|
@@ -479,6 +479,21 @@ module Transformer = struct
|
|
lift_expr ~blocks:[x] substitute
|
|
lift_expr ~blocks:[x] substitute
|
|
| _ -> def
|
|
| _ -> def
|
|
|
|
|
|
|
|
+ and transform_call is_value e params ae =
|
|
|
|
+ let trans is_value blocks e = transform_expr1 is_value ae.a_next_id blocks e in
|
|
|
|
+ let trans1 e params =
|
|
|
|
+ let e = trans true [] e in
|
|
|
|
+ let blocks = e.a_blocks @ (List.flatten (List.map (fun (p) -> p.a_blocks) params)) in
|
|
|
|
+ let params = List.map (fun (p) -> p.a_expr) params in
|
|
|
|
+ let e = { ae.a_expr with eexpr = TCall(e.a_expr, params) } in
|
|
|
|
+ lift_expr ~blocks:blocks e
|
|
|
|
+ in
|
|
|
|
+ match e, params with
|
|
|
|
+ (* the foreach block should not be handled as a value *)
|
|
|
|
+ | ({ eexpr = TField(_, FStatic({cl_path = ["python";],"Syntax"},{ cf_name = "_foreach" }))} as e, [e1;e2;e3]) ->
|
|
|
|
+ trans1 e [trans true [] e1; trans true [] e2; trans false [] e3]
|
|
|
|
+ | (e, params) ->
|
|
|
|
+ trans1 e (List.map (trans true []) params)
|
|
|
|
|
|
|
|
|
|
and transform1 ae : adjusted_expr =
|
|
and transform1 ae : adjusted_expr =
|
|
@@ -751,17 +766,8 @@ module Transformer = struct
|
|
let params = List.map (fun (p) -> p.a_expr) params in
|
|
let params = List.map (fun (p) -> p.a_expr) params in
|
|
let e = { a_expr with eexpr = TNew(c, tp, params) } in
|
|
let e = { a_expr with eexpr = TNew(c, tp, params) } in
|
|
lift false blocks e
|
|
lift false blocks e
|
|
-(* | (_, TCall({ eexpr = TLocal({v_name = "__python_for__" })} as x, [param])) ->
|
|
|
|
- let param = trans false [] param in
|
|
|
|
- let call = { a_expr with eexpr = TCall(x, [param.a_expr])} in
|
|
|
|
- lift_expr call *)
|
|
|
|
- | (_, TCall(e, params)) ->
|
|
|
|
- let e = trans true [] e in
|
|
|
|
- let params = List.map (trans true []) params in
|
|
|
|
- let blocks = e.a_blocks @ (List.flatten (List.map (fun (p) -> p.a_blocks) params)) in
|
|
|
|
- let params = List.map (fun (p) -> p.a_expr) params in
|
|
|
|
- let e = { a_expr with eexpr = TCall(e.a_expr, params) } in
|
|
|
|
- lift_expr ~blocks:blocks e
|
|
|
|
|
|
+ | (is_value, TCall(e,params)) ->
|
|
|
|
+ transform_call is_value e params ae
|
|
| (_, TArray(e1, e2)) ->
|
|
| (_, TArray(e1, e2)) ->
|
|
let e1 = trans true [] e1 in
|
|
let e1 = trans true [] e1 in
|
|
let e2 = trans true [] e2 in
|
|
let e2 = trans true [] e2 in
|
|
@@ -1259,11 +1265,10 @@ module Printer = struct
|
|
Printf.sprintf "%s(%s)" (print_expr pctx e1) (print_exprs pctx ", " el)
|
|
Printf.sprintf "%s(%s)" (print_expr pctx e1) (print_exprs pctx ", " el)
|
|
| "python_Syntax.opPow", [e1;e2] ->
|
|
| "python_Syntax.opPow", [e1;e2] ->
|
|
Printf.sprintf "(%s ** %s)" (print_expr pctx e1) (print_expr pctx e2)
|
|
Printf.sprintf "(%s ** %s)" (print_expr pctx e1) (print_expr pctx e2)
|
|
-(* | "__python_for__",[{eexpr = TBlock [{eexpr = TVar(v1,_)};e2;block]}] ->
|
|
|
|
- let f1 = v1.v_name in
|
|
|
|
|
|
+ | "python_Syntax._foreach",[e1;e2;e3] ->
|
|
let pctx = {pctx with pc_indent = "\t" ^ pctx.pc_indent} in
|
|
let pctx = {pctx with pc_indent = "\t" ^ pctx.pc_indent} in
|
|
let i = pctx.pc_indent in
|
|
let i = pctx.pc_indent in
|
|
- Printf.sprintf "for %s in %s:\n%s%s" f1 (print_expr pctx e2) i (print_expr pctx block) *)
|
|
|
|
|
|
+ Printf.sprintf "for %s in %s:\n%s%s" (print_expr pctx e1) (print_expr pctx e2) i (print_expr pctx e3)
|
|
(* | "__new_named__",e1::el ->
|
|
(* | "__new_named__",e1::el ->
|
|
Printf.sprintf "new %s(%s)" (print_expr pctx e1) (print_exprs pctx ", " el) *)
|
|
Printf.sprintf "new %s(%s)" (print_expr pctx e1) (print_exprs pctx ", " el) *)
|
|
(* | "__python_kwargs__",[e1] ->
|
|
(* | "__python_kwargs__",[e1] ->
|