Enum literals are now correctly translated to numbers
[matthijs/master-project/cλash.git] / clash / CLasH / VHDL / VHDLTools.hs
index edaa5d2128ae271c782869ac5c8835aa70067f34..3dcd951bcb7a9822509fc77d0807f2a137734aeb 100644 (file)
@@ -192,7 +192,7 @@ dataconToVHDLExpr dc = do
           let existing_ty = Monad.liftM (fmap fst) $ Map.lookup htype typemap
           case existing_ty of
             Just ty -> do
-              let lit    = idToVHDLExpr $ mkVHDLExtId $ Name.getOccString dcname
+              let lit    = AST.PrimLit $ show $ getConstructorIndex htype $ Name.getOccString dcname
               return lit
             Nothing -> error $ "\nVHDLTools.dataconToVHDLExpr: Trying to make value for non-representable DataCon: " ++ pprString dc
     -- Error when constructing htype
@@ -649,7 +649,7 @@ mkAdtShow conLbl conIds elemIdss adtTM = AST.SubProgBody showSpec [] [showExpr]
                   [AST.CaseSmAlt [AST.ChoiceE $ AST.PrimLit $ show x] 
                     [AST.ReturnSm (Just $ ((genExprFCall showId) . (selectedName adtPar) $ mkVHDLBasicId conLbl) AST.:&: showFields x)] | x <- [0..(length conIds) -1]]
     showFields i = if (null (elemIdss!!i)) then
-        AST.PrimLit "''"
+        AST.PrimLit "nul"
       else
         foldr1 (\e1 e2 -> e1 AST.:&: e2) $
               map ((AST.PrimLit "' '" AST.:&:) . (genExprFCall showId) . (selectedName adtPar))