X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FTranslator%2FTranslatorTypes.hs;h=de7ee52055b23835174e29571c8172df04705283;hb=b83ea5327202d46fc976e369ac303608cbc2330e;hp=6871861f839c52b8e8e13a18c658689ce215c51c;hpb=bf9f8e9e9cfce93ae1e35cf524b371beb34f5010;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git "a/c\316\273ash/CLasH/Translator/TranslatorTypes.hs" "b/c\316\273ash/CLasH/Translator/TranslatorTypes.hs" index 6871861..de7ee52 100644 --- "a/c\316\273ash/CLasH/Translator/TranslatorTypes.hs" +++ "b/c\316\273ash/CLasH/Translator/TranslatorTypes.hs" @@ -79,6 +79,10 @@ $( Data.Accessor.Template.deriveAccessors ''TranslatorState ) type TranslatorSession = State.State TranslatorState +----------------------------------------------------------------------------- +-- Some accessors +----------------------------------------------------------------------------- + -- Does the given binder reference a top level binder in the current -- module(s)? isTopLevelBinder :: CoreSyn.CoreBndr -> TranslatorSession Bool @@ -86,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: