diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2024-09-28 17:23:32 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2024-09-28 17:23:32 -0600 |
commit | 719c8f8ed3d1e6337f27d3b9d5a033a4b63726b8 (patch) | |
tree | 80008d173d549ff3a347b1614d41adfb12e3e8bf /src/Language/Fiddle/Compiler/ConsistencyCheck.hs | |
parent | 35b7ae9561b3dc312b857cadb3e99e14594d29a6 (diff) | |
download | fiddle-719c8f8ed3d1e6337f27d3b9d5a033a4b63726b8.tar.gz fiddle-719c8f8ed3d1e6337f27d3b9d5a033a4b63726b8.tar.bz2 fiddle-719c8f8ed3d1e6337f27d3b9d5a033a4b63726b8.zip |
wip
Diffstat (limited to 'src/Language/Fiddle/Compiler/ConsistencyCheck.hs')
-rw-r--r-- | src/Language/Fiddle/Compiler/ConsistencyCheck.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/Language/Fiddle/Compiler/ConsistencyCheck.hs b/src/Language/Fiddle/Compiler/ConsistencyCheck.hs index 5c7b399..908db52 100644 --- a/src/Language/Fiddle/Compiler/ConsistencyCheck.hs +++ b/src/Language/Fiddle/Compiler/ConsistencyCheck.hs @@ -33,12 +33,15 @@ import GHC.TypeLits import Language.Fiddle.Ast import Language.Fiddle.Compiler import Language.Fiddle.Internal.Scopes +import Language.Fiddle.Internal.UnitInterface import Language.Fiddle.Types (Commented (unCommented), SourceSpan) import Text.Printf (printf) import Prelude hiding (unzip) -newtype GlobalState = GlobalState - { globalScope :: Scope String (Either SizeBits SizeBytes) +data GlobalState = GlobalState + { globalScope :: Scope String (Either SizeBits SizeBytes), + fileDependencies :: [FilePath], + unitInterface :: UnitInterface } newtype LocalState = LocalState (ScopePath String) @@ -61,7 +64,7 @@ checkConsistency :: Compile () (FiddleUnit Checked I Annot) checkConsistency = fmap snd - . subCompile (GlobalState mempty) + . subCompile (GlobalState mempty mempty) . advanceStage (LocalState mempty) instance CompilationStage Checked where @@ -78,7 +81,11 @@ instance CompilationStage Expanded where type StageFunctor Expanded = Identity type StageAnnotation Expanded = Commented SourceSpan -deriving instance AdvanceStage Expanded FiddleUnit +instance AdvanceStage Expanded FiddleUnit + +-- advanceStage localState (FiddleUnit decls _ annot) = do + +-- decls' <- mapM (advanceStage localState) decls deriving instance AdvanceStage Expanded Expression @@ -528,7 +535,7 @@ insertTypeSize :: Compile GlobalState () insertTypeSize (LocalState scopePath) (Identifier s annot) size = do modifyM $ - \(GlobalState globalScope) -> + \state@GlobalState {globalScope = globalScope} -> let fullName = NonEmpty.prependList (currentScope scopePath) @@ -537,7 +544,7 @@ insertTypeSize (LocalState scopePath) (Identifier s annot) size = do (Just _, _) -> do diagnosticError (printf "Duplicate type %s" s) annot compilationFailure - (Nothing, n) -> return $ GlobalState n + (Nothing, n) -> return $ state {globalScope = n} where modifyM fn = do s <- get |