From a194e327d04ea63b8117badb01ca771ea0870289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Fri, 16 Feb 2018 18:20:33 +0100 Subject: [PATCH] Properly handle binary operators --- src/CPS.ml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CPS.ml b/src/CPS.ml index 0714e87..3f21702 100644 --- a/src/CPS.ml +++ b/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 @@