Move around some helper functions.
[matthijs/master-project/cλash.git] / cλash / CLasH / Translator / TranslatorTypes.hs
index 5fb97c2b31831c4c1f5380d51f5250ceacd57517..de7ee52055b23835174e29571c8172df04705283 100644 (file)
@@ -62,13 +62,6 @@ data TypeState = TypeState {
 -- Derive accessors
 $( Data.Accessor.Template.deriveAccessors ''TypeState )
 
--- Compatibility with old VHDLSession
-vsTypes = tsTypes
-vsTypeDecls = tsTypeDecls
-vsTypeFuns = tsTypeFuns
-vsTfpInts = tsTfpInts
-vsHscEnv = tsHscEnv
-
 -- Define a session
 type TypeSession = State.State TypeState
 -- A global state for the translator
@@ -86,12 +79,9 @@ $( Data.Accessor.Template.deriveAccessors ''TranslatorState )
 
 type TranslatorSession = State.State TranslatorState
 
--- Compatibility for the old VHDLSesssion
-vsType = tsType
-type VHDLSession = TranslatorSession
-
--- Compatibility for the old TransformSession
-type TransformSession = TranslatorSession
+-----------------------------------------------------------------------------
+-- Some accessors
+-----------------------------------------------------------------------------
 
 -- Does the given binder reference a top level binder in the current
 -- module(s)?
@@ -100,4 +90,20 @@ isTopLevelBinder bndr = do
   bindings <- getA tsBindings
   return $ Map.member bndr bindings
 
+-- Finds the value of a global binding, if available
+getGlobalBind :: CoreSyn.CoreBndr -> TranslatorSession (Maybe CoreSyn.CoreExpr)
+getGlobalBind bndr = do
+  bindings <- getA tsBindings
+  return $ Map.lookup bndr bindings 
+
+-- Adds a new global binding with the given value
+addGlobalBind :: CoreSyn.CoreBndr -> CoreSyn.CoreExpr -> TranslatorSession ()
+addGlobalBind bndr expr = modA tsBindings (Map.insert bndr expr)
+
+-- Returns a list of all global binders
+getGlobalBinders :: TranslatorSession [CoreSyn.CoreBndr]
+getGlobalBinders = do
+  bindings <- getA tsBindings
+  return $ Map.keys bindings
+
 -- vim: set ts=8 sw=2 sts=2 expandtab: