Properly handle binary operators
This commit is contained in:
parent
dd3c7e6786
commit
a194e327d0
1 changed files with 10 additions and 1 deletions
11
src/CPS.ml
11
src/CPS.ml
|
@ -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 @@
|
||||
|
|
Loading…
Reference in a new issue