From: Matthijs Kooijman Date: Fri, 13 Feb 2009 12:36:20 +0000 (+0100) Subject: Store the Haskell Type in SignalInfo. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=b0beb407a0e6fa06767b892e5e9dd8c9c8526eac;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Store the Haskell Type in SignalInfo. --- diff --git a/Flatten.hs b/Flatten.hs index e62f186..cd51585 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -38,7 +38,7 @@ typeMapToUseMap :: -> FlattenState (SignalMap UnnamedSignal) typeMapToUseMap (Single ty) = do - id <- genSignalId + id <- genSignalId ty return $ Single id typeMapToUseMap (Tuple tymaps) = do diff --git a/FlattenTypes.hs b/FlattenTypes.hs index 7838dcd..c8cd306 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 @@ -76,8 +77,9 @@ data CondDef sigid = CondDef { -- | Information on a signal definition data SignalInfo = SignalInfo { - name :: Maybe String -} deriving (Eq, Show) + name :: Maybe String, + ty :: Type.Type +} -- | A flattened function data FlatFunction' sigid = FlatFunction { @@ -86,7 +88,7 @@ data FlatFunction' sigid = FlatFunction { apps :: [FApp sigid], conds :: [CondDef sigid], sigs :: [(sigid, SignalInfo)] -} deriving (Show, Eq) +} -- | A flat function that does not have its signals named type FlatFunction = FlatFunction' UnnamedSignal @@ -119,10 +121,10 @@ addCondDef c = do State.put (apps, c:conds, sigs, n) -- | Generates a new signal id, which is unique within the current flattening. -genSignalId :: FlattenState UnnamedSignal -genSignalId = do +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) + let s = (n, SignalInfo Nothing ty) State.put (apps, conds, s:sigs, n+1) return n diff --git a/Pretty.hs b/Pretty.hs index 3797fe2..98a3d33 100644 --- a/Pretty.hs +++ b/Pretty.hs @@ -47,8 +47,8 @@ instance Pretty id => Pretty (CondDef id) where pPrint _ = text "TODO" instance Pretty SignalInfo where - pPrint (SignalInfo Nothing) = empty - pPrint (SignalInfo (Just name)) = text ":" <> text name + pPrint (SignalInfo Nothing ty) = empty + pPrint (SignalInfo (Just name) ty) = text ":" <> text name instance Pretty VHDLSession where pPrint (VHDLSession mod nameCount funcs) = diff --git a/Translator.hs b/Translator.hs index b7d3e0e..78c3a6f 100644 --- a/Translator.hs +++ b/Translator.hs @@ -186,7 +186,7 @@ nameFlatFunction hsfunc fdata = -- Name the signals in all other functions Just flatfunc -> let s = sigs flatfunc in - let s' = map (\(id, (SignalInfo Nothing)) -> (id, SignalInfo (Just $ "sig_" ++ (show id)))) s in + let s' = map (\(id, (SignalInfo Nothing ty)) -> (id, SignalInfo (Just $ "sig_" ++ (show id)) ty)) s in let flatfunc' = flatfunc { sigs = s' } in fdata { flatFunc = Just flatfunc' }