[add support for array allocation and manipulation in fgrin back end
John Meacham <john@repetae.net>**20070510052631] hunk ./C/FromGrin2.hs 343
+convertExp (Fetch (Index base off)) | getType base == TyPtr (TyPtr TyNode) = do
+    base <- convertVal base
+    off <- convertVal off
+    return (mempty,indexArray base off)
+convertExp (Update (Index base off) z) | getType z == TyPtr TyNode = do
+    base <- convertVal base
+    off <- convertVal off
+    z' <- convertVal z
+    return $ (indexArray base off `assign` z',emptyExpression)
hunk ./C/FromGrin2.hs 402
+
+convertExp Alloc { expValue = v, expCount = c, expRegion = r } | r == region_heap, TyPtr TyNode == getType v  = do
+    v' <- convertVal v
+    c' <- convertVal c
+    tmp <- newVar (ptrType sptr_t)
+    let malloc = tmp `assign` jhc_malloc (operator "*" (sizeof sptr_t) c')
+    fill <- case v of
+        ValUnknown _ -> return mempty
+        _ -> do
+            i <- newVar (basicType "int")
+            return $ forLoop i (expressionRaw "0") c' $ indexArray tmp i `assign` v'
+    return (malloc `mappend` fill, tmp)
+
hunk ./C/FromGrin2.hs 748
-convertExp (Fetch (Index base off)) | getType base == TyPtr (TyPtr TyNode) = do
-    base <- convertVal base
-    off <- convertVal off
-    ure.eturn (mempty,indexArray base off)
hunk ./C/FromGrin2.hs 773
-convertExp (Update (Index base off) z) | getType z == TyPtr TyNode = do
-    base <- convertVal base
-    off <- convertVal off
-    z' <- convertVal z
-    return $ (indexArray base off `assign` z',emptyExpression)