From: Matthijs Kooijman Date: Thu, 6 Aug 2009 17:09:11 +0000 (+0200) Subject: Let argsToVHDLExpr ignore empty types. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=e9fdb64bf7174b8608d9b1c7004fdcbe3dd23a9c;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Let argsToVHDLExpr ignore empty types. This makes sure that state arguments are not passed to called functions. --- diff --git "a/c\316\273ash/CLasH/VHDL/Generate.hs" "b/c\316\273ash/CLasH/VHDL/Generate.hs" index 31c9c8d..827315c 100644 --- "a/c\316\273ash/CLasH/VHDL/Generate.hs" +++ "b/c\316\273ash/CLasH/VHDL/Generate.hs" @@ -204,11 +204,19 @@ genExprArgs wrap dst func args = do -- | Turn the all lefts into VHDL Expressions. argsToVHDLExprs :: [Either CoreSyn.CoreExpr AST.Expr] -> TranslatorSession [AST.Expr] -argsToVHDLExprs = mapM argToVHDLExpr - -argToVHDLExpr :: Either CoreSyn.CoreExpr AST.Expr -> TranslatorSession AST.Expr -argToVHDLExpr (Left expr) = MonadState.lift tsType $ varToVHDLExpr (exprToVar expr) -argToVHDLExpr (Right expr) = return expr +argsToVHDLExprs = catMaybesM . (mapM argToVHDLExpr) + +argToVHDLExpr :: Either CoreSyn.CoreExpr AST.Expr -> TranslatorSession (Maybe AST.Expr) +argToVHDLExpr (Left expr) = MonadState.lift tsType $ do + let errmsg = "Generate.argToVHDLExpr: Using non-representable type? Should not happen!" + ty_maybe <- vhdl_ty errmsg expr + case ty_maybe of + Just _ -> do + vhdl_expr <- varToVHDLExpr $ exprToVar expr + return $ Just vhdl_expr + Nothing -> return $ Nothing + +argToVHDLExpr (Right expr) = return $ Just expr -- A function to wrap a builder-like function that generates no component -- instantiations