summaryrefslogtreecommitdiff
path: root/compiler/codeGen/CgMonad.lhs
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2012-01-27 09:53:48 +0000
committerSimon Marlow <marlowsd@gmail.com>2012-01-27 09:53:48 +0000
commited90dd62e7846d42cc44b43c199d58697b031a19 (patch)
treeabde19f406810d3950cfbbaf57506f5866605f1a /compiler/codeGen/CgMonad.lhs
parent1fdb39b5a648bac2a7c68ae8f69b074e39b0ea2e (diff)
downloadhaskell-ed90dd62e7846d42cc44b43c199d58697b031a19.tar.gz
Make the old codegen run in constant space too
Diffstat (limited to 'compiler/codeGen/CgMonad.lhs')
-rw-r--r--compiler/codeGen/CgMonad.lhs13
1 files changed, 6 insertions, 7 deletions
diff --git a/compiler/codeGen/CgMonad.lhs b/compiler/codeGen/CgMonad.lhs
index 302d8ac652..59f6accf9d 100644
--- a/compiler/codeGen/CgMonad.lhs
+++ b/compiler/codeGen/CgMonad.lhs
@@ -14,7 +14,7 @@ module CgMonad (
Code,
FCode,
- initC, thenC, thenFC, listCs, listFCs, mapCs, mapFCs,
+ initC, runC, thenC, thenFC, listCs, listFCs, mapCs, mapFCs,
returnFC, fixC, fixC_, checkedAbsC,
stmtC, stmtsC, labelC, emitStmts, nopC, whenC, newLabelC,
newUnique, newUniqSupply,
@@ -379,13 +379,12 @@ instance Monad FCode where
The Abstract~C is not in the environment so as to improve strictness.
\begin{code}
-initC :: DynFlags -> Module -> FCode a -> IO a
+initC :: IO CgState
+initC = do { uniqs <- mkSplitUniqSupply 'c'
+ ; return (initCgState uniqs) }
-initC dflags mod (FCode code)
- = do { uniqs <- mkSplitUniqSupply 'c'
- ; case code (initCgInfoDown dflags mod) (initCgState uniqs) of
- (res, _) -> return res
- }
+runC :: DynFlags -> Module -> CgState -> FCode a -> (a,CgState)
+runC dflags mod st (FCode code) = code (initCgInfoDown dflags mod) st
returnFC :: a -> FCode a
returnFC val = FCode (\_ state -> (val, state))