Generation of DataCons for implicit PArray instances
authorRoman Leshchinskiy <rl@cse.unsw.edu.au>
Wed, 18 Jul 2007 02:52:35 +0000 (02:52 +0000)
committerRoman Leshchinskiy <rl@cse.unsw.edu.au>
Wed, 18 Jul 2007 02:52:35 +0000 (02:52 +0000)
compiler/vectorise/VectType.hs

index 45b22ad..ebf1797 100644 (file)
@@ -15,6 +15,7 @@ import OccName
 import MkId
 import BasicTypes        ( StrictnessMark(..), boolToRecFlag )
 import NameEnv
+import TysWiredIn
 
 import Unique
 import UniqFM
@@ -161,6 +162,40 @@ vectDataCon dc
     rep_arg_tys = dataConRepArgTys dc
     tycon       = dataConTyCon dc
 
+{-
+mkPArrTyCon :: TyCon -> VM TyCon
+mkPArrTyCon tc = fixV $ \repr_tc ->
+  do
+-}
+
+mkPArrayDataCon :: TyCon -> TyCon -> VM DataCon
+mkPArrayDataCon orig_tc repr_tc
+  = do
+      name     <- cloneName mkPArrayDataConOcc (tyConName orig_tc)
+      shape_ty <- mkPArrayType intTy   -- FIXME: we want to unbox this!
+      repr_tys <- mapM mkPArrayType types
+      wrk_name <- cloneName mkDataConWorkerOcc name
+      wrp_name <- cloneName mkDataConWrapperOcc name
+
+      let ids      = mkDataConIds wrp_name wrk_name data_con
+          data_con = mkDataCon name
+                               False
+                               (MarkedStrict : map (const NotMarkedStrict) repr_tys)
+                               []
+                               (tyConTyVars orig_tc)
+                               []
+                               []
+                               []
+                               repr_tys
+                               repr_tc
+                               []
+                               ids
+
+      return data_con
+  where
+    types = [ty | dc <- tyConDataCons orig_tc
+                , ty <- dataConRepArgTys dc]
+
 -- | Split the given tycons into two sets depending on whether they have to be
 -- converted (first list) or not (second list). The first argument contains
 -- information about the conversion status of external tycons: