[for known platform independent types, fill in the maxBound,minBound and sizeOf values directly, rather than defering it to code generation time
John Meacham <john@repetae.net>**20061221035121] hunk ./C/Arch.hs 2
-module C.Arch(determineArch,primitiveInfo) where
+module C.Arch(determineArch,primitiveInfo,genericPrimitiveInfo) where
hunk ./C/Arch.hs 60
+genericPrimitiveInfo :: Monad m => ExtType -> m PrimType
+genericPrimitiveInfo et = Map.lookup et primMap
hunk ./arch/generic.arch 8
+  PrimType {
+    primTypeName = "HsChar",
+    primTypeIsSigned = True,
+    primTypeType = PrimTypeIntegral,
+    primTypeAlignmentOf = 4,
+    primTypeSizeOf = 4 },
hunk ./data/PrimitiveOperators-in.hs 9
+import C.Arch
hunk ./data/PrimitiveOperators-in.hs 170
+prim_minbound, prim_maxbound :: Name -> E -> ExtType -> E -> E
+prim_minbound dc dt s e = f s where
+    f "HsChar" = boxup $ ELit $ LitInt 0 (rawType "HsChar")
+    f s | Just pt <- genericPrimitiveInfo s = boxup $ case primTypeIsSigned pt of
+        False -> ELit $ LitInt 0 (rawType s)
+        True -> ELit $ LitInt (negate $ 2 ^ (8 * primTypeSizeOf pt - 1)) (rawType s)
+    f _ = e
+    boxup a =  ELit litCons { litName = dc, litArgs = [a], litType = dt }
+prim_maxbound dc dt s e = f s where
+    f "HsChar" = boxup $ ELit $ LitInt 0x10ffff (rawType "HsChar")
+    f s | Just pt <- genericPrimitiveInfo s = boxup $ case primTypeIsSigned pt of
+        False -> ELit $ LitInt (2 ^ (8 * primTypeSizeOf pt)) (rawType s)
+        True -> ELit $ LitInt (2 ^ (8 * primTypeSizeOf pt - 1) - 1) (rawType s)
+    f _ = e
+    boxup a =  ELit litCons { litName = dc, litArgs = [a], litType = dt }
+    {-
+prim_maxbound "HsChar" e = ELit $ LitInt 0x10ffff (rawType "HsChar")
+prim_maxbound s e | Just pt <- genericPrimitiveInfo s = case primTypeIsSigned pt of
+    False -> ELit $ LitInt (2 ^ (8 * primTypeSizeOf pt)) (rawType s)
+    True -> ELit $ LitInt (2 ^ (8 * primTypeSizeOf pt - 1) - 1) (rawType s)
+prim_maxbound s e = e
+-}
+
+prim_bitsize s | Just pt <- genericPrimitiveInfo s = let
+    rp = ELit $ LitInt (fromIntegral (primTypeSizeOf pt) * 8) tIntzh
+    in (ELit (litCons { litName = dc_Int, litArgs = [rp], litType = tInt }))
+prim_bitsize s = (ELit (litCons { litName = dc_Int, litArgs = [rp'], litType = tInt })) where
+    rp = EPrim (APrim (PrimTypeInfo { primArgType = s, primRetType = "int", primTypeInfo = PrimSizeOf }) mempty) [] tIntzh
+    rp' = EPrim (APrim (Operator "*" ["int","int"] "int") mempty) [rp,(ELit (LitInt 8 tIntzh))] tIntzh
+
+
+prim_sizeof s | Just pt <- genericPrimitiveInfo s = let
+    rp = ELit $ LitInt (fromIntegral (primTypeSizeOf pt)) tIntzh
+    in (ELit (litCons { litName = dc_Int, litArgs = [rp], litType = tInt }))
hunk ./data/PrimitiveOperators-in.hs 205
-    rp = (EPrim (APrim (PrimTypeInfo { primArgType = s, primRetType = "int", primTypeInfo = PrimSizeOf }) mempty) [] tIntzh)
+    rp = EPrim (APrim (PrimTypeInfo { primArgType = s, primRetType = "int", primTypeInfo = PrimSizeOf }) mempty) [] tIntzh
+
hunk ./data/primitives.txt 35
-Foreign.C.Types.CWchar, wchar_t, int, 0x10FFF, 0
-Foreign.C.Types.CWint, wint_t, int, 0x10FFF, 0
+Foreign.C.Types.CWchar, wchar_t, int, 0x10FFFF, 0
+Foreign.C.Types.CWint, wint_t, int, 0x10FFFF, 0
hunk ./utils/op_process.prl 136
-    push @cmeth, "($prelude_bounded, toInstName \"Jhc.Enum.maxBound.$d->[0]\", " . const($cncons, $d->[3],$t,"$d->[1]") . ")";
-    push @cmeth, "($prelude_bounded, toInstName \"Jhc.Enum.minBound.$d->[0]\", " . const($cncons,$d->[4],$t,"$d->[1]") . ")";
+    push @cmeth, "($prelude_bounded, toInstName \"Jhc.Enum.maxBound.$d->[0]\", " . "prim_maxbound $cncons $t \"$d->[1]\" (" . const($cncons, $d->[3],$t,"$d->[1]") . "))";
+    push @cmeth, "($prelude_bounded, toInstName \"Jhc.Enum.minBound.$d->[0]\", " . "prim_minbound $cncons $t \"$d->[1]\" (" . const($cncons,$d->[4],$t,"$d->[1]") . "))";