From: Matthijs Kooijman Date: Tue, 13 Apr 2010 12:38:23 +0000 (+0200) Subject: Add genCoreArgs wrapper to VHDL.Generate. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=07a6394442d0d83a754af8f0d90f3702bb1821c6;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add genCoreArgs wrapper to VHDL.Generate. --- diff --git "a/c\316\273ash/CLasH/VHDL/Generate.hs" "b/c\316\273ash/CLasH/VHDL/Generate.hs" index da5d2ea..07cf0e8 100644 --- "a/c\316\273ash/CLasH/VHDL/Generate.hs" +++ "b/c\316\273ash/CLasH/VHDL/Generate.hs" @@ -342,13 +342,22 @@ genNoInsts wrap dst func args = do genVarArgs :: (dst -> func -> [Var.Var] -> res) -> (dst -> func -> [Either CoreSyn.CoreExpr AST.Expr] -> res) -genVarArgs wrap dst func args = wrap dst func args' +genVarArgs wrap = genCoreArgs $ \dst func args -> let + args' = map exprToVar args + in + wrap dst func args' + +-- | A function to wrap a builder-like function that expects its arguments to +-- be core expressions. +genCoreArgs :: + (dst -> func -> [CoreSyn.CoreExpr] -> res) + -> (dst -> func -> [Either CoreSyn.CoreExpr AST.Expr] -> res) +genCoreArgs wrap dst func args = wrap dst func args' where - args' = map exprToVar args'' -- Check (rather crudely) that all arguments are CoreExprs - args'' = case Either.partitionEithers args of + args' = case Either.partitionEithers args of (exprargs, []) -> exprargs - (exprsargs, rest) -> error $ "\nGenerate.genVarArgs: expect varargs but found ast exprs:" ++ (show rest) + (exprsargs, rest) -> error $ "\nGenerate.genCoreArgs: expect core expression arguments but found ast exprs:" ++ (show rest) -- | A function to wrap a builder-like function that expects its arguments to -- be Literals