diff options
author | Camil Staps | 2018-12-24 14:40:24 +0100 |
---|---|---|
committer | Camil Staps | 2018-12-24 14:40:24 +0100 |
commit | 4d24cd1e3c8a35df8ea872dda22f431b46c3c64f (patch) | |
tree | 5ed2940fe858ddf8d0f72e8a685ff0578de5f862 /isjit.icl | |
parent | Fix compilation for constant functions (allocate space for return value) (diff) |
Divide in modules
Diffstat (limited to 'isjit.icl')
-rw-r--r-- | isjit.icl | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/isjit.icl b/isjit.icl new file mode 100644 index 0000000..72d95dd --- /dev/null +++ b/isjit.icl @@ -0,0 +1,32 @@ +module isjit + +import StdEnv +import StdMaybe +import StdOverloadedList + +import System.CommandLine + +import Sjit.Compile +import Sjit.Syntax +import Sjit.Run + +import Text.GenPrint +derive gPrint Instr + +Start w +# (io,w) = stdio w +# io = Foldl (\io b -> io <<< " " <<< printToString b <<< "\n") (io <<< "Program blocks:\n") comp_state.blocks +# io = io <<< "Interpreted result: " <<< interpreted_result <<< "\n" +# io = io <<< "JIT-compiled result: " <<< jit_compiled_result <<< "\n" +# (_,w) = fclose io w += setReturnCode (if (interpreted_result==jit_compiled_result) 0 1) w +where + interpreted_result = interpret comp_state + jit_compiled_result = exec comp_state + +comp_state =: compile_all Nothing + [ {fun_name="id", fun_args=["x"], fun_expr=Var "x"} + , {fun_name="const", fun_args=["x","y"], fun_expr=Var "x"} + , {fun_name="seven", fun_args=[], fun_expr=App "const" [Int 7, Int 10]} + , {fun_name="main", fun_args=[], fun_expr=App "+" [App "seven" [], App "const" [Int 5, Int 10]]} + ] |