From: Matthijs Kooijman Date: Wed, 11 Feb 2009 19:13:10 +0000 (+0100) Subject: Fill the signal list in FlatFunction. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=668cd4041980db707d6afb0cfb5aed4036b0b46b;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Fill the signal list in FlatFunction. --- diff --git a/Flatten.hs b/Flatten.hs index 1297793..e62f186 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -53,12 +53,12 @@ flattenFunction :: flattenFunction _ (Rec _) = error "Recursive binders not supported" flattenFunction hsfunc bind@(NonRec var expr) = - FlatFunction args res apps conds [] + FlatFunction args res apps conds sigs where - init_state = ([], [], 0) + init_state = ([], [], [], 0) (fres, end_state) = State.runState (flattenExpr [] expr) init_state (args, res) = fres - (apps, conds, _) = end_state + (apps, conds, sigs, _) = end_state flattenExpr :: BindMap diff --git a/FlattenTypes.hs b/FlattenTypes.hs index 49ca8c0..024db9b 100644 --- a/FlattenTypes.hs +++ b/FlattenTypes.hs @@ -104,24 +104,24 @@ 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], [Signal UnnamedSignal], 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) + (apps, conds, sigs, n) <- State.get + let s = Signal n + State.put (apps, conds, s:sigs, n+1) return n -