diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-09-27 16:20:32 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-09-27 16:24:10 -0600 |
commit | 21e6e5940ecb462436b8dc94428c5cee5cdc9072 (patch) | |
tree | 01405c637f904f24feadc177a84ab9bae7c8c99c /src/Language/Fiddle/Internal | |
parent | a4cffc1eeb547f780068875a703251db6aa41d6c (diff) | |
download | fiddle-21e6e5940ecb462436b8dc94428c5cee5cdc9072.tar.gz fiddle-21e6e5940ecb462436b8dc94428c5cee5cdc9072.tar.bz2 fiddle-21e6e5940ecb462436b8dc94428c5cee5cdc9072.zip |
Add import resolution phase and also add a more abstractions around
compliation phases.
Diffstat (limited to 'src/Language/Fiddle/Internal')
-rw-r--r-- | src/Language/Fiddle/Internal/Scopes.hs | 2 | ||||
-rw-r--r-- | src/Language/Fiddle/Internal/UnitInterface.hs | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/Language/Fiddle/Internal/Scopes.hs b/src/Language/Fiddle/Internal/Scopes.hs index 302eab2..83ea144 100644 --- a/src/Language/Fiddle/Internal/Scopes.hs +++ b/src/Language/Fiddle/Internal/Scopes.hs @@ -14,6 +14,7 @@ data Scope k v = Scope { subScopes :: Map k (Scope k v), -- Nested sub-scopes scopeValues :: Map k v -- Values stored in the current scope } + deriving (Eq, Ord, Show, Read) -- | 'ScopePath' keeps track of the current scope path as a list of keys, -- and also includes any additional paths (like imported modules or @@ -22,6 +23,7 @@ data ScopePath k = ScopePath { currentScope :: [k], -- Current path within the scope hierarchy usingPaths :: [[k]] -- Additional paths for resolving symbols } + deriving (Eq, Ord, Show, Read) -- | The 'Semigroup' instance for 'Scope' allows combining two scopes, -- where sub-scopes and values are merged together. diff --git a/src/Language/Fiddle/Internal/UnitInterface.hs b/src/Language/Fiddle/Internal/UnitInterface.hs new file mode 100644 index 0000000..1f12c4c --- /dev/null +++ b/src/Language/Fiddle/Internal/UnitInterface.hs @@ -0,0 +1,34 @@ +module Language.Fiddle.Internal.UnitInterface where + +import Data.Text +import Data.Word +import Language.Fiddle.Internal.Scopes (Scope) +import Language.Fiddle.Types (SourceSpan) + +data Annotated a = Annotated + { sourceSpan :: SourceSpan, + docComment :: Text, + internal :: a + } + deriving (Eq, Ord, Show) + +-- | Contains a datastructure which represents a FiddleUnit. +-- +-- These datastructures contain the exported symobls of a fiddle unit and it's +-- direct dependencies. +data UnitInterface where + UnitInterface :: + { rootScope :: Scope String (Annotated ExportedValue), + dependencies :: [FilePath] + } -> + UnitInterface + deriving (Eq, Ord, Show) + +data ExportedValue where + ExportedBitsType :: + {exportBitsTypeSize :: Word32} -> + ExportedValue + ExportedObjType :: + {exportObjTypeSize :: Word32} -> + ExportedValue + deriving (Show, Eq, Ord) |