summaryrefslogtreecommitdiff
path: root/src/Language/Fiddle/Compiler
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-10-03 12:58:38 -0600
committerJosh Rahm <joshuarahm@gmail.com>2024-10-03 12:58:38 -0600
commit5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359 (patch)
tree7a4afc937e94365e486bf978dc7d91e5a20ef04e /src/Language/Fiddle/Compiler
parentae5ea355a32eff2b1b1762f4ac2389d94f388df7 (diff)
downloadfiddle-5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359.tar.gz
fiddle-5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359.tar.bz2
fiddle-5d0b8e6371d1e365ff9b10e0160a39f0f1d9f359.zip
Make changes to AST for qualification step.
Diffstat (limited to 'src/Language/Fiddle/Compiler')
-rw-r--r--src/Language/Fiddle/Compiler/ConsistencyCheck.hs14
-rw-r--r--src/Language/Fiddle/Compiler/Expansion.hs15
-rw-r--r--src/Language/Fiddle/Compiler/Qualification.hs2
3 files changed, 15 insertions, 16 deletions
diff --git a/src/Language/Fiddle/Compiler/ConsistencyCheck.hs b/src/Language/Fiddle/Compiler/ConsistencyCheck.hs
index 2f570a4..7ca618b 100644
--- a/src/Language/Fiddle/Compiler/ConsistencyCheck.hs
+++ b/src/Language/Fiddle/Compiler/ConsistencyCheck.hs
@@ -159,18 +159,18 @@ deriving instance AdvanceStage CurrentStage FiddleDecl
instance AdvanceStage CurrentStage (Directed FiddleDecl) where
modifyState (Directed directives t _) s = case t of
- (BitsDecl id typ annotation) -> do
+ (BitsDecl () id typ annotation) -> do
typeSize <- getTypeSize typ
insertTypeSize annotation s id typeSize
return s
- (PackageDecl n _ _) -> do
+ (PackageDecl () n _ _) -> do
let strs = nameToList n
let (LocalState scopePath) = s
return $
LocalState $
scopePath {currentScope = strs ++ currentScope scopePath}
- (UsingDecl n _) ->
+ (UsingDecl _ n _) ->
let (LocalState scopePath) = s
in return $
LocalState $
@@ -180,7 +180,7 @@ instance AdvanceStage CurrentStage (Directed FiddleDecl) where
_ -> return s
customAdvanceStage (Directed directives t a) (LocalState scopePath) = case t of
- (ObjTypeDecl ident (Identity body) annot) -> do
+ (ObjTypeDecl () ident (Identity body) annot) -> do
(body', size) <- objTypeBodyToStage3 (LocalState scopePath) body 0
let fullName =
@@ -192,7 +192,7 @@ instance AdvanceStage CurrentStage (Directed FiddleDecl) where
let ui' = insertIntoUnitInterface fullName ui annot (ExportedObjType size)
modify' $ \gs -> gs {unitInterface = ui'}
- return $ Just $ Directed directives (ObjTypeDecl ident (Identity body') annot) a
+ return $ Just $ Directed directives (ObjTypeDecl () ident (Identity body') annot) a
_ -> return Nothing
nameToList :: Name f a -> [String]
@@ -456,8 +456,8 @@ registerBitsTypeRefToStage3 localState = \case
( RegisterBitsArray ref' expr' a,
size * fromIntegral multiplier
)
- RegisterBitsReference name a ->
- (RegisterBitsReference name a,) <$> lookupTypeSize localState name
+ RegisterBitsReference () name a ->
+ (RegisterBitsReference () name a,) <$> lookupTypeSize localState name
RegisterBitsJustBits expr a -> do
expr' <- advanceStage localState expr
(RegisterBitsJustBits expr' a,)
diff --git a/src/Language/Fiddle/Compiler/Expansion.hs b/src/Language/Fiddle/Compiler/Expansion.hs
index f10fa5f..202717f 100644
--- a/src/Language/Fiddle/Compiler/Expansion.hs
+++ b/src/Language/Fiddle/Compiler/Expansion.hs
@@ -123,8 +123,8 @@ instance AdvanceStage CurrentStage RegisterBitsTypeRef where
<$> advanceStage path typeref
<*> advanceStage path expr
<*> pure annot
- RegisterBitsReference name annot ->
- return $ RegisterBitsReference name annot
+ RegisterBitsReference () name annot ->
+ return $ RegisterBitsReference () name annot
RegisterBitsJustBits expr annot ->
RegisterBitsJustBits
<$> advanceStage path expr
@@ -133,16 +133,16 @@ instance AdvanceStage CurrentStage RegisterBitsTypeRef where
ident <-
internAnonymousBitsType path
=<< advanceStage path anonType
- return $ RegisterBitsReference (identToName ident) annot
+ return $ RegisterBitsReference () (identToName ident) annot
instance AdvanceStage CurrentStage ObjType where
advanceStage path = \case
(AnonymousObjType _ (Identity body) annot) -> do
body' <- advanceStage path body
identifier <- internObjType path body'
- return (ReferencedObjType (identToName identifier) annot)
- (ReferencedObjType name annot) ->
- return $ ReferencedObjType name annot
+ return (ReferencedObjType () (identToName identifier) annot)
+ (ReferencedObjType () name annot) ->
+ return $ ReferencedObjType () name annot
(ArrayObjType objType expr a) ->
ArrayObjType
<$> advanceStage path objType
@@ -200,12 +200,13 @@ reconfigureFiddleDecls p decls = do
where
resolveAnonymousObjType (Linkage linkage, objTypeBody) =
ObjTypeDecl
+ ()
(Identifier linkage (annot objTypeBody))
(pure objTypeBody)
(annot objTypeBody)
resolveAnonymousBitsType (Linkage linkage, AnonymousEnumBody expr body a) =
- BitsDecl (Identifier linkage a) (EnumBitType expr body a) a
+ BitsDecl () (Identifier linkage a) (EnumBitType expr body a) a
identToName :: Identifier I a -> Name I a
identToName ident = Name (NonEmpty.singleton ident) (annot ident)
diff --git a/src/Language/Fiddle/Compiler/Qualification.hs b/src/Language/Fiddle/Compiler/Qualification.hs
index 146fd61..f8fbc0a 100644
--- a/src/Language/Fiddle/Compiler/Qualification.hs
+++ b/src/Language/Fiddle/Compiler/Qualification.hs
@@ -8,8 +8,6 @@
--
-- In this phase, symbol resolution statements (such as 'using' statements) are
-- removed, as they become unnecessary once references are fully qualified.
--- Additionally, package structures are flattened, and package declarations are
--- discarded since full qualification renders them redundant.
module Language.Fiddle.Compiler.Qualification (qualificationPhase) where
import Control.Monad.Identity