Skip to content

Commit

Permalink
flambda-backend: Improve debuginfo for for-loops (and conditionals) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mshinwell authored Oct 6, 2023
1 parent 19133b6 commit cbb72d8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions lambda/lambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ and lambda_while =

and lambda_for =
{ for_id : Ident.t;
for_loc : scoped_location;
for_from : lambda;
for_to : lambda;
for_dir : direction_flag;
Expand Down
1 change: 1 addition & 0 deletions lambda/lambda.mli
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ and lambda_while =

and lambda_for =
{ for_id : Ident.t;
for_loc : scoped_location;
for_from : lambda;
for_to : lambda;
for_dir : direction_flag;
Expand Down
2 changes: 1 addition & 1 deletion lambda/printlambda.ml
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ let rec lam ppf = function
| Lwhile {wh_cond; wh_body} ->
fprintf ppf "@[<2>(while@ %a@ %a)@]"
lam wh_cond lam wh_body
| Lfor {for_id; for_from; for_to; for_dir; for_body} ->
| Lfor {for_id; for_loc = _; for_from; for_to; for_dir; for_body} ->
fprintf ppf "@[<2>(for %a@ %a@ %s@ %a@ %a)@]"
Ident.print for_id lam for_from
(match for_dir with Upto -> "to" | Downto -> "downto")
Expand Down
2 changes: 2 additions & 0 deletions lambda/transl_array_comprehension.ml
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ let iterator ~transl_exp ~scopes ~loc
let stop = bound "stop" stop in
let mk_iterator body =
Lfor { for_id = ident
; for_loc = loc
; for_from = start.var
; for_to = stop.var
; for_dir = direction
Expand Down Expand Up @@ -483,6 +484,7 @@ let iterator ~transl_exp ~scopes ~loc
(* for iter_ix = 0 to Array.length iter_arr - 1 ... *)
(* CR layouts v4: will need updating when we allow non-values in arrays. *)
Lfor { for_id = iter_ix
; for_loc = loc
; for_from = l0
; for_to = iter_len.var - l1
; for_dir = Upto
Expand Down
1 change: 1 addition & 0 deletions lambda/translcore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
let body = transl_exp ~scopes for_body_sort for_body in
Lfor {
for_id;
for_loc = of_location ~scopes e.exp_loc;
for_from = transl_exp ~scopes Jkind.Sort.for_predef_value for_from;
for_to = transl_exp ~scopes Jkind.Sort.for_predef_value for_to;
for_dir;
Expand Down

0 comments on commit cbb72d8

Please sign in to comment.