[clean up C code generator just a bit
John Meacham <john@repetae.net>**20080313184924] hunk ./C/FromGrin2.hs 354
-    let jerr | null s    = expr $ functionCall (name "jhc_exit") [constant $ number 255]
-             | otherwise = expr $ functionCall (name "jhc_error") [string s]
+    let jerr | null s    = toStatement $ functionCall (name "jhc_exit") [constant $ number 255]
+             | otherwise = toStatement $ functionCall (name "jhc_error") [string s]
hunk ./C/FromGrin2.hs 407
-    return $ indexArray base off `assign` z'
+    return $ indexArray base off =* z'
hunk ./C/FromGrin2.hs 444
-        TodoExp [] -> return $ expr er
+        TodoExp [] -> return $ toStatement er
hunk ./C/FromGrin2.hs 502
-    let malloc = tmp `assign` jhc_malloc (operator "*" (sizeof sptr_t) c')
+    let malloc = tmp =* jhc_malloc (operator "*" (sizeof sptr_t) c')
hunk ./C/FromGrin2.hs 507
-            return $ forLoop i (expressionRaw "0") c' $ indexArray tmp i `assign` v'
+            return $ forLoop i (expressionRaw "0") c' $ indexArray tmp i =* v'
hunk ./C/FromGrin2.hs 781
-profile_update_inc   = expr $ functionCall (name "jhc_update_inc") []
-profile_case_inc     = expr $ functionCall (name "jhc_case_inc") []
-profile_function_inc = expr $ functionCall (name "jhc_function_inc") []
+profile_update_inc   = toStatement $ functionCall (name "jhc_update_inc") []
+profile_case_inc     = toStatement $ functionCall (name "jhc_case_inc") []
+profile_function_inc = toStatement $ functionCall (name "jhc_function_inc") []
hunk ./C/FromGrin2.hs 816
-------------
--- C helpers
-------------
-
-infix 3 `eq`
-
-eq :: Expression -> Expression -> Expression
-eq = operator "=="
-
-infix 2 =*
-
-(=*) :: Expression -> Expression -> Statement
-x =* y = x `assign` y
-
-class ToStatement a  where
-    toStatement :: a -> Statement
-
-instance ToStatement Statement where
-    toStatement x = x
-
-instance ToStatement Expression where
-    toStatement x = expr x
-
-class ToExpression a where
-    toExpression :: a -> Expression
-
-instance ToExpression Expression where
-    toExpression e = e
-
-instance ToExpression Constant where
-    toExpression c = constant c
-
-instance ToExpression Name where
-    toExpression c = variable c
-
-
-infixl 1 &
-
-(&) :: (ToStatement a,ToStatement b) => a -> b -> Statement
-x & y = toStatement x `mappend` toStatement y
-
hunk ./C/Generate.hs 4
+    (=*),
+    (&),
+    ToExpression(..),
+    ToStatement(..),
+    eq,
hunk ./C/Generate.hs 11
-    assign,
hunk ./C/Generate.hs 25
-    expr,
hunk ./C/Generate.hs 69
-    test,
hunk ./C/Generate.hs 529
---namedStructType :: Name -> [(Name,Type)] -> Type
---structType :: Name -> [Type] -> Type
---enumType :: Name -> [Name] -> Type
-
hunk ./C/Generate.hs 630
-test1 = constant (number 3)
-test2 = operator "-" (operator "+" test1 test1) test1
-test3 = expr $ functionCall (toName "foo") [test1,test2]
-test4 = mconcat [test3,expr test2,test3]
-
-showIt x = putStrLn (render $ drawG x)
-
-
-test = do
-    showIt test2
-    showIt test3
-    showIt test4
hunk ./C/Generate.hs 642
+------------
+-- C helpers
+------------
+
+infix 3 `eq`
+
+eq :: Expression -> Expression -> Expression
+eq = operator "=="
+
+infix 2 =*
+
+(=*) :: Expression -> Expression -> Statement
+x =* y = x `assign` y
+
+class ToStatement a  where
+    toStatement :: a -> Statement
+
+instance ToStatement Statement where
+    toStatement x = x
+
+instance ToStatement Expression where
+    toStatement x = expr x
+
+class ToExpression a where
+    toExpression :: a -> Expression
+
+instance ToExpression Expression where
+    toExpression e = e
+
+instance ToExpression Constant where
+    toExpression c = constant c
+
+instance ToExpression Name where
+    toExpression c = variable c
+
+
+infixl 1 &
+
+(&) :: (ToStatement a,ToStatement b) => a -> b -> Statement
+x & y = toStatement x `mappend` toStatement y
+