From 1730303a697c4c35941919ada4e45e7a64803a7f Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 6 Feb 2009 12:19:36 +0100 Subject: [PATCH] Add accessor methods for FlattenState. --- Flatten.hs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Flatten.hs b/Flatten.hs index 3c5fda7..ee70446 100644 --- a/Flatten.hs +++ b/Flatten.hs @@ -22,12 +22,13 @@ data FlatFunction = FlatFunction { type SignalUseMap = HsValueMap SignalUse type SignalDefMap = HsValueMap SignalDef +type SignalId = Int data SignalUse = SignalUse { - sigUseId :: Int + sigUseId :: SignalId } deriving (Show, Eq) data SignalDef = SignalDef { - sigDefId :: Int + sigDefId :: SignalId } deriving (Show, Eq) data App = App { @@ -75,7 +76,26 @@ type BindMap = [( ) )] -type FlattenState = State.State ([App], [CondDef], Int) +type FlattenState = State.State ([App], [CondDef], SignalId) + +-- | Add an application to the current FlattenState +addApp :: App -> FlattenState () +addApp a = do + (apps, conds, n) <- State.get + State.put (a:apps, conds, n) + +-- | Add a conditional definition to the current FlattenState +addCondDef :: CondDef -> FlattenState () +addCondDef c = do + (apps, conds, n) <- State.get + State.put (apps, c:conds, n) + +-- | Generates a new signal id, which is unique within the current flattening. +genSignalId :: FlattenState SignalId +genSignalId = do + (apps, conds, n) <- State.get + State.put (apps, conds, n+1) + return n -- | Flatten a haskell function flattenFunction :: -- 2.30.2