[project @ 2000-11-13 17:08:36 by sewardj]
[ghc-hetmet.git] / ghc / compiler / prelude / PrimRep.lhs
index 6c479d1..2769a58 100644 (file)
@@ -25,8 +25,7 @@ module PrimRep
 
 #include "HsVersions.h"
 
-import Constants ( dOUBLE_SIZE, iNT64_SIZE, wORD64_SIZE )
-import Util
+import Constants ( dOUBLE_SIZE, iNT64_SIZE, wORD64_SIZE, wORD_SIZE )
 import Outputable
 \end{code}
 
@@ -79,6 +78,11 @@ data PrimRep
   | ArrayRep           -- Primitive array of Haskell pointers
   | ByteArrayRep       -- Primitive array of bytes (no Haskell pointers)
 
+  | PrimPtrRep         -- Used for MutVars and MVars; 
+                       -- a pointer to a primitive object
+                       -- ToDo: subsumes WeakPtrRep, ThreadIdRep, 
+                       -- StableNameRep, ForeignObjRep, and BCORep ?
+
   | VoidRep            -- Occupies no space at all!
                        -- (Primitive states are mapped onto this)
   deriving (Eq, Ord)
@@ -118,6 +122,7 @@ isFollowableRep ByteArrayRep  = True        --      ''
 isFollowableRep WeakPtrRep    = True   --      ''
 isFollowableRep ForeignObjRep = True   --      ''
 isFollowableRep StableNameRep = True    --      ''
+isFollowableRep PrimPtrRep    = True    --      ''
 isFollowableRep ThreadIdRep   = True   -- pointer to a TSO
 
 isFollowableRep other        = False
@@ -175,7 +180,7 @@ getPrimRepSize other          = 1
 
 retPrimRepSize = getPrimRepSize RetRep
 
--- size in bytes, ToDo: cpp in the right vals.
+-- sizes in bytes.
 -- (used in some settings to figure out how many bytes
 -- we have to push onto the stack when calling external
 -- entry points (e.g., stdcalling on win32)
@@ -184,19 +189,19 @@ getPrimRepSizeInBytes pr =
  case pr of
     CharRep        ->    4
     Int8Rep        ->    1
-    IntRep         ->    4
-    AddrRep        ->    4
-    FloatRep       ->    4
-    DoubleRep      ->    8
-    Word64Rep      ->    8
-    Int64Rep       ->    8
-    WeakPtrRep     ->    4
-    ForeignObjRep  ->    4
-    StablePtrRep   ->    4
-    StableNameRep  ->    4
-    ArrayRep       ->    4
-    ByteArrayRep   ->    4
-    _             ->   panic "getPrimRepSize: ouch - this wasn't supposed to happen!"
+    IntRep         ->    wORD_SIZE
+    AddrRep        ->    wORD_SIZE
+    FloatRep       ->    wORD_SIZE
+    DoubleRep      ->    dOUBLE_SIZE * wORD_SIZE
+    Word64Rep      ->    wORD64_SIZE * wORD_SIZE
+    Int64Rep       ->    iNT64_SIZE * wORD_SIZE
+    WeakPtrRep     ->    wORD_SIZE
+    ForeignObjRep  ->    wORD_SIZE
+    StablePtrRep   ->    wORD_SIZE
+    StableNameRep  ->    wORD_SIZE
+    ArrayRep       ->    wORD_SIZE
+    ByteArrayRep   ->    wORD_SIZE
+    _             ->    panic "getPrimRepSize: ouch - this wasn't supposed to happen!"
 
 \end{code}
 
@@ -228,6 +233,7 @@ showPrimRep AddrRep    = "StgAddr"
 showPrimRep FloatRep      = "StgFloat"
 showPrimRep DoubleRep     = "StgDouble"
 showPrimRep ArrayRep      = "P_" -- see comment below
+showPrimRep PrimPtrRep    = "P_"
 showPrimRep ByteArrayRep   = "StgByteArray"
 showPrimRep StablePtrRep   = "StgStablePtr"
 showPrimRep StableNameRep  = "P_"
@@ -235,6 +241,7 @@ showPrimRep ThreadIdRep        = "StgTSO*"
 showPrimRep WeakPtrRep     = "P_"
 showPrimRep ForeignObjRep  = "StgAddr"
 showPrimRep VoidRep       = "!!VOID_KIND!!"
+showPrimRep BCORep         = "P_"      -- not sure -- JRS 000708
 
 primRepString CharRep          = "Char"
 primRepString Int8Rep          = "Char" -- To have names like newCharArray#