From 5b9609b47768dc6c2137dd7381a119e3e976bdf2 Mon Sep 17 00:00:00 2001 From: Rudy Ges Date: Wed, 18 Dec 2024 17:48:46 +0100 Subject: [PATCH] [macro] reification: do not apply @:pos to type path --- src/syntax/reification.ml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/syntax/reification.ml b/src/syntax/reification.ml index 83c7946f3c4..93802a7a408 100644 --- a/src/syntax/reification.ml +++ b/src/syntax/reification.ml @@ -123,8 +123,8 @@ let reify in_macro = ("name", (efield(ei,"name"),p)); ("sub", (efield(ei,"sub"),p)); ("params", ea); - ("pos", to_pos p); - ("posPath", to_pos ptp.pos_path); + ("pos", to_pos_obj p); + ("posPath", to_pos_obj ptp.pos_path); ] in to_obj fields p end else begin @@ -132,8 +132,8 @@ let reify in_macro = ("pack", to_array to_string t.tpackage p); ("name", to_string t.tname p); ("params", to_array to_tparam t.tparams p); - ("pos", to_pos p); - ("posPath", to_pos ptp.pos_path); + ("pos", to_pos_obj p); + ("posPath", to_pos_obj ptp.pos_path); ] in let fields = match t.tsub with None -> fields | Some s -> fields @ ["sub",to_string s p] in to_obj fields p @@ -226,11 +226,7 @@ let reify in_macro = ] in to_obj fields p ) m p - and to_pos p = - match !cur_pos with - | Some p -> - p - | None -> + and to_pos_obj p = 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 @@ -238,11 +234,15 @@ let reify in_macro = (EUntyped (ECall ((EConst (Ident "$__mk_pos__"),p),[file;pmin;pmax]),p),p) else to_obj [("file",file);("min",pmin);("max",pmax)] p + and to_pos p = + match !cur_pos with + | Some p -> p + | None -> to_pos_obj p and to_enc_pos p = match !cur_pos with | Some p -> p - | None when in_macro -> to_pos p - | None -> (ECall ((efield ((efield ((efield ((EConst (Ident "haxe"),p),"macro"),p),"Context"),p),"makePosition"),p),[to_pos p]),p) + | None when in_macro -> to_pos_obj p + | None -> (ECall ((efield ((efield ((efield ((EConst (Ident "haxe"),p),"macro"),p),"Context"),p),"makePosition"),p),[to_pos_obj p]),p) and to_expr_array a p = match a with | [EMeta ((Meta.Dollar "a",[],_),e1),_] -> (match fst e1 with EArrayDecl el -> to_expr_array el p | _ -> e1) | _ -> to_array to_expr a p