[utilize the CTYPE pragma for most built in types, clean up src/data/names.txt
John Meacham <john@repetae.net>**20120311055029
 Ignore-this: 3965b08298708f2a1bf42ae09df3b321
] hunk ./lib/jhc-prim/Jhc/Prim/Bits.hs 8
+-- The CTYPE of the raw types is declared in src/DataConstructors.hs
hunk ./lib/jhc-prim/Jhc/Prim/Bits.hs 31
-newtype Addr_    = Addr_ BitsPtr_
-newtype FunAddr_ = FunAddr_ BitsPtr_
-newtype Bool_    = Bool_ Bits16_
-newtype Char_    = Char_ Bits32_
+newtype {-# CTYPE "HsPtr" #-}    Addr_    = Addr_ BitsPtr_
+newtype {-# CTYPE "HsFunPtr" #-} FunAddr_ = FunAddr_ BitsPtr_
+newtype {-# CTYPE "bool" #-}     Bool_    = Bool_ Bits16_
+newtype {-# CTYPE "wchar_t" #-}  Char_    = Char_ Bits32_
hunk ./lib/jhc-prim/Jhc/Prim/Prim.hs 14
-data Bool = False | True
+data {-# CTYPE "HsBool" #-} Bool = False | True
hunk ./lib/jhc-prim/Jhc/Prim/Rts.hs 8
-data Bang_ a :: #
+data {-# CTYPE "wptr_t" #-} Bang_ a :: #
hunk ./lib/jhc-prim/Jhc/Prim/Words.hs 1
-module Jhc.Prim.Words where
-
-import Jhc.Prim.Bits
-
--- define the lifted form of the basic
--- numeric types.
-
-data Word = Word Bits32_
-data Word8 = Word8 Bits8_
-data Word16 = Word16 Bits16_
-data Word32 = Word32 Bits32_
-data Word64 = Word64 Bits64_
-data Word128 = Word128 Bits128_
-data WordPtr = WordPtr BitsPtr_
-data WordMax = WordMax BitsMax_
-
-data Int = Int Bits32_
-data Int8 = Int8 Bits8_
-data Int16 = Int16 Bits16_
-data Int32 = Int32 Bits32_
-data Int64 = Int64 Bits64_
-data Int128 = Int128 Bits128_
-data IntPtr = IntPtr BitsPtr_
-data IntMax = IntMax BitsMax_
rmfile ./lib/jhc-prim/Jhc/Prim/Words.hs
hunk ./lib/jhc/Jhc/Type/C.hs 11
-newtype CChar    = CChar Int8
-newtype CSChar   = CSChar Int8
-newtype CUChar   = CUChar Word8
-newtype CShort   = CShort Int16
-newtype CUShort  = CUShort Word16
-newtype CInt     = CInt Int
-newtype CUInt    = CUInt Word
-newtype CLong    = CLong IntPtr
-newtype CULong   = CULong WordPtr
-newtype CLLong   = CLLong IntMax
-newtype CULLong  = CULLong WordMax
+newtype {-# CTYPE "char" #-}           CChar    = CChar Int8
+newtype {-# CTYPE "signed char" #-}    CSChar   = CSChar Int8
+newtype {-# CTYPE "unsigned char" #-}  CUChar   = CUChar Word8
+newtype {-# CTYPE "short" #-}          CShort   = CShort Int16
+newtype {-# CTYPE "unsigned short" #-} CUShort  = CUShort Word16
+newtype {-# CTYPE "int" #-}            CInt     = CInt Int
+newtype {-# CTYPE "unsigned" #-}       CUInt    = CUInt Word
+newtype {-# CTYPE "long" #-}           CLong    = CLong IntPtr
+newtype {-# CTYPE "unsigned long" #-}  CULong   = CULong WordPtr
+newtype {-# CTYPE "long long" #-}      CLLong   = CLLong IntMax
+newtype {-# CTYPE "unsigned long long" #-} CULLong  = CULLong WordMax
hunk ./lib/jhc/Jhc/Type/C.hs 30
-newtype CLDouble = CLDouble Double
+newtype {-# CTYPE "long double" #-} CLDouble = CLDouble Double
hunk ./lib/jhc/Jhc/Type/C.hs 32
-newtype CWchar   = CWchar Word32
-newtype CWint    = CWint Int32
-newtype CClock   = CClock IntMax
-newtype CPtrdiff = CPtrdiff IntPtr
-newtype CSize    = CSize WordPtr
-newtype CTime    = CTime IntMax
+newtype {-# CTYPE "wchar_t" #-}   CWchar   = CWchar Word32
+newtype {-# CTYPE "wint_t" #-}    CWint    = CWint Int32
+newtype {-# CTYPE "clock_t" #-}   CClock   = CClock IntMax
+newtype {-# CTYPE "ptrdiff_t" #-} CPtrdiff = CPtrdiff IntPtr
+newtype {-# CTYPE "size_t" #-}    CSize    = CSize WordPtr
+newtype {-# CTYPE "time_t" #-}    CTime    = CTime IntMax
hunk ./lib/jhc/Jhc/Type/C.hs 39
-data CFile
-data CJmpBuf
-data CFpos
-data CSigAtomic
+data {-# CTYPE "FILE" #-}        CFile
+data {-# CTYPE "jmp_buf" #-}     CJmpBuf
+data {-# CTYPE "fpos_t" #-}      CFpos
+data {-# CTYPE "sigatomic_t" #-} CSigAtomic
hunk ./lib/jhc/Jhc/Type/Float.hs 5
-data Float = Float Float32_
-data Double = Double Float64_
+data {-# CTYPE "float" #-} Float = Float Float32_
+data {-# CTYPE "double" #-} Double = Double Float64_
hunk ./lib/jhc/Jhc/Type/Ptr.hs 5
-data Ptr a = Ptr Addr_
-data FunPtr a = FunPtr FunAddr_
+data {-# CTYPE "HsPtr" #-} Ptr a = Ptr Addr_
+data {-# CTYPE "FunPtr" #-} FunPtr a = FunPtr FunAddr_
hunk ./lib/jhc/Jhc/Type/Word.hs 8
-data Word = Word Bits32_
-data Word8 = Word8 Bits8_
-data Word16 = Word16 Bits16_
-data Word32 = Word32 Bits32_
-data Word64 = Word64 Bits64_
-data Word128 = Word128 Bits128_
-data WordPtr = WordPtr BitsPtr_
-data WordMax = WordMax BitsMax_
+data {-# CTYPE "unsigned"  #-} Word = Word Bits32_
+data {-# CTYPE "uint8_t"   #-} Word8 = Word8 Bits8_
+data {-# CTYPE "uint16_t"  #-} Word16 = Word16 Bits16_
+data {-# CTYPE "uint32_t"  #-} Word32 = Word32 Bits32_
+data {-# CTYPE "uint64_t"  #-} Word64 = Word64 Bits64_
+data {-# CTYPE "uint128_t" #-} Word128 = Word128 Bits128_
+data {-# CTYPE "uintptr_t" #-} WordPtr = WordPtr BitsPtr_
+data {-# CTYPE "uintmax_t" #-} WordMax = WordMax BitsMax_
hunk ./lib/jhc/Jhc/Type/Word.hs 17
-data Int = Int Bits32_
-data Int8 = Int8 Bits8_
-data Int16 = Int16 Bits16_
-data Int32 = Int32 Bits32_
-data Int64 = Int64 Bits64_
-data Int128 = Int128 Bits128_
-data IntPtr = IntPtr BitsPtr_
-data IntMax = IntMax BitsMax_
+data {-# CTYPE "int"      #-} Int = Int Bits32_
+data {-# CTYPE "int8_t"   #-} Int8 = Int8 Bits8_
+data {-# CTYPE "int16_t"  #-} Int16 = Int16 Bits16_
+data {-# CTYPE "int32_t"  #-} Int32 = Int32 Bits32_
+data {-# CTYPE "int64_t"  #-} Int64 = Int64 Bits64_
+data {-# CTYPE "int128_t" #-} Int128 = Int128 Bits128_
+data {-# CTYPE "intptr_t" #-} IntPtr = IntPtr BitsPtr_
+data {-# CTYPE "intmax_t" #-} IntMax = IntMax BitsMax_
hunk ./src/DataConstructors.hs 415
-    f seen e@(ELit LitCons { litName = c }) | Just et <- Map.lookup c typeTable = do
-        res <- g seen e
-        return $ case res of
-            ExtTypeRaw _ -> ExtTypeRaw et
-            ExtTypeBoxed b t _ -> ExtTypeBoxed b t et
-            ExtTypeVoid -> ExtTypeVoid
hunk ./src/DataConstructors.hs 416
-        res <- g seen e
-        return $ case res of
-            ExtTypeRaw _ -> ExtTypeRaw et
-            ExtTypeBoxed b t _ -> ExtTypeBoxed b t et
-            ExtTypeVoid -> ExtTypeVoid
+        return $ case g seen e of
+            Just (ExtTypeBoxed b t _) -> ExtTypeBoxed b t et
+            Just ExtTypeVoid -> ExtTypeVoid
+            _ -> ExtTypeRaw et
hunk ./src/DataConstructors.hs 919
-    (rt_float128,  "__float128"),
-    (tc_CFile,      "FILE"),
-    (tc_CJmpBuf,    "jmp_buf"),
-    (tc_CFpos,      "fpos_t"),
-    (tc_CSigAtomic, "sigatomic_t"),
-    (tc_Bang_,     "wptr_t")
-    ]
-
--- which C types these convert to in FFI specifications for
--- figuring out calling conventions. not necessarily related
--- to the representation.
---
--- ideally, these could be set via a pragma
-
-typeTable :: Map.Map Name ExtType
-typeTable = Map.fromList [
-    (tc_Int,      "int"),
-    (tc_Int8,     "int8_t"),
-    (tc_Int16,    "int16_t"),
-    (tc_Int32,    "int32_t"),
-    (tc_Int64,    "int64_t"),
-    (tc_IntMax,   "intmax_t"),
-    (tc_IntPtr,   "intptr_t"),
-    (tc_Word,     "unsigned"),
-    (tc_Word8,    "uint8_t"),
-    (tc_Word16,   "uint16_t"),
-    (tc_Word32,   "uint32_t"),
-    (tc_Word64,   "uint64_t"),
-    (tc_WordMax,  "uintmax_t"),
-    (tc_WordPtr,  "uintptr_t"),
-    (tc_Float,    "float"),
-    (tc_Double,   "double"),
-    (tc_Ptr,      "HsPtr"),
-    (tc_FunPtr,   "HsFunPtr"),
-
-    (tc_Addr_,    "HsPtr"),
-    (tc_FunAddr_, "HsFunPtr"),
-    (tc_Char_,    "wchar_t"),
-    (tc_Bool_,    "bool"),
-    (tc_Bool,     "HsBool"),
-
-    (tc_CChar,    "char"),
-    (tc_CShort,   "short"),
-    (tc_CInt,     "int"),
-    (tc_CLong,    "long"),
-    (tc_CLLong,   "long long"),
-
-    (tc_CSChar,   "signed char"),
-    (tc_CUChar,   "unsigned char"),
-    (tc_CUShort,  "unsigned short"),
-    (tc_CUInt,    "unsigned int"),
-    (tc_CULong,   "unsigned long"),
-    (tc_CULLong,  "unsigned long long"),
-
-    (tc_CWchar,     "wchar_t"),
-    (tc_CWint,      "wint_t"),
-    (tc_CTime,      "time_t"),
-    (tc_CClock,     "clock_t"),
-    (tc_CSize,      "size_t"),
-    (tc_Unit,       "void"),
-    (tc_State_,     "void"),
-    (tc_Bang_,      "wptr_t")  -- internal rts type
+    (rt_float128,  "__float128")
hunk ./src/E/Show.hs 82
-        f LitCons { litName = ((tc_Addr_ ==) -> True), litType = ((eHash ==) -> True) } = return $ atom $ text "Addr_"
-        f LitCons { litName = ((tc_FunAddr_ ==) -> True), litType = ((eHash ==) -> True) } = return $ atom $ text "FunAddr_"
-        f LitCons { litName = ((tc_Char_ ==) -> True), litType = ((eHash ==) -> True) } = return $ atom $ text "Char_"
+--        f LitCons { litName = n, litArgs = [] } | Just m <- getModule n, m `elem`[toModule "Jhc.Prim.Bits", toModule "Jhc.Prim.Word"]  = return $ atom $ text "[]"
+--        f LitCons { litName = ((tc_Addr_ ==) -> True), litType = ((eHash ==) -> True) } = return $ atom $ text "Addr_"
+--        f LitCons { litName = ((tc_FunAddr_ ==) -> True), litType = ((eHash ==) -> True) } = return $ atom $ text "FunAddr_"
+--        f LitCons { litName = ((tc_Char_ ==) -> True), litType = ((eHash ==) -> True) } = return $ atom $ text "Char_"
hunk ./src/E/Show.hs 96
-	    s <- return $ fromMaybe s (Map.lookup s shortName)
+	    s <- return $ fromMaybe s (shortenName s)
hunk ./src/E/Show.hs 101
-	    s <- return $ fromMaybe s (Map.lookup s shortName)
+	    s <- return $ fromMaybe s (shortenName s)
hunk ./src/E/Show.hs 105
+	shortenName n = Map.lookup n shortName `mplus` (getModule n >>= mm) where
+	    mm m = if m `elem` shortMods then return (toUnqualified n) else Nothing
+            shortMods = map toModule [ "Jhc.Prim.IO", "Jhc.Prim.Bits", "Jhc.Type.Word", "Jhc.Type.C" ]
hunk ./src/E/Show.hs 155
-      tc_Bool,     tc_Char,    tc_IO,      tc_ACIO,    tc_State_,  tc_RealWorld,
-      tc_Ordering, tc_Bool_,   tc_Ratio,   tc_Float,   tc_Double,  tc_Ptr,
-      tc_FunPtr,   tc_CInt,    tc_CUInt,   tc_CLong,   tc_CULong,  tc_CLLong,
-      tc_CULLong,  tc_CShort,  tc_CUShort, tc_CWchar,  tc_CWint,   tc_CChar,
-      tc_CSChar,   tc_CUChar,  tc_CInt,    tc_CUInt,   tc_CTime,   tc_CSize,
-      tc_CClock,   tc_Integer, tc_Int,     tc_Int8,    tc_Int16,   tc_Int32,
-      tc_Int64,    tc_IntMax,  tc_IntPtr,  tc_Word,    tc_Word8,   tc_Word16,
-      tc_Word32,   tc_Word64,  tc_WordMax, tc_WordPtr, tc_Addr_,   tc_FunAddr_,
-      tc_Char_,    dc_Boolzh,  dc_Char,    dc_Int,     dc_Integer, dc_Word,
-      tc_ST,       tc_Bang_]
+      tc_Bool,      tc_Char,     tc_IO,      tc_ACIO,    tc_State_,
+      tc_RealWorld, tc_Ordering, tc_Bool_,   tc_Ratio,   tc_Float,
+      tc_Double,    tc_Ptr,      tc_FunPtr,  tc_Integer, tc_Addr_,
+      tc_FunAddr_,  tc_Char_,    dc_Boolzh,  dc_Char,    dc_Integer,
+      tc_ST,        tc_Bang_]
hunk ./src/FrontEnd/HsParser.y 310
-      : 'data' ctype srcloc deriving
-          {% checkDataHeader $2 `thenP` \(cs,c,t) ->
-             returnP hsDataDecl { hsDeclSrcLoc = $3, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclDerives = $4 } }
-      | 'data' ctype '::' kind srcloc deriving
-          {% checkDataHeader $2 `thenP` \(cs,c,t) ->
-             returnP hsDataDecl { hsDeclSrcLoc = $5, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclDerives = $6, hsDeclHasKind = Just $4 } }
+      : 'data' mCTYPE ctype srcloc deriving
+          {% checkDataHeader $3 `thenP` \(cs,c,t) ->
+             returnP hsDataDecl { hsDeclSrcLoc = $4, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclDerives = $5, hsDeclCTYPE = $2 } }
+      | 'data' mCTYPE ctype '::' kind srcloc deriving
+          {% checkDataHeader $3 `thenP` \(cs,c,t) ->
+             returnP hsDataDecl { hsDeclSrcLoc = $6, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclDerives = $7, hsDeclHasKind = Just $5, hsDeclCTYPE = $2 } }
hunk ./src/FrontEnd/HsParser.y 320
-      | 'data' ctype srcloc '=' constrs deriving
-                      {% checkDataHeader $2 `thenP` \(cs,c,t) ->
-                         returnP hsDataDecl { hsDeclSrcLoc = $3, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclDerives = $6, hsDeclCons = reverse $5 } }
hunk ./src/FrontEnd/HsParser.y 323
+      | 'data' mCTYPE ctype srcloc '=' constrs deriving
+                      {% checkDataHeader $3 `thenP` \(cs,c,t) ->
+                         returnP hsDataDecl { hsDeclSrcLoc = $4, hsDeclContext = cs, hsDeclName = c, hsDeclArgs = t, hsDeclDerives = $7, hsDeclCons = reverse $6, hsDeclCTYPE = $2 } }
hunk ./src/data/names.txt 28
-# Jhc.Type.C
-CLong      Jhc.Type.C.CLong
-CULong     Jhc.Type.C.CULong
-CLLong     Jhc.Type.C.CLLong
-CULLong    Jhc.Type.C.CULLong
-CShort     Jhc.Type.C.CShort
-CUShort    Jhc.Type.C.CUShort
-CWchar     Jhc.Type.C.CWchar
-CWint      Jhc.Type.C.CWint
-CChar      Jhc.Type.C.CChar
-CSChar     Jhc.Type.C.CSChar
-CUChar     Jhc.Type.C.CUChar
-
-CInt       Jhc.Type.C.CInt
-CUInt      Jhc.Type.C.CUInt
-CTime      Jhc.Type.C.CTime
-CSize      Jhc.Type.C.CSize
-CClock     Jhc.Type.C.CClock
-CFile      Jhc.Type.C.CFile
-CJmpBuf    Jhc.Type.C.CJmpBuf
-CFpos      Jhc.Type.C.CFpos
-CSigAtomic Jhc.Type.C.CSigAtomic
-
hunk ./src/data/names.txt 31
-Int8      Jhc.Type.Word.Int8
-Int16     Jhc.Type.Word.Int16
-Int32     Jhc.Type.Word.Int32
-Int64     Jhc.Type.Word.Int64
-IntMax    Jhc.Type.Word.IntMax
-IntPtr    Jhc.Type.Word.IntPtr
-
-Word       Jhc.Type.Word.Word
-Word8      Jhc.Type.Word.Word8
-Word16     Jhc.Type.Word.Word16
-Word32     Jhc.Type.Word.Word32
-Word64     Jhc.Type.Word.Word64
-WordMax    Jhc.Type.Word.WordMax
-WordPtr    Jhc.Type.Word.WordPtr