@@ 15,11 15,15 @@ import Compiler.VMCode
import Libraries.Utils.Path
import Compiler.CPS
+import Compiler.CPSI
import Compiler.CPSLift
import Compiler.CPSPrepare
+import Data.Utils
import Rapid.Common
import Rapid.Driver
+%hide Data.Utils.showSep
+
shell : List String -> String
shell args = showSep " " $ map shellQuote args
where
@@ 94,12 98,23 @@ compile defs tmpDir outputDir term outfile = do
cd <- getCompileData False Cases term
coreLift_ $ fPutStrLn stderr $ "got compiledata"
- let mainExpr = forget (cd.mainExpr)
+ let mainExpr = cd.mainExpr
let mainName = MN "__mainExpression" 0
- let allFunctionsRaw = (mainName, emptyFC, MkNmFun [] mainExpr)::cd.namedDefs
- let allFunctions = map transformDef allFunctionsRaw
-
- cps <- for allFunctions (\(n, fc, d) => pure (n, fc, !(defToCPS d)))
+ let allFunctionsRaw = (mainName, emptyFC, MkFun [] mainExpr)::cd.cseDefs
+ let allFunctions = map prepareDef allFunctionsRaw
+ coreLift_ $ fPutStrLn stderr $ "preparation complete"
+ let funCount = length allFunctions
+ cpsRaw <- for (enumerate allFunctions) (\(i, (n, fc, d)) => do
+ coreLift_ $ fPutStrLn stderr $ "CPS transform def \{show i}/\{show funCount}: \{show n}"
+ pure (n, fc, CPSI.defToCPS d))
+ coreLift_ $ fPutStrLn stderr $ "cps transform complete"
+
+ --let cps = cpsRaw <&> (\(n, fc, d) => (n, fc, (forgetDef d)))
+ cps <- for (enumerate cpsRaw) (\(i, (n, fc, d)) => do
+ coreLift_ $ fPutStrLn stderr $ "CPS forget def \{show i}/\{show funCount}: \{show n}"
+ pure (n, fc, forgetDef d))
+ coreLift_ $ fPutStrLn stderr $ "forget complete"
+ --cps <- for allFunctions (\(n, fc, d) => pure (n, fc, !(defToCPS d)))
liftedCps <- liftDefs cps
coreLift_ $ fPutStrLn stderr $ "got lifted CPS defs"