From a1b19f34a500caafbfc494ed101eb457ffc3262b Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Wed, 16 Jun 2010 13:28:47 +0200 Subject: [PATCH] Let genApplication handle (built-in) enumeration types. Since datacons are no longer seen as local variables, genApplication sees simple datacons without arguments (e.g., x = True). Now it knows how to handle these. --- clash/CLasH/VHDL/Generate.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/clash/CLasH/VHDL/Generate.hs b/clash/CLasH/VHDL/Generate.hs index 022adea..80b2d43 100644 --- a/clash/CLasH/VHDL/Generate.hs +++ b/clash/CLasH/VHDL/Generate.hs @@ -1102,8 +1102,21 @@ genApplication dst f args = do mkassign label arg = let sel_name = mkSelectedName ((either varToVHDLName id) dst) label in mkUncondAssign (Right sel_name) arg + -- Enumeration types have no arguments and are just + -- simple assignments + Right (EnumType _ _) -> + simple_assign + -- These builtin types are also enumeration types + Right (BuiltinType tyname) | tyname `elem` ["Bit", "Bool"] -> + simple_assign Right _ -> error $ "Datacon application does not result in a aggregate type? datacon: " ++ pprString f ++ " Args: " ++ show args Left _ -> error $ "Unrepresentable result type in datacon application? datacon: " ++ pprString f ++ " Args: " ++ show args + where + -- Simple uncoditional assignment, for (built-in) + -- enumeration types + simple_assign = do + expr <- MonadState.lift tsType $ dataconToVHDLExpr dc + return ([mkUncondAssign dst expr], []) Right _ -> error "\nGenerate.genApplication(DataConWorkId): Can't generate dataconstructor application without an original binder" IdInfo.DataConWrapId dc -> case dst of -- 2.30.2