From: Matthijs Kooijman Date: Wed, 16 Jun 2010 11:28:47 +0000 (+0200) Subject: Let genApplication handle (built-in) enumeration types. X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fmaster-project%2Fc%CE%BBash.git;a=commitdiff_plain;h=a1b19f34a500caafbfc494ed101eb457ffc3262b;hp=d8b60ced4dcb0498199608f25db4f9989d0e7a3f 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. --- 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