[make distinction between sptr_t and wptr_t, use it in code generation. be sure to treat global cafs as lazy locations rather than ones in WHNF
John Meacham <john@repetae.net>**20070227083227] hunk ./C/FromGrin2.hs 162
---convertType TyNode = return pnode_t
---convertType (TyPtr TyNode) = return pnode_t
-convertType TyNode = return sptr_t
+convertType TyNode = return wptr_t
hunk ./C/FromGrin2.hs 164
-convertType (TyPtr (TyPtr TyNode)) = return $ ptrType sptr_t -- ppnode_t
+convertType (TyPtr (TyPtr TyNode)) = return $ ptrType sptr_t
hunk ./C/FromGrin2.hs 330
-    tmp <- newVar ppnode_t
-    return ((tmp =* jhc_malloc (sizeof pnode_t)) & (dereference tmp =* v),tmp)
+    tmp <- newVar (ptrType sptr_t)
+    return ((tmp =* jhc_malloc (sizeof sptr_t)) & (dereference tmp =* v),tmp)
hunk ./C/FromGrin2.hs 366
-convertExp (Update v@Var {} (NodeC t as)) | tagIsSuspFunction t, getType v == TyPtr TyNode = do
-    en <- declareEvalFunc t
+convertExp (Update v@(Var vv _) (NodeC t as)) | getType v == TyPtr TyNode = do
hunk ./C/FromGrin2.hs 370
-    let tmp' = cast nt v'
-        s = getTag tmp' =* functionCall (name "EVALTAG") [reference (variable en)]
-        ass = [project' (arg i) tmp' =* a | a <- as' | i <- [(1 :: Int) ..] ]
+    let tmp' = cast nt (if vv < v0 then f_DETAG v' else v')
+    s <- if tagIsSuspFunction t then do
+        en <- declareEvalFunc t
+        return $ getTag tmp' =* f_EVALTAG (reference (variable en))
+     else do
+        declareStruct t
+        tell mempty { wTags = Set.singleton t }
+        return $ getTag tmp' =* constant (enum (nodeTagName t))
+    let ass = [project' (arg i) tmp' =* a | a <- as' | i <- [(1 :: Int) ..] ]
hunk ./C/FromGrin2.hs 380
-convertExp (Update v@Var {} (NodeC t as)) | getType v == TyPtr TyNode = do
+{-
+convertExp (Update v@(Var vv _) (NodeC t as)) | getType v == TyPtr TyNode = do
hunk ./C/FromGrin2.hs 387
-    let tmp' = cast nt v'
+    let tmp' = cast nt (if vv < v0 then f_DETAG v' else v')
hunk ./C/FromGrin2.hs 391
+-}
hunk ./C/FromGrin2.hs 395
-ccaf (v,val) = text "/* " <> text (show v) <> text " = " <> (text $ P.render (pprint val)) <> text "*/\n" <> text "static node_t _" <> tshow (varName v) <> text ";\n" <> text "#define " <> tshow (varName v) <+>  text "(&_" <> tshow (varName v) <> text ")\n";
+ccaf (v,val) = text "/* " <> text (show v) <> text " = " <> (text $ P.render (pprint val)) <> text "*/\n" <> text "static node_t _" <> tshow (varName v) <> text ";\n" <> text "#define " <> tshow (varName v) <+>  text "(EVALTAG(&_" <> tshow (varName v) <> text "))\n";
hunk ./C/FromGrin2.hs 464
-    return $  (mempty,jhc_malloc (sizeof node_t))
+    fail "newNode.tagHole"
hunk ./C/FromGrin2.hs 469
-    tmp <- newVar pnode_t
+    tmp <- newVar sptr_t
hunk ./C/FromGrin2.hs 472
-        tagassign = getTag tmp' =* functionCall (name "EVALTAG") [reference (variable en)]
+        tagassign = getTag tmp' =* f_EVALTAG (reference (variable en))
hunk ./C/FromGrin2.hs 478
-        tmp'' = functionCall (name "EVALTAG") [tmp]
-    return (mconcat $ malloc:tagassign:ass, cast pnode_t tmp'')
+        tmp'' = f_EVALTAG tmp
+    return (mconcat $ malloc:tagassign:ass, cast sptr_t tmp'')
hunk ./C/FromGrin2.hs 485
-    tmp <- newVar pnode_t
+    tmp <- newVar wptr_t
hunk ./C/FromGrin2.hs 487
-        malloc =  tmp =* wmalloc (sizeof  (if tagIsWHNF t then st else node_t))
+        malloc =  tmp =* wmalloc (sizeof st)
hunk ./C/FromGrin2.hs 495
-    return (mconcat $ malloc:tagassign:ass, cast pnode_t tmp)
+    return (mconcat $ malloc:tagassign:ass, tmp)
hunk ./C/FromGrin2.hs 516
-        rvar = localVariable sptr_t (name "r");
+        rvar = localVariable wptr_t (name "r");
hunk ./C/FromGrin2.hs 519
-        update =  functionCall (toName "update") [cast sptr_t (variable aname),rvar]
-    tellFunctions [function fname sptr_t [(aname,atype)] [] (body & update & creturn rvar )]
+        update =  functionCall (toName "update") [cast wptr_t (variable aname),rvar]
+    tellFunctions [function fname wptr_t [(aname,atype)] [] (body & update & creturn rvar )]
hunk ./C/FromGrin2.hs 562
+f_DETAG e = functionCall (name "DETAG") [e]
+f_EVALTAG e = functionCall (name "EVALTAG") [e]
hunk ./C/FromGrin2.hs 580
-node_t = basicType "node_t"
hunk ./C/FromGrin2.hs 581
-pnode_t = ptrType node_t
-ppnode_t = ptrType (ptrType node_t)
+wptr_t = basicType "wptr_t"