Add genCoreArgs wrapper to VHDL.Generate.
authorMatthijs Kooijman <matthijs@stdin.nl>
Tue, 13 Apr 2010 12:38:23 +0000 (14:38 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Tue, 13 Apr 2010 12:38:23 +0000 (14:38 +0200)
cλash/CLasH/VHDL/Generate.hs

index da5d2ea770a6632df98b05d183f0ab6c0cbdcffe..07cf0e89864022936af27fa5c9f0fd6cb6719ecc 100644 (file)
@@ -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 ::
   (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
   where
-    args' = map exprToVar args''
     -- Check (rather crudely) that all arguments are CoreExprs
     -- Check (rather crudely) that all arguments are CoreExprs
-    args'' = case Either.partitionEithers args of 
+    args' = case Either.partitionEithers args of 
       (exprargs, []) -> exprargs
       (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
 
 -- | A function to wrap a builder-like function that expects its arguments to
 -- be Literals