[when storing values inside of smart pointers, be sure to use the proper signedness when extracting/inserting values
John Meacham <john@repetae.net>**20100319021048
 Ignore-this: 709af4301eed95813a0a9d57a7dda13e
] hunk ./src/C/FromGrin2.hs 63
-    rCPR  :: Set.Set Atom,
+    rCPR  :: Map.Map Atom Bool,
hunk ./src/C/FromGrin2.hs 85
-    cpr = iw `Set.union` Set.insert cChar (Set.fromList [ a | (a,TyTy { tySlots = [s], tySiblings = Just [a'] }) <- Map.assocs tmap, a == a', isJust (good s) ])
-    iw = if fopts FO.FullInt then Set.empty else Set.fromList [cInt, cWord]
+    cpr = iw `Map.union` Map.insert cChar False (Map.fromList [ (a,False) | (a,TyTy { tySlots = [s], tySiblings = Just [a'] }) <- Map.assocs tmap, a == a', isJust (good s) ])
+    iw = if fopts FO.FullInt then mempty else Map.fromList [(cInt,True), (cWord,False)]
hunk ./src/C/FromGrin2.hs 132
-        let ef =  drawG $ f_EVALFUNC (reference $ variable en)
+        let ef =  drawG $ f_TO_FPTR (reference $ variable en)
hunk ./src/C/FromGrin2.hs 135
-                text "#define " <> tshow (varName v) <+>  text "(EVALTAGC(&_" <> tshow (varName v) <> text "))\n";
+                text "#define " <> tshow (varName v) <+>  text "(MKLAZY_C(&_" <> tshow (varName v) <> text "))\n";
hunk ./src/C/FromGrin2.hs 341
-        tag = f_GETWHAT scrut
-        ifscrut = if null fps then f_RAWWHAT tenum `eq` scrut else tenum `eq` tag where
+        tag = f_FETCH_TAG scrut
+        ifscrut = if null fps then f_SET_RAW_TAG tenum `eq` scrut else tenum `eq` tag where
hunk ./src/C/FromGrin2.hs 360
-    let tag = f_GETWHAT scrut
+    let tag = f_FETCH_TAG scrut
hunk ./src/C/FromGrin2.hs 514
-        if t `Set.notMember` cpr then na else do
hunk ./src/C/FromGrin2.hs 515
-        [arg] <- return as
-        t <- convertType $ getType arg
-        arg' <- iDeclare $ convertVal arg
-        let s = arg' =* cast t (f_GETVALUE v')
-        ss <- convertBody e'
-        return $ s & ss
-    na = do
-        declareStruct t
-        v' <- convertVal v
-        as' <- iDeclare $ mapM convertVal as
-        let ass = concat [perhapsM (a `Set.member` fve) $ a' =* (project' (arg i) (concrete t v')) | a' <- as' | Var a _ <- as |  i <- [( 1 :: Int) ..] ]
-            fve = freeVars e'
-        ss' <- convertBody e'
-        return $ mconcat ass & ss'
+        case Map.lookup t cpr of
+            Just signed -> do
+                [arg] <- return as
+                t <- convertType $ getType arg
+                arg' <- iDeclare $ convertVal arg
+                let s = arg' =* cast t (if signed then f_RAW_GET_F v' else f_RAW_GET_UF v')
+                ss <- convertBody e'
+                return $ s & ss
+            Nothing -> do
+                declareStruct t
+                as' <- iDeclare $ mapM convertVal as
+                let ass = concat [perhapsM (a `Set.member` fve) $ a' =* (project' (arg i) (concrete t v')) | a' <- as' | Var a _ <- as |  i <- [( 1 :: Int) ..] ]
+                    fve = freeVars e'
+                ss' <- convertBody e'
+                return $ mconcat ass & ss'
hunk ./src/C/FromGrin2.hs 567
-    let tmp' = cast nt (f_FROM_SPTR v') -- (if vv < v0 then f_DETAG v' else v')
+    let tmp' = cast nt (f_FROM_SPTR v')
hunk ./src/C/FromGrin2.hs 575
---convertExp (Update v@(Var vv _) tn@(NodeC t as)) | getType v == TyINode = do
---    v' <- convertVal v
---    as' <- mapM convertVal as
---    nt <- nodeTypePtr t
---    let tmp' = cast nt (f_DETAG v') -- (if vv < v0 then f_DETAG v' else v')
---    if not (tagIsSuspFunction t) && vv < v0 then do
---        (nns, nn) <- newNode fptr_t tn
---        return (nns & getHead (f_NODEP(f_DETAG v')) =* nn,emptyExpression)
---     else do
---        s <- tagAssign tmp' t
---        let ass = [project' (arg i) tmp' =* a | a <- as' | i <- [(1 :: Int) ..] ]
---        return (mconcat $ profile_update_inc:s:ass,emptyExpression)
hunk ./src/C/FromGrin2.hs 593
-     text "#define " <> tshow (varName v) <+>  text "(EVALTAGC(&_" <> tshow (varName v) <> text "))\n";
+     text "#define " <> tshow (varName v) <+>  text "(MKLAZY_C(&_" <> tshow (varName v) <> text "))\n";
hunk ./src/C/FromGrin2.hs 726
-    return $ getHead e =* f_EVALFUNC (reference (variable en))
+    return $ getHead e =* f_TO_FPTR (reference (variable en))
hunk ./src/C/FromGrin2.hs 734
-        _ -> do return . toStatement $ f_SETWHAT e (constant (enum $ nodeTagName t))
+        _ -> do return . toStatement $ f_SET_MEM_TAG e (constant (enum $ nodeTagName t))
hunk ./src/C/FromGrin2.hs 777
-        let res = if sf then (f_EVALTAG tmp) else tmp
+        let res = if sf then (f_MKLAZY tmp) else tmp
hunk ./src/C/FromGrin2.hs 807
-basicNode a []  = do tellTags a ; return . Just $ (f_RAWWHAT (constant $ enum (nodeTagName a)))
+basicNode a []  = do tellTags a ; return . Just $ (f_SET_RAW_TAG (constant $ enum (nodeTagName a)))
hunk ./src/C/FromGrin2.hs 810
-    if a `Set.notMember` cpr then return Nothing else
-        case v of
-            Lit i ty | a == cChar, Just c <- ch -> return $ Just (f_VALUE (toExpression c)) where
+    case Map.lookup a cpr of
+        Nothing -> return Nothing
+        Just signed -> case v of
+            Lit i ty | a == cChar, Just c <- ch -> return $ Just (f_RAW_SET_UF (toExpression c)) where
hunk ./src/C/FromGrin2.hs 822
-                return $ Just (f_VALUE v)
+                return $ Just (if signed then f_RAW_SET_F v else f_RAW_SET_UF v)
hunk ./src/C/FromGrin2.hs 875
-f_VALUE e     = functionCall (name "VALUE") [e]
-f_GETVALUE e  = functionCall (name "GETVALUE") [e]
-f_EVALTAG e   = functionCall (name "EVALTAG") [e]
-f_EVALFUNC e  = functionCall (name "EVALFUNC") [e]
+f_RAW_SET_F e  = functionCall (name "RAW_SET_F") [e]
+f_RAW_SET_UF e = functionCall (name "RAW_SET_UF") [e]
+f_RAW_GET_F e  = functionCall (name "RAW_GET_F") [e]
+f_RAW_GET_UF e = functionCall (name "RAW_GET_UF") [e]
+f_MKLAZY e     = functionCall (name "MKLAZY") [e]
+f_TO_FPTR e    = functionCall (name "TO_FPTR") [e]
hunk ./src/C/FromGrin2.hs 884
-f_GETWHAT e   = functionCall (name "GETWHAT") [e]
-f_SETWHAT e v = functionCall (name "SETWHAT") [e,v]
-f_RAWWHAT e   = functionCall (name "RAWWHAT") [e]
+f_FETCH_TAG e = functionCall (name "FETCH_TAG") [e]
+f_SET_RAW_TAG e   = functionCall (name "SET_RAW_TAG") [e]
+f_SET_MEM_TAG e v = functionCall (name "SET_MEM_TAG") [e,v]
hunk ./src/Grin/HashConst.hs 21
-newConst :: MonadState HcHash m => Set.Set Atom -> Val -> m (Bool,Int)
+newConst :: MonadState HcHash m => Map.Map Atom a -> Val -> m (Bool,Int)
hunk ./src/Grin/HashConst.hs 31
-            g n@(Const (NodeC a _)) | a `Set.member` cpr = return $ Left n
-            g n@(NodeC a _) | a `Set.member` cpr  = return $ Left n
+            g n@(Const (NodeC a _)) | a `Map.member` cpr = return $ Left n
+            g n@(NodeC a _) | a `Map.member` cpr  = return $ Left n
hunk ./src/data/rts/jhc_rts2.c 114
-#define IS_LAZY(x)     (((uintptr_t)(x)) & 0x1)
-#define IS_PTR(x)      (!(((uintptr_t)(x)) & 0x2))
+#define IS_LAZY(x)     (bool)(((uintptr_t)(x)) & 0x1)
+#define IS_PTR(x)      (bool)(!(((uintptr_t)(x)) & 0x2))
hunk ./src/data/rts/jhc_rts2.c 126
-#define EVALTAG(fn)  TO_SPTR(P_LAZY,(sptr_t)fn)
-#define EVALTAGC(fn) TO_SPTR_C(P_LAZY,(sptr_t)fn)
-#define EVALFUNC(fn) TO_SPTR_C(P_FUNC,(fptr_t)fn)
+#define MKLAZY(fn)    TO_SPTR(P_LAZY,(sptr_t)fn)
+#define MKLAZY_C(fn)  TO_SPTR_C(P_LAZY,(sptr_t)fn)
+#define TO_FPTR(fn)   TO_SPTR_C(P_FUNC,(fptr_t)fn)
hunk ./src/data/rts/jhc_rts2.c 130
-// #define EVALTAG(fn)  (assert(GET_PTYPE(fn) == 0),(sptr_t)((uintptr_t)(fn) | P_LAZY))
-// #define EVALTAGC(fn) ((sptr_t)((void *)(fn) + P_LAZY))
-// #define EVALFUNC(fn) ((fptr_t)((uintptr_t)(fn) + P_FUNC))
+#define RAW_SET_F(n)   ((wptr_t)(((intptr_t)(n) << 2) | P_VALUE))
+#define RAW_SET_UF(n)  ((wptr_t)(((uintptr_t)(n) << 2) | P_VALUE))
+#define RAW_GET_F(n)   ((intptr_t)(n) >> 2)
+#define RAW_GET_UF(n)  ((uintptr_t)(n) >> 2)
hunk ./src/data/rts/jhc_rts2.c 135
-#define VALUE(n)     ((wptr_t)(((intptr_t)(n) << 2) | P_VALUE))
-#define GETVALUE(n)  ((intptr_t)(n) >> 2)
-#define ISVALUE(n)   (assert(!IS_LAZY(n)), ((uintptr_t)(n) & 0x2))
+#define RAW_SET_16(w)  (wptr_t)(((uintptr_t)(w) << 16) | P_VALUE)
+#define RAW_GET_16(n)  ((intptr_t)(n) >> 16)
+#define RAW_GET_U16(n) ((uintptr_t)(n) >> 16)
hunk ./src/data/rts/jhc_rts2.c 143
-#define GETWHAT(x)   (GET_PTYPE(x) == P_VALUE ? ((uintptr_t)(x) >> 16) : DNODEP(x)->what)
-#define SETWHAT(x,v) (DNODEP(x)->what = (v))
-#define RAWWHAT(w)   (wptr_t)(((uintptr_t)w << 16) | P_VALUE)
+#define FETCH_TAG(x)      (IS_RAW_TAG(x) ? FETCH_RAW_TAG(x) : FETCH_MEM_TAG(x))
+#define IS_RAW_TAG(x)     ((bool)((uintptr_t)(x) & 0x2))
+#define FETCH_RAW_TAG(x)  RAW_GET_U16(x)
+#define FETCH_MEM_TAG(x)  (DNODEP(x)->what)
+#define SET_RAW_TAG(x)    RAW_SET_16(x)
+#define SET_MEM_TAG(x,v)  (DNODEP(x)->what = (v))
hunk ./src/data/rts/jhc_rts_header.h 28
-#define _JHC_GC_JGC       1
+#define _JHC_GC_JGC    1