Skip to content

Commit 277f153

Browse files
committed
more verbose labels
1 parent 4a5190a commit 277f153

17 files changed

+280
-108
lines changed

jscomp/all.depend

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,9 +761,11 @@ super_errors/super_main.cmx : super_errors/super_typetexp.cmx \
761761
super_errors/super_env.cmx
762762
super_errors/super_reason_react.cmi :
763763
super_errors/super_misc.cmi :
764+
outcome_printer/reason_syntax_util.cmx :
764765
outcome_printer/outcome_printer_ns.cmx : ext/ext_namespace.cmx \
765766
outcome_printer/outcome_printer_ns.cmi
766-
outcome_printer/tweaked_reason_oprint.cmx :
767+
outcome_printer/tweaked_reason_oprint.cmx : \
768+
outcome_printer/reason_syntax_util.cmx
767769
outcome_printer/reason_outcome_printer_main.cmx : \
768770
outcome_printer/tweaked_reason_oprint.cmx
769771
outcome_printer/outcome_printer_ns.cmi :

jscomp/core/bs_conditional_initial.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
let setup_env () =
2727
#if BS_DEBUG then
28-
Js_config.set_debug_file "gpr_2352_test.ml";
28+
Js_config.set_debug_file "gpr_2413_test.ml";
2929
#end
3030
Lexer.replace_directive_bool "BS" true;
3131
Lexer.replace_directive_string "BS_VERSION" Bs_version.version

jscomp/core/j.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ and variable_declaration = {
379379
}
380380

381381
and 'a case_clause = {
382-
case : 'a ;
383-
body : block * bool ; (* true means break *)
382+
switch_case : 'a ;
383+
switch_body : block * bool ; (* true means break *)
384384
}
385385

386386
(* TODO: For efficency: block should not be a list, it should be able to

jscomp/core/js_dump.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ and pp_function method_
359359
and output_one : 'a .
360360
_ -> P.t -> (P.t -> 'a -> unit) -> 'a J.case_clause -> _
361361
= fun cxt f pp_cond
362-
({case = e; body = (sl,break)} : _ J.case_clause) ->
362+
({switch_case = e; switch_body = (sl,should_break)} : _ J.case_clause) ->
363363
let cxt =
364364
P.group f 1 @@ fun _ ->
365365
P.group f 1 @@ (fun _ ->
@@ -378,7 +378,7 @@ and output_one : 'a .
378378
P.newline f ;
379379
statement_list false cxt f sl
380380
in
381-
(if break then
381+
(if should_break then
382382
begin
383383
P.newline f ;
384384
P.string f L.break;

jscomp/core/js_fold.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class virtual fold =
461461
{[ goto : label option ; ]}
462462
*)
463463
'a. ('self_type -> 'a -> 'self_type) -> 'a case_clause -> 'self_type =
464-
fun _f_a { case = _x; body = _x_i1 } ->
464+
fun _f_a { switch_case = _x; switch_body = _x_i1 } ->
465465
let o = _f_a o _x in
466466
let o =
467467
(fun (_x, _x_i1) -> let o = o#block _x in let o = o#bool _x_i1 in o)

jscomp/core/js_map.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,13 @@ class virtual map =
512512
*)
513513
'a 'a_out.
514514
('self_type -> 'a -> 'a_out) -> 'a case_clause -> 'a_out case_clause =
515-
fun _f_a { case = _x; body = _x_i1 } ->
515+
fun _f_a { switch_case = _x; switch_body = _x_i1 } ->
516516
let _x = _f_a o _x in
517517
let _x_i1 =
518518
(fun (_x, _x_i1) ->
519519
let _x = o#block _x in let _x_i1 = o#bool _x_i1 in (_x, _x_i1))
520520
_x_i1
521-
in { case = _x; body = _x_i1; }
521+
in { switch_case = _x; switch_body = _x_i1; }
522522
method block : block -> block = (* true means break *)
523523
(* TODO: For efficency: block should not be a list, it should be able to
524524
be concatenated in both ways

jscomp/core/js_of_lam_variant.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ let eval (arg : J.expression) (dispatches : (int * string) list ) : E.t =
4040
E.of_block
4141
[(S.int_switch arg
4242
(Ext_list.map (fun (i,r) ->
43-
{J.case = i ;
44-
body = [S.return_stmt (E.str r)],
43+
{J.switch_case = i ;
44+
switch_body = [S.return_stmt (E.str r)],
4545
false (* FIXME: if true, still print break*)
4646
}) dispatches))]
4747

@@ -58,8 +58,8 @@ let eval_as_event (arg : J.expression) (dispatches : (int * string) list ) =
5858
(E.of_block
5959
[(S.int_switch (E.index arg 0l)
6060
(Ext_list.map (fun (i,r) ->
61-
{J.case = i ;
62-
body = [S.return_stmt (E.str r)],
61+
{J.switch_case = i ;
62+
switch_body = [S.return_stmt (E.str r)],
6363
false (* FIXME: if true, still print break*)
6464
}) dispatches))]
6565
, (* TODO: improve, one dispatch later,
@@ -86,8 +86,8 @@ let eval_as_int (arg : J.expression) (dispatches : (int * int) list ) : E.t =
8686
E.of_block
8787
[(S.int_switch arg
8888
(Ext_list.map (fun (i,r) ->
89-
{J.case = i ;
90-
body = [S.return_stmt (E.int (Int32.of_int r))],
89+
{J.switch_case = i ;
90+
switch_body = [S.return_stmt (E.int (Int32.of_int r))],
9191
false (* FIXME: if true, still print break*)
9292
}) dispatches))]
9393

jscomp/core/js_output.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ let to_break_block (x : t) : J.block * bool =
122122
TODO: check if it has side efects
123123
*)
124124
| { value = None; finished } ->
125-
block, (match finished with | True -> false | (False | Dummy) -> true )
125+
block,
126+
(match finished with | True -> false | (False | Dummy) -> true )
126127

127128
| {value = Some _ as opt; _} ->
128129
block_with_opt_expr block opt, true

jscomp/core/js_stmt_make.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ let int_switch ?comment ?declaration ?default (e : J.expression) clauses : t
100100
let continuation =
101101
begin match Ext_list.find_opt
102102
(fun (x : _ J.case_clause) ->
103-
if x.case = (Int32.to_int i) then Some (fst x.body) else None ) clauses
103+
if x.switch_case = (Int32.to_int i) then
104+
Some (fst x.switch_body) else None ) clauses
104105
with
105106
| Some case -> case
106107
| None ->
@@ -137,8 +138,8 @@ let string_switch ?comment ?declaration ?default (e : J.expression) clauses :
137138
let continuation =
138139
begin match Ext_list.find_opt
139140
(fun (x : string J.case_clause) ->
140-
if x.case = s then
141-
Some (fst x.body)
141+
if x.switch_case = s then
142+
Some (fst x.switch_body)
142143
else None
143144
) clauses
144145
with

jscomp/core/lam_compile.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,10 @@ and compile_general_cases :
480480
|> Ext_list.map_last
481481
(fun last (x,lam) ->
482482
if last
483-
then {J.case = x;
484-
body =
483+
then {J.switch_case = x;
484+
switch_body =
485485
Js_output.to_break_block (compile_lambda cxt lam) }
486-
else { case = x; body = [],false }))
486+
else { switch_case = x; switch_body = [],false }))
487487
(* TODO: we should also group default *)
488488
(* The last clause does not need [break]
489489
common break through, *)

0 commit comments

Comments
 (0)