blob: dc8169b462d50e9db2df51101c33af8634bf7563 (
plain)
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
|
(* TEST
readonly_files = "main.c"
arguments = "-DINT_FLOAT -DFUN=is_even main.c"
* asmgen
*)
("format_odd": string "odd %d\n\000")
("format_even": string "even %d\n\000")
(function "force_spill" (a:int) 0)
(function "force_spill_float" (f:float) 0.0)
(function "is_even" (b:int)
(catch (exit even b 0.0)
with (odd v:val f:float)
(if (== v 0) f
(seq
(extcall "printf_int" "format_odd" v unit)
(let v2 (- v 1)
(app "force_spill" 0 int)
(app "force_spill_float" 0.0 float)
(exit even v2 (+f 1.0 f)))))
and (even v:val f:float)
(if (== v 0) f
(seq
(extcall "printf_int" "format_even" v unit)
(exit odd (- v 1) (+f 1.0 f))))))
|