[finally remove the ambiguity between the pointer to a node and an indirect node, make the difference explicit in the grin type.
John Meacham <john@repetae.net>**20090629103337
 Ignore-this: d3b0a312eb18b776bc6dbd2b634517de
] hunk ./C/FromGrin2.hs 135
-            mmalloc [TyPtr TyNode] = [a_MALLOC]
+            mmalloc [TyINode] = [a_MALLOC]
hunk ./C/FromGrin2.hs 235
-convertType (TyPtr TyNode) = return sptr_t
-convertType (TyPtr (TyPtr TyNode)) = return $ ptrType sptr_t
+convertType TyINode = return sptr_t
+convertType (TyPtr TyINode) = return $ ptrType sptr_t
+convertType (TyPtr TyNode) = return $ ptrType wptr_t
hunk ./C/FromGrin2.hs 397
+        f TyINode = return nullPtr
hunk ./C/FromGrin2.hs 542
-convertExp (Update v@(Var vv _) tn@(NodeC t as)) | getType v == TyPtr TyNode = do
+convertExp (Update v@(Var vv _) tn@(NodeC t as)) | getType v == TyINode = do
hunk ./C/FromGrin2.hs 555
-convertExp Alloc { expValue = v, expCount = c, expRegion = r } | r == region_heap, TyPtr TyNode == getType v  = do
+convertExp Alloc { expValue = v, expCount = c, expRegion = r } | r == region_heap, TyINode == getType v  = do
hunk ./Grin/DeadCode.hs 179
-    f (Update (Var v (TyPtr TyNode)) _) | deadCaf v = do
+    f (Update (Var v TyINode) _) | deadCaf v = do
hunk ./Grin/DeadCode.hs 199
-    clearCaf (Var v (TyPtr TyNode)) | deadCaf v = do
+    clearCaf (Var v TyINode) | deadCaf v = do
hunk ./Grin/DeadCode.hs 201
-        return (properHole (TyPtr TyNode))
+        return (properHole TyINode)
hunk ./Grin/Devolve.hs 132
-    isNode (TyPtr TyNode) = True
+    isNode TyINode = True
hunk ./Grin/FromE.hs 190
-            ccafMap = fromList $ [(tvrIdent v,e) |(v,_,e) <- cc ]  ++ [ (tvrIdent v,Var vv (TyPtr TyNode)) | (v,vv,_) <- rcafs]
+            ccafMap = fromList $ [(tvrIdent v,e) |(v,_,e) <- cc ]  ++ [ (tvrIdent v,Var vv TyINode) | (v,vv,_) <- rcafs]
hunk ./Grin/FromE.hs 221
-        initCafs = sequenceG_ [ Update (Var v (TyPtr TyNode)) node | (v,node) <- cafs ]
+        initCafs = sequenceG_ [ Update (Var v TyINode) node | (v,node) <- cafs ]
hunk ./Grin/FromE.hs 243
-        as = [ toType (TyPtr TyNode) s |  s <- conSlots c]
+        as = [ toType TyINode s |  s <- conSlots c]
hunk ./Grin/FromE.hs 309
-    conv (EVar v) | v `Set.member` lbs = Var (cafNum v) (TyPtr TyNode)
+    conv (EVar v) | v `Set.member` lbs = Var (cafNum v) TyINode
hunk ./Grin/FromE.hs 334
-    toVal TVr { tvrType = ty, tvrIdent = num } = case toType (TyPtr TyNode) ty of
+    toVal TVr { tvrType = ty, tvrIdent = num } = case toType TyINode ty of
hunk ./Grin/FromE.hs 445
-            return $ Alloc { expValue = ValUnknown (TyPtr TyNode), expCount = v', expRegion = region_heap, expInfo = mempty }
+            return $ Alloc { expValue = ValUnknown TyINode, expCount = v', expRegion = region_heap, expInfo = mempty }
hunk ./Grin/FromE.hs 578
-            targs = [Var v ty | v <- [v1..] | ty <- (TyPtr TyNode:map getType as)]
+            targs = [Var v ty | v <- [v1..] | ty <- (TyINode:map getType as)]
hunk ./Grin/FromE.hs 733
-    newNodePtrVar =  fmap (\x -> Var x (TyPtr TyNode)) newVar
+    newNodePtrVar =  fmap (\x -> Var x TyINode) newVar
hunk ./Grin/Grin.hs 111
-tyINode = TyPtr TyNode
+tyINode = TyINode
hunk ./Grin/Grin.hs 135
+-- For historical reasons, some of the grin expressions do different things depending on the arguments type and whether it is a variable.
+--
+--
+--
+-- Store : NodeC:TyNode  -> TyINode   - this allocates a new indirect node
+-- Store : var:TyNode -> TyINode - this demotes a node to an indirect node. called 'demote'
+-- Update : var:TyINode, TyNode - this stores an indirection to the second argument in the first
+-- Update : TyPtr t, t - this sets the memory pointed to by the first argumnet to the second. it is called 'poke'
+-- Update : var:TyNode, x:TyNode - this copies the contents of the second argument over the first
+-- Update : var:TyINode, x:TyINode - this copies the contents of the second argument over the first
+-- Fetch  : TyINode -> TyNode - follow an indirection, also called 'promote'
+-- Fetch  : TyPtr t -> t - read a pointer, also called 'peek'
+--
+--
+
hunk ./Grin/Grin.hs 203
-    NodeC !Tag [Val]          -- ^ Complete node with constant tag
-    | Const Val               -- ^ pointer to constant data, only Lit, Tag, and NodeC may be children
+    NodeC !Tag [Val]          -- ^ Complete node, of type TyNode
+    | Const Val               -- ^ constant data, only Lit, Const and NodeC may be children. of type TyINode
hunk ./Grin/Grin.hs 211
-    | ValUnknown Ty           -- ^ Unknown value
+    | ValUnknown Ty           -- ^ Unknown or unimportant value
hunk ./Grin/Grin.hs 215
-    TyPtr Ty                 -- ^ pointer to a heap location which contains its argument
-    | TyNode                   -- ^ a whole tagged node
-    | TyPrim Op.Ty             -- ^ a basic type
-    | TyUnit                   -- ^ type of Unit
+    TyPtr Ty                     -- ^ pointer to a memory location which contains its argument
+    | TyNode                     -- ^ a whole node
+    | TyINode                    -- ^ a whole possibly indirect node
+    | TyPrim Op.Ty               -- ^ a basic type
+    | TyUnit                     -- ^ type of Unit
hunk ./Grin/Grin.hs 221
-    | TyRegion                 -- ^ a region
-    | TyUnknown                -- ^ an unknown possibly undefined type, All of these must be eliminated by code generation
+    | TyRegion                   -- ^ a region
+    | TyUnknown                  -- ^ an unknown possibly undefined type, All of these must be eliminated by code generation
hunk ./Grin/Grin.hs 278
+    show TyINode = "I"
hunk ./Grin/Grin.hs 293
-        | TyPtr TyNode <- t = text "ni" <> tshow i
+        | TyINode <- t = text "ni" <> tshow i
hunk ./Grin/Grin.hs 295
-        | TyPtr (TyPtr TyNode) <- t = text "np" <> tshow i
+--        | TyPtr TyINode <- t = text "np" <> tshow i
+        | TyPtr t' <- t = text "p" <> shows (Var (V i) t')
hunk ./Grin/Grin.hs 305
-        | TyPrim (Op.TyBits (Op.BitsArch Op.BitsPtr)  _) <- t  = char 'p' <> tshow i
-        | TyPrim (Op.TyBits (Op.BitsArch Op.BitsMax)  _) <- t  = char 'm' <> tshow i
+        | TyPrim (Op.TyBits (Op.BitsArch Op.BitsPtr)  _) <- t  = text "bp" <> tshow i
+        | TyPrim (Op.TyBits (Op.BitsArch Op.BitsMax)  _) <- t  = text "bm" <> tshow i
hunk ./Grin/Grin.hs 427
-    TyPtr TyNode -> Const (properHole TyNode)
+    TyINode -> Const (properHole TyNode)
hunk ./Grin/Grin.hs 431
-isHole x = x `elem` map properHole [TyPtr TyNode, TyNode]
+isHole x = x `elem` map properHole [TyINode, TyNode]
hunk ./Grin/Grin.hs 464
-p0 = Var v0 (TyPtr TyNode)
-p1 = Var v1 (TyPtr TyNode)
-p2 = Var v2 (TyPtr TyNode)
-p3 = Var v3 (TyPtr TyNode)
+p0 = Var v0 TyINode
+p1 = Var v1 TyINode
+p2 = Var v2 TyINode
+p3 = Var v3 TyINode
hunk ./Grin/Grin.hs 477
-    getType (Store v) = [TyPtr (getType v)]
+    getType (Store v) = case getType v of
+        TyNode -> [TyINode]
+        t -> [TyPtr t]
hunk ./Grin/Grin.hs 482
+        TyINode -> [TyNode]
hunk ./Grin/Grin.hs 502
-    getType (Const t) = TyPtr (getType t)
+    getType (Const t) = case (getType t) of
+        TyNode -> TyINode
+        t -> TyPtr t
hunk ./Grin/NodeAnalyze.hs 80
-    isGood (TyPtr TyNode) = True
+    isGood TyINode = True
hunk ./Grin/NodeAnalyze.hs 115
-        docaf (v,tt) | True = tell $ Right top `equals` Left (V (Vr v) (TyPtr TyNode))
+        docaf (v,tt) | True = tell $ Right top `equals` Left (V (Vr v) TyINode)
hunk ./Grin/NodeAnalyze.hs 238
-        f (Update (Var vname ty) v) | ty == TyPtr TyNode  = do
+        f (Update (Var vname ty) v) | ty == TyINode  = do
hunk ./Grin/NodeAnalyze.hs 242
-        f (Update (Var vname ty) v) | ty == TyPtr (TyPtr TyNode)  = do
+        f (Update (Var vname ty) v) | ty == TyPtr TyINode  = do
hunk ./Grin/NodeAnalyze.hs 265
-               tell $ Right top `islte` Left (fa fn (length vs + i) (TyPtr TyNode))
+               tell $ Right top `islte` Left (fa fn (length vs + i) TyINode)