Skip to content

Commit d1ecd6b

Browse files
committed
Add location on new expression
1 parent f1f0d24 commit d1ecd6b

File tree

8 files changed

+17
-13
lines changed

8 files changed

+17
-13
lines changed

compiler/lib/generate.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ let rec translate_expr ctx queue loc x e level : _ * J.statement_list =
12321232
l
12331233
~init:([], mutator_p, queue)
12341234
in
1235-
( J.ENew (cc, if List.is_empty args then None else Some args)
1235+
( J.ENew (cc, (if List.is_empty args then None else Some args), loc)
12361236
, or_p pc prop
12371237
, queue )
12381238
| Extern "caml_js_get", [ Pv o; Pc (NativeString (Utf f)) ] when J.is_ident' f ->

compiler/lib/javascript.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ and expression =
280280
| EAccess of expression * access_kind * expression
281281
| EDot of expression * access_kind * identifier
282282
| EDotPrivate of expression * access_kind * identifier
283-
| ENew of expression * arguments option
283+
| ENew of expression * arguments option * location
284284
| EVar of ident
285285
| EFun of ident option * function_declaration
286286
| EClass of ident option * class_declaration

compiler/lib/javascript.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ and expression =
197197
| EAccess of expression * access_kind * expression
198198
| EDot of expression * access_kind * identifier
199199
| EDotPrivate of expression * access_kind * identifier
200-
| ENew of expression * arguments option
200+
| ENew of expression * arguments option * location
201201
| EVar of ident
202202
| EFun of ident option * function_declaration
203203
| EClass of ident option * class_declaration

compiler/lib/js_output.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,12 +854,13 @@ struct
854854
| ANormal -> PP.string f ".#"
855855
| ANullish -> PP.string f "?.#");
856856
PP.string f nm
857-
| ENew (e, None) ->
857+
| ENew (e, None, loc) ->
858858
if Prec.(l > NewExpression)
859859
then (
860860
PP.start_group f 1;
861861
PP.string f "(");
862862
PP.start_group f 1;
863+
output_debug_info f loc;
863864
PP.string f "new";
864865
PP.space f;
865866
expression NewExpression f e;
@@ -868,8 +869,9 @@ struct
868869
then (
869870
PP.string f ")";
870871
PP.end_group f)
871-
| ENew (e, Some el) ->
872+
| ENew (e, Some el, loc) ->
872873
PP.start_group f 1;
874+
output_debug_info f loc;
873875
PP.string f "new";
874876
PP.space f;
875877
expression MemberExpression f e;

compiler/lib/js_parser.mly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ call_expr(x):
906906

907907
new_expr(x):
908908
| e=member_expr(x) { e }
909-
| T_NEW e=new_expr(d1) { (ENew (e,None)) }
909+
| T_NEW e=new_expr(d1) { (ENew (e,None, p $symbolstartpos)) }
910910

911911
access:
912912
| "." { ANormal }
@@ -924,7 +924,7 @@ member_expr(x):
924924
| e1=member_expr(x) ak=access i=field_name
925925
{ (EDot(e1,ak,i)) }
926926
| T_NEW e1=member_expr(d1) a=arguments
927-
{ (ENew(e1, Some a)) }
927+
{ (ENew(e1, Some a, p $symbolstartpos)) }
928928
| e=member_expr(x) t=template_literal
929929
{ ECallTemplate(e, t, p $symbolstartpos) }
930930
| T_SUPER "[" e=expr "]"

compiler/lib/js_traverse.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ class map : mapper =
314314
| EAccess (e1, ak, e2) -> EAccess (m#expression e1, ak, m#expression e2)
315315
| EDot (e1, ak, id) -> EDot (m#expression e1, ak, id)
316316
| EDotPrivate (e1, ak, id) -> EDotPrivate (m#expression e1, ak, id)
317-
| ENew (e1, args) ->
318-
ENew (m#expression e1, Option.map ~f:(List.map ~f:m#argument) args)
317+
| ENew (e1, args, loc) ->
318+
ENew (m#expression e1, Option.map ~f:(List.map ~f:m#argument) args, m#loc loc)
319319
| EVar v -> EVar (m#ident v)
320320
| EFun (idopt, fun_decl) ->
321321
let idopt = Option.map ~f:m#ident idopt in
@@ -668,10 +668,10 @@ class iter : iterator =
668668
m#expression e2
669669
| EDot (e1, _ak, _) -> m#expression e1
670670
| EDotPrivate (e1, _, _) -> m#expression e1
671-
| ENew (e1, Some args) ->
671+
| ENew (e1, Some args, _) ->
672672
m#expression e1;
673673
List.iter args ~f:m#argument
674-
| ENew (e1, None) -> m#expression e1
674+
| ENew (e1, None, _) -> m#expression e1
675675
| EVar v -> m#ident v
676676
| EFun (idopt, fun_decl) ->
677677
(match idopt with

compiler/lib/wasm/wa_gc_target.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,8 @@ let () =
15591559
, Some
15601560
(List.map
15611561
~f:(fun x -> J.Arg (EVar (J.ident x)))
1562-
params) ))
1562+
params)
1563+
, N ))
15631564
, N )
15641565
, N )
15651566
]

compiler/lib/wasm/wa_link.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ let build_runtime_arguments
490490
(EStr
491491
(Utf8_string.of_string_exn
492492
(nm ^ " not implemented")))
493-
] ))
493+
]
494+
, N ))
494495
, N )
495496
]
496497
N

0 commit comments

Comments
 (0)