Properly handle binary operators

This commit is contained in:
Théophile Bastian 2018-02-16 18:20:33 +01:00
parent dd3c7e6786
commit a194e327d0

View file

@ -61,7 +61,16 @@ let rec cps_term_inner (t: S.term) (cont: T.variable) (nameHint: string option)
: T.term = match t with
| S.Var _ -> cps_value_as_term t cont
| S.Lit _ -> cps_value_as_term t cont
| S.BinOp _ -> cps_value_as_term t cont
| S.BinOp (t1, op, t2) ->
(try cps_value_as_term t cont
with NotValue _ -> (
let t1Var = freshVar ()
and t2Var = freshVar () in
light_term t1Var t1 None @@
light_term t2Var t2 None @@
T.TailCall(T.vvar cont,
[T.VBinOp(T.vvar t1Var, op, T.vvar t2Var)])
))
| S.Lam _ as lambda ->
let fName = freshBlockVarHinted nameHint in
light_term fName lambda None @@