X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=VHDLTools.hs;h=e4aad6f497a685c1b6d6dbd0e732bb98ac0f456c;hb=65d99830e416463d66f97581ece93da49f746778;hp=359597f3395485f1ad96b525da9e4b837cbc14ca;hpb=6fcd2ccf28d4b34eca94eb868ecac83cc5a2c144;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/VHDLTools.hs b/VHDLTools.hs index 359597f..e4aad6f 100644 --- a/VHDLTools.hs +++ b/VHDLTools.hs @@ -447,8 +447,9 @@ mkHType ty = do elem_htype_either <- mkHType el_ty case elem_htype_either of -- Could create element type - Right elem_htype -> - return $ Right $ VecType (tfvec_len ty) elem_htype + Right elem_htype -> do + len <- vec_len ty + return $ Right $ VecType len elem_htype -- Could not create element type Left err -> return $ Left $ "VHDLTools.mkHType: Can not construct vectortype for elementtype: " ++ pprString el_ty ++ "\n" @@ -479,3 +480,23 @@ mkTyConHType tycon args = where tyvars = TyCon.tyConTyVars tycon subst = CoreSubst.extendTvSubstList CoreSubst.emptySubst (zip tyvars args) + +-- Is the given type representable at runtime? +isReprType :: Type.Type -> TypeSession Bool +isReprType ty = do + ty_either <- vhdl_ty_either ty + return $ case ty_either of + Left _ -> False + Right _ -> True + +vec_len :: Type.Type -> TypeSession Int +vec_len ty = do + veclens <- getA vsTfpInts + let len_ty = tfvec_len_ty ty + let existing_len = Map.lookup (OrdType len_ty) veclens + case existing_len of + Just len -> return len + Nothing -> do + let new_len = tfvec_len ty + modA vsTfpInts (Map.insert (OrdType len_ty) (new_len)) + return new_len \ No newline at end of file