X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=FlattenTypes.hs;h=4e2640a8ee7d18520ea0f72333ce0b63bb248385;hb=a8d7c5bd4b745860f321d4315bff0b9efa3cb05c;hp=49ca8c04533cbeab1616846c7ff1e5c1da2ac1bb;hpb=1f0b33729534d451d7dcc46d4614d1a12b31ea82;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/FlattenTypes.hs b/FlattenTypes.hs index 49ca8c0..4e2640a 100644 --- a/FlattenTypes.hs +++ b/FlattenTypes.hs @@ -4,6 +4,7 @@ import Data.Traversable import qualified Control.Monad.State as State import CoreSyn +import qualified Type import HsValueMap @@ -75,9 +76,10 @@ data CondDef sigid = CondDef { } deriving (Show, Eq) -- | Information on a signal definition -data Signal sigid = Signal { - id :: sigid -} deriving (Eq, Show) +data SignalInfo = SignalInfo { + sigName :: Maybe String, + sigTy :: Type.Type +} -- | A flattened function data FlatFunction' sigid = FlatFunction { @@ -85,8 +87,8 @@ data FlatFunction' sigid = FlatFunction { res :: SignalMap sigid, apps :: [FApp sigid], conds :: [CondDef sigid], - sigs :: [Signal sigid] -} deriving (Show, Eq) + sigs :: [(sigid, SignalInfo)] +} -- | A flat function that does not have its signals named type FlatFunction = FlatFunction' UnnamedSignal @@ -104,24 +106,25 @@ type BindMap = [( )] -- | The state during the flattening of a single function -type FlattenState = State.State ([FApp UnnamedSignal], [CondDef UnnamedSignal], UnnamedSignal) +type FlattenState = State.State ([FApp UnnamedSignal], [CondDef UnnamedSignal], [(UnnamedSignal, SignalInfo)], UnnamedSignal) -- | Add an application to the current FlattenState addApp :: (FApp UnnamedSignal) -> FlattenState () addApp a = do - (apps, conds, n) <- State.get - State.put (a:apps, conds, n) + (apps, conds, sigs, n) <- State.get + State.put (a:apps, conds, sigs, n) -- | Add a conditional definition to the current FlattenState addCondDef :: (CondDef UnnamedSignal) -> FlattenState () addCondDef c = do - (apps, conds, n) <- State.get - State.put (apps, c:conds, n) + (apps, conds, sigs, n) <- State.get + State.put (apps, c:conds, sigs, n) -- | Generates a new signal id, which is unique within the current flattening. -genSignalId :: FlattenState UnnamedSignal -genSignalId = do - (apps, conds, n) <- State.get - State.put (apps, conds, n+1) +genSignalId :: Type.Type -> FlattenState UnnamedSignal +genSignalId ty = do + (apps, conds, sigs, n) <- State.get + -- Generate a new numbered but unnamed signal + let s = (n, SignalInfo Nothing ty) + State.put (apps, conds, s:sigs, n+1) return n -