X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=c%CE%BBash%2FCLasH%2FUtils%2FCore%2FBinderTools.hs;h=8d0751b5469b623137b25ecbb300826f67b42723;hb=f3951a1376fc7d7f8addbe9e9fed071320502100;hp=a072c45f2ee95389672704fce4a9f6e412145752;hpb=b83ea5327202d46fc976e369ac303608cbc2330e;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git "a/c\316\273ash/CLasH/Utils/Core/BinderTools.hs" "b/c\316\273ash/CLasH/Utils/Core/BinderTools.hs" index a072c45..8d0751b 100644 --- "a/c\316\273ash/CLasH/Utils/Core/BinderTools.hs" +++ "b/c\316\273ash/CLasH/Utils/Core/BinderTools.hs" @@ -4,10 +4,10 @@ module CLasH.Utils.Core.BinderTools where -- Standard modules -import Data.Accessor.MonadState as MonadState +import qualified Data.Accessor.Monad.Trans.State as MonadState -- GHC API -import CoreSyn +import qualified CoreSyn import qualified Type import qualified UniqSupply import qualified Unique @@ -17,21 +17,16 @@ import qualified Var import qualified SrcLoc import qualified IdInfo import qualified CoreUtils -import qualified CoreSubst -import qualified VarSet -import qualified HscTypes -- Local imports -import Data.Accessor -import Data.Accessor.MonadState as MonadState import CLasH.Translator.TranslatorTypes -- Create a new Unique mkUnique :: TranslatorSession Unique.Unique mkUnique = do - us <- getA tsUniqSupply + us <- MonadState.get tsUniqSupply let (us', us'') = UniqSupply.splitUniqSupply us - putA tsUniqSupply us' + MonadState.set tsUniqSupply us' return $ UniqSupply.uniqFromSupply us'' -- Create a new internal var with the given name and type. A Unique is @@ -59,15 +54,15 @@ mkTypeVar str kind = do -- Creates a binder for the given expression with the given name. This -- works for both value and type level expressions, so it can return a Var or -- TyVar (which is just an alias for Var). -mkBinderFor :: CoreExpr -> String -> TranslatorSession Var.Var -mkBinderFor (Type ty) string = mkTypeVar string (Type.typeKind ty) +mkBinderFor :: CoreSyn.CoreExpr -> String -> TranslatorSession Var.Var +mkBinderFor (CoreSyn.Type ty) string = mkTypeVar string (Type.typeKind ty) mkBinderFor expr string = mkInternalVar string (CoreUtils.exprType expr) -- Creates a reference to the given variable. This works for both a normal -- variable as well as a type variable -mkReferenceTo :: Var.Var -> CoreExpr -mkReferenceTo var | Var.isTyVar var = (Type $ Type.mkTyVarTy var) - | otherwise = (Var var) +mkReferenceTo :: Var.Var -> CoreSyn.CoreExpr +mkReferenceTo var | Var.isTyVar var = (CoreSyn.Type $ Type.mkTyVarTy var) + | otherwise = (CoreSyn.Var var) cloneVar :: Var.Var -> TranslatorSession Var.Var cloneVar v = do @@ -79,7 +74,7 @@ cloneVar v = do -- Creates a new function with the same name as the given binder (but with a -- new unique) and with the given function body. Returns the new binder for -- this function. -mkFunction :: CoreBndr -> CoreExpr -> TranslatorSession CoreBndr +mkFunction :: CoreSyn.CoreBndr -> CoreSyn.CoreExpr -> TranslatorSession CoreSyn.CoreBndr mkFunction bndr body = do let ty = CoreUtils.exprType body id <- cloneVar bndr