Skip to content

Commit cbb72d8

Browse files
authored
flambda-backend: Improve debuginfo for for-loops (and conditionals) (#1870)
1 parent 19133b6 commit cbb72d8

File tree

5 files changed

+6
-1
lines changed

5 files changed

+6
-1
lines changed

lambda/lambda.ml

+1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ and lambda_while =
603603

604604
and lambda_for =
605605
{ for_id : Ident.t;
606+
for_loc : scoped_location;
606607
for_from : lambda;
607608
for_to : lambda;
608609
for_dir : direction_flag;

lambda/lambda.mli

+1
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ and lambda_while =
507507

508508
and lambda_for =
509509
{ for_id : Ident.t;
510+
for_loc : scoped_location;
510511
for_from : lambda;
511512
for_to : lambda;
512513
for_dir : direction_flag;

lambda/printlambda.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ let rec lam ppf = function
868868
| Lwhile {wh_cond; wh_body} ->
869869
fprintf ppf "@[<2>(while@ %a@ %a)@]"
870870
lam wh_cond lam wh_body
871-
| Lfor {for_id; for_from; for_to; for_dir; for_body} ->
871+
| Lfor {for_id; for_loc = _; for_from; for_to; for_dir; for_body} ->
872872
fprintf ppf "@[<2>(for %a@ %a@ %s@ %a@ %a)@]"
873873
Ident.print for_id lam for_from
874874
(match for_dir with Upto -> "to" | Downto -> "downto")

lambda/transl_array_comprehension.ml

+2
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ let iterator ~transl_exp ~scopes ~loc
456456
let stop = bound "stop" stop in
457457
let mk_iterator body =
458458
Lfor { for_id = ident
459+
; for_loc = loc
459460
; for_from = start.var
460461
; for_to = stop.var
461462
; for_dir = direction
@@ -483,6 +484,7 @@ let iterator ~transl_exp ~scopes ~loc
483484
(* for iter_ix = 0 to Array.length iter_arr - 1 ... *)
484485
(* CR layouts v4: will need updating when we allow non-values in arrays. *)
485486
Lfor { for_id = iter_ix
487+
; for_loc = loc
486488
; for_from = l0
487489
; for_to = iter_len.var - l1
488490
; for_dir = Upto

lambda/translcore.ml

+1
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
691691
let body = transl_exp ~scopes for_body_sort for_body in
692692
Lfor {
693693
for_id;
694+
for_loc = of_location ~scopes e.exp_loc;
694695
for_from = transl_exp ~scopes Jkind.Sort.for_predef_value for_from;
695696
for_to = transl_exp ~scopes Jkind.Sort.for_predef_value for_to;
696697
for_dir;

0 commit comments

Comments
 (0)