[bring back a little interpreter functionality, add some labels to the primitives
John Meacham <john@repetae.net>**20051108090156] hunk ./C/Prims.hs 21
-    | CConst String ExtType  -- C code which evaluates to a constant
-    | Operator String  [ExtType] ExtType   -- C operator
-    | Func Bool String [ExtType] ExtType   -- function call with C calling convention
-    | IFunc [ExtType] ExtType              -- indirect function call
-    | AddrOf String                        -- address of linker name
-    | Peek ExtType                         -- read value from memory
-    | Poke ExtType                         -- write value to memory
-    | CCast ExtType ExtType                -- Cast from one basic type to another, possibly lossy.
+    | CConst { primConst :: String, primRetType :: ExtType }  -- C code which evaluates to a constant
+    | Operator { primOp :: String, primArgTypes ::  [ExtType], primRetType :: ExtType }   -- C operator
+    | Func { funcIOLike :: Bool, funcName :: String, primArgTypes :: [ExtType], primRetType :: ExtType }   -- function call with C calling convention
+    | IFunc { primArgTypes :: [ExtType], primRetType :: ExtType }-- indirect function call
+    | AddrOf String                                              -- address of linker name
+    | Peek { primArgType :: ExtType }                            -- read value from memory
+    | Poke { primArgType :: ExtType }                            -- write value to memory
+    | CCast { primArgType :: ExtType, primRetType :: ExtType }   -- Cast from one basic type to another, possibly lossy.
hunk ./Grin/Interpret.hs 4
+import CanType
hunk ./Grin/Interpret.hs 8
+import C.Prims
hunk ./Grin/Interpret.hs 23
---createCafMap as = f vars [] >>= return . Map.fromList  where
---    f [] xs = return xs
---    f ((x,y):xs) ys = newIORef (NodeC y []) >>= \y -> f xs ((x,Addr y):ys)
---    vars = [ ((V $ - atomIndex tag) ,tag) | (x,[],_) <- as, x /= funcInitCafs, let tag = partialTag x 0]
hunk ./Grin/Interpret.hs 65
-            --Just (Right action) -> do action xs'
hunk ./Grin/Interpret.hs 66
+    f env (Prim Primitive { primAPrim = APrim CCast {} _, primType = (_,t)} [x]) = return $ (Lit n t)
+        where (Lit n _) = le env x
+    f env (Prim Primitive { primAPrim = APrim Func { funcName = "putwchar" } _} [x]) = putChar (chr $ fromIntegral n) >> return unit
+        where (Lit n _) = le env x
hunk ./Grin/Interpret.hs 155
-    bind v r   = fail "unbindable"    -- check type to be sure
-    --bind v r | runIdentity (tc te v) == runIdentity (tc te r)  = fail "unbindable"    -- check type to be sure
-    --bind x y = error $ "bad bind: " ++ show (x,y)
+    bind v r | getType v == getType r = fail $ "unbindable: "  ++ show (v,r,getType v,getType r)   -- check type to be sure
+    bind x y = error $ "bad bind: " ++ show (x,y)
+
+