diff --git a/src/macro/eval/evalEmitter.ml b/src/macro/eval/evalEmitter.ml index 7663674aac7..e3568cf8c08 100644 --- a/src/macro/eval/evalEmitter.ml +++ b/src/macro/eval/evalEmitter.ml @@ -127,11 +127,8 @@ let emit_array_declaration execs env = let emit_type_expr proto env = proto -let emit_mk_pos exec1 exec2 exec3 env = - let file = exec1 env in - let min = exec2 env in - let max = exec3 env in - encode_pos { pfile = decode_string file; pmin = decode_int min; pmax = decode_int max } +let emit_mk_pos p env = + encode_pos p let emit_enum_construction key i execs p env = encode_enum_value key i (Array.map (apply env) execs) p diff --git a/src/macro/eval/evalJit.ml b/src/macro/eval/evalJit.ml index 8d0dbd6c701..78528de66bb 100644 --- a/src/macro/eval/evalJit.ml +++ b/src/macro/eval/evalJit.ml @@ -495,16 +495,9 @@ and jit_expr jit return e = | _ -> die "" __LOC__ end | _ -> - match e1.eexpr,el with - | TIdent "$__mk_pos__",[file;min;max] -> - let exec1 = jit_expr jit false file in - let exec2 = jit_expr jit false min in - let exec3 = jit_expr jit false max in - emit_mk_pos exec1 exec2 exec3 - | _ -> - let exec = jit_expr jit false e1 in - let execs = List.map (jit_expr jit false) el in - emit_call exec execs e.epos + let exec = jit_expr jit false e1 in + let execs = List.map (jit_expr jit false) el in + emit_call exec execs e.epos end | TNew({cl_path=[],"Array"},_,_) -> emit_new_array @@ -636,6 +629,8 @@ and jit_expr jit return e = loop (Texpr.for_remap (ctx.curapi.MacroApi.get_com()).Common.basic v e1 e2 e.epos) | TParenthesis e1 | TMeta(_,e1) | TCast(e1,None) -> loop e1 + | TIdent "$__mk_pos__" -> + emit_mk_pos e.epos | TIdent s -> Error.raise_typing_error ("Unknown identifier: " ^ s) e.epos in diff --git a/src/syntax/reification.ml b/src/syntax/reification.ml index 83c7946f3c4..057f7ce78bc 100644 --- a/src/syntax/reification.ml +++ b/src/syntax/reification.ml @@ -231,13 +231,14 @@ let reify in_macro = | Some p -> p | None -> - let file = (EConst (String(p.pfile,SDoubleQuotes)),p) in - let pmin = (EConst (Int ((string_of_int p.pmin), None)),p) in - let pmax = (EConst (Int ((string_of_int p.pmax), None)),p) in - if in_macro then - (EUntyped (ECall ((EConst (Ident "$__mk_pos__"),p),[file;pmin;pmax]),p),p) - else - to_obj [("file",file);("min",pmin);("max",pmax)] p + if in_macro then + (EUntyped (EConst (Ident "$__mk_pos__"),p),p) + else begin + let file = (EConst (String(p.pfile,SDoubleQuotes)),p) in + let pmin = (EConst (Int ((string_of_int p.pmin), None)),p) in + let pmax = (EConst (Int ((string_of_int p.pmax), None)),p) in + to_obj [("file",file);("min",pmin);("max",pmax)] p + end and to_enc_pos p = match !cur_pos with | Some p -> p