Fix C code production, add ifzero basic test

This commit is contained in:
Théophile Bastian 2018-02-16 00:52:07 +01:00
parent 3141ce6fde
commit 7c6e2e390e
3 changed files with 4 additions and 1 deletions

View file

@ -230,7 +230,8 @@ let rec finish_term (t : S.term) : C.stmt =
) )
| S.IfZero (expr, tIf, tElse) -> | S.IfZero (expr, tIf, tElse) ->
T.IfElse ( T.IfElse (
finish_value expr, T.Op2(T.K.Eq, to_int @@ finish_value expr,
T.Constant(T.K.Int32, "0")),
finish_term tIf, finish_term tIf,
finish_term tElse) finish_term tElse)
| S.Swi (v, bs) -> | S.Swi (v, bs) ->

1
src/tests/simple_if.exp Normal file
View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1 @@
ifzero 42 then print 0 else print 1