1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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]]}
]
|