|
@@ -4504,7 +4504,7 @@ let typing_timer ctx need_type f =
|
|
|
exit();
|
|
|
raise e
|
|
|
|
|
|
-let load_macro_ref : (typer -> path -> string -> pos -> (typer * ((string * bool * t) list * t * tclass * Type.tclass_field) * (Interp.value list -> Interp.value option))) ref = ref (fun _ _ _ _ -> assert false)
|
|
|
+let load_macro_ref : (typer -> bool -> path -> string -> pos -> (typer * ((string * bool * t) list * t * tclass * Type.tclass_field) * (Interp.value list -> Interp.value option))) ref = ref (fun _ _ _ _ -> assert false)
|
|
|
|
|
|
let make_macro_api ctx p =
|
|
|
let parse_expr_string s p inl =
|
|
@@ -4576,7 +4576,7 @@ let make_macro_api ctx p =
|
|
|
Interp.type_macro_expr = (fun e ->
|
|
|
let e = typing_timer ctx true (fun() -> type_expr ctx e Value) in
|
|
|
let rec loop e = match e.eexpr with
|
|
|
- | TField(_,FStatic(c,({cf_kind = Method _} as cf))) -> ignore(!load_macro_ref ctx c.cl_path cf.cf_name e.epos)
|
|
|
+ | TField(_,FStatic(c,({cf_kind = Method _} as cf))) -> ignore(!load_macro_ref ctx false c.cl_path cf.cf_name e.epos)
|
|
|
| _ -> Type.iter loop e
|
|
|
in
|
|
|
loop e;
|
|
@@ -4927,7 +4927,7 @@ let get_macro_context ctx p =
|
|
|
create_macro_interp ctx mctx;
|
|
|
api, mctx
|
|
|
|
|
|
-let load_macro ctx cpath f p =
|
|
|
+let load_macro ctx display cpath f p =
|
|
|
(*
|
|
|
The time measured here takes into account both macro typing an init, but benchmarks
|
|
|
shows that - unless you re doing heavy statics vars init - the time is mostly spent in
|
|
@@ -4941,7 +4941,7 @@ let load_macro ctx cpath f p =
|
|
|
| _ -> cpath, None
|
|
|
) in
|
|
|
(* Temporarily enter display mode while typing the macro. *)
|
|
|
- if ctx.in_display then mctx.com.display <- ctx.com.display;
|
|
|
+ if display then mctx.com.display <- ctx.com.display;
|
|
|
let m = (try Hashtbl.find ctx.g.types_module cpath with Not_found -> cpath) in
|
|
|
let mloaded = Typeload.load_module mctx m p in
|
|
|
api.Interp.current_macro_module <- (fun() -> mloaded);
|
|
@@ -4980,15 +4980,7 @@ type macro_arg_type =
|
|
|
| MAOther
|
|
|
|
|
|
let type_macro ctx mode cpath f (el:Ast.expr list) p =
|
|
|
- let reset = if mode = MDisplay then begin
|
|
|
- let old = ctx.in_display in
|
|
|
- ctx.in_display <- true;
|
|
|
- (fun () -> ctx.in_display <- old)
|
|
|
- end else
|
|
|
- (fun () -> ())
|
|
|
- in
|
|
|
- let mctx, (margs,mret,mclass,mfield), call_macro = load_macro ctx cpath f p in
|
|
|
- reset();
|
|
|
+ let mctx, (margs,mret,mclass,mfield), call_macro = load_macro ctx (mode = MDisplay) cpath f p in
|
|
|
let mpos = mfield.cf_pos in
|
|
|
let ctexpr = { tpackage = ["haxe";"macro"]; tname = "Expr"; tparams = []; tsub = None } in
|
|
|
let expr = Typeload.load_instance mctx (ctexpr,p) false in
|
|
@@ -5169,7 +5161,7 @@ let type_macro ctx mode cpath f (el:Ast.expr list) p =
|
|
|
e
|
|
|
|
|
|
let call_macro ctx path meth args p =
|
|
|
- let mctx, (margs,_,mclass,mfield), call = load_macro ctx path meth p in
|
|
|
+ let mctx, (margs,_,mclass,mfield), call = load_macro ctx false path meth p in
|
|
|
let el, _ = unify_call_args mctx args margs t_dynamic p false false in
|
|
|
call (List.map (fun e -> try Interp.make_const e with Exit -> error "Parameter should be a constant" e.epos) el)
|
|
|
|