Skip to content

Commit 5aa3c90

Browse files
committed
meaningful names
1 parent df8508b commit 5aa3c90

15 files changed

+62
-62
lines changed

jscomp/core/lam.ml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ type apply_status =
3333
module Types = struct
3434

3535
type lambda_switch =
36-
{ sw_numconsts: bool; (* TODO: refine its representation *)
36+
{ sw_consts_full : bool; (* TODO: refine its representation *)
3737
sw_consts: (int * t) list;
38-
sw_numblocks: bool;
38+
sw_blocks_full : bool;
3939
sw_blocks: (int * t) list;
4040
sw_failaction : t option;
4141
sw_names : Lambda.switch_names option }
4242
(*
4343
Invariant:
44-
length (sw_consts) <= sw_numconsts
45-
when length (sw_consts) >= sw_numconsts -> true
44+
length (sw_consts) <= sw_consts_full
45+
when length (sw_consts) >= sw_consts_full -> true
4646
Note that failaction would appear in both
4747
{[
4848
match x with
@@ -55,16 +55,16 @@ module Types = struct
5555
5656
In most cases: {[
5757
let sw =
58-
{sw_numconsts = cstr.cstr_consts; sw_consts = consts;
59-
sw_numblocks = cstr.cstr_nonconsts; sw_blocks = nonconsts;
58+
{sw_consts_full = cstr.cstr_consts; sw_consts = consts;
59+
sw_blocks_full = cstr.cstr_nonconsts; sw_blocks = nonconsts;
6060
sw_failaction = None} in
6161
]}
6262
6363
but there are some edge cases (see https://caml.inria.fr/mantis/view.php?id=6033)
6464
one predicate used is
6565
{[
66-
(sw.sw_numconsts - List.length sw.sw_consts) +
67-
(sw.sw_numblocks - List.length sw.sw_blocks) > 1
66+
(sw.sw_consts_full - List.length sw.sw_consts) +
67+
(sw.sw_blocks_full - List.length sw.sw_blocks) > 1
6868
]}
6969
if [= 1] with [some fail] -- called once
7070
if [= 0] could not have [some fail]
@@ -111,9 +111,9 @@ module X = struct
111111
type lambda_switch
112112
= Types.lambda_switch
113113
=
114-
{ sw_numconsts: bool;
114+
{ sw_consts_full: bool;
115115
sw_consts: (int * t) list;
116-
sw_numblocks: bool;
116+
sw_blocks_full: bool;
117117
sw_blocks: (int * t) list;
118118
sw_failaction: t option;
119119
sw_names: Lambda.switch_names option }
@@ -190,12 +190,12 @@ let inner_map
190190
let args = Ext_list.map args f in
191191
Lprim { args; primitive; loc}
192192

193-
| Lswitch(arg, {sw_consts; sw_numconsts; sw_blocks; sw_numblocks; sw_failaction; sw_names}) ->
193+
| Lswitch(arg, {sw_consts; sw_consts_full; sw_blocks; sw_blocks_full; sw_failaction; sw_names}) ->
194194
let arg = f arg in
195195
let sw_consts = Ext_list.map_snd sw_consts f in
196196
let sw_blocks = Ext_list.map_snd sw_blocks f in
197197
let sw_failaction = Ext_option.map sw_failaction f in
198-
Lswitch(arg, { sw_consts; sw_blocks; sw_failaction; sw_numblocks; sw_numconsts; sw_names})
198+
Lswitch(arg, { sw_consts; sw_blocks; sw_failaction; sw_blocks_full; sw_consts_full; sw_names})
199199
| Lstringswitch (arg,cases,default) ->
200200
let arg = f arg in
201201
let cases = Ext_list.map_snd cases f in
@@ -757,14 +757,14 @@ let if_ (a : t) (b : t) (c : t) : t =
757757
->
758758
begin match c with
759759
| Lswitch ( Lvar yy as switch_arg,
760-
({sw_blocks = []; sw_numblocks = true; sw_consts ;
761-
sw_numconsts = _; sw_failaction = None} as body)
760+
({sw_blocks = []; sw_blocks_full = true; sw_consts ;
761+
sw_consts_full = _; sw_failaction = None} as body)
762762
)
763763
when Ident.same xx yy
764764
&& complete_range sw_consts ~start:0 ~finish:range
765765
->
766766
Lswitch(switch_arg,
767-
{ body with sw_failaction = Some b; sw_numconsts = false; })
767+
{ body with sw_failaction = Some b; sw_consts_full = false; })
768768
| _ -> Lifthenelse(a,b,c)
769769
end
770770
| _ -> Lifthenelse (a,b,c))

jscomp/core/lam.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
type ident = Ident.t
3030

3131
type lambda_switch =
32-
{ sw_numconsts: bool;
32+
{ sw_consts_full: bool;
3333
sw_consts: (int * t) list;
34-
sw_numblocks: bool;
34+
sw_blocks_full: bool;
3535
sw_blocks: (int * t) list;
3636
sw_failaction: t option;
3737
sw_names: Lambda.switch_names option }

jscomp/core/lam_arity_analysis.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ let rec get_arity (meta : Lam_stats.t) (lam : Lam.t) : Lam_arity.t =
111111
| Lswitch(_, {sw_failaction;
112112
sw_consts;
113113
sw_blocks;
114-
sw_numblocks = _;
115-
sw_numconsts = _;
114+
sw_blocks_full = _;
115+
sw_consts_full = _;
116116
}) ->
117117
all_lambdas meta (
118118
let rest =

jscomp/core/lam_bounded_vars.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,17 @@ let rewrite (map : _ Hash_ident.t)
118118
| Lswitch(l, {sw_failaction;
119119
sw_consts;
120120
sw_blocks;
121-
sw_numblocks;
122-
sw_numconsts;
121+
sw_blocks_full;
122+
sw_consts_full;
123123
sw_names;
124124
}) ->
125125
let l = aux l in
126126
Lam.switch l
127127
{sw_consts =
128128
Ext_list.map_snd sw_consts aux;
129129
sw_blocks = Ext_list.map_snd sw_blocks aux;
130-
sw_numconsts = sw_numconsts;
131-
sw_numblocks = sw_numblocks;
130+
sw_consts_full = sw_consts_full;
131+
sw_blocks_full = sw_blocks_full;
132132
sw_failaction = option_map sw_failaction;
133133
sw_names;
134134
}

jscomp/core/lam_check.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ let check file lam =
132132
iter_list_snd sw.sw_consts;
133133
iter_list_snd sw.sw_blocks;
134134
Ext_option.iter sw.sw_failaction iter;
135-
assert (not (sw.sw_failaction <> None && sw.sw_numconsts && sw.sw_numblocks))
135+
assert (not (sw.sw_failaction <> None && sw.sw_consts_full && sw.sw_blocks_full))
136136
| Lstringswitch (arg,cases,default) ->
137137
iter arg ;
138138
iter_list_snd cases ;

jscomp/core/lam_closure.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ let free_variables
102102
({sw_consts;
103103
sw_blocks;
104104
sw_failaction;
105-
sw_numconsts;
106-
sw_numblocks
105+
sw_consts_full;
106+
sw_blocks_full
107107
})) ->
108108
iter top arg;
109109
let top = Lam_var_stats.new_position_after_lam arg top in
@@ -112,7 +112,7 @@ let free_variables
112112
(match sw_failaction with
113113
| None -> ()
114114
| Some x ->
115-
if sw_numconsts || sw_numblocks
115+
if sw_consts_full || sw_blocks_full
116116
then iter top x
117117
else iter sink_pos x)
118118
| Lstringswitch (arg,cases,default) ->

jscomp/core/lam_compile.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,16 +589,16 @@ and compile_switch
589589
also if last statement is throw -- should we drop remaining
590590
statement?
591591
*)
592-
let ({sw_numconsts;
592+
let ({sw_consts_full;
593593
sw_consts;
594-
sw_numblocks;
594+
sw_blocks_full;
595595
sw_blocks;
596596
sw_failaction;
597597
sw_names } : Lam.lambda_switch) = sw in
598598
let sw_num_default =
599-
default_action ~saturated:sw_numconsts sw_failaction in
599+
default_action ~saturated:sw_consts_full sw_failaction in
600600
let sw_blocks_default =
601-
default_action ~saturated:sw_numblocks sw_failaction in
601+
default_action ~saturated:sw_blocks_full sw_failaction in
602602

603603
let get_name is_const i =
604604
match sw_names with
@@ -613,9 +613,9 @@ and compile_switch
613613
| {value = None; _} -> assert false
614614
| { block; value = Some e } ->
615615
block @
616-
(if sw_numconsts && sw_consts = [] then
616+
(if sw_consts_full && sw_consts = [] then
617617
compile_cases cxt (E.tag e) sw_blocks sw_blocks_default (get_name false)
618-
else if sw_numblocks && sw_blocks = [] then
618+
else if sw_blocks_full && sw_blocks = [] then
619619
compile_cases cxt e sw_consts sw_num_default (get_name true)
620620
else
621621
(* [e] will be used twice *)

jscomp/core/lam_convert.ml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -755,9 +755,9 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
755755
| Alias, Lprim {primitive = Poffsetint offset; args = [Lvar _ as matcher ]},
756756
Lswitch (Lvar switcher3 ,
757757
({
758-
sw_numconsts = false ;
758+
sw_consts_full = false ;
759759
sw_consts ;
760-
sw_blocks = []; sw_numblocks = true;
760+
sw_blocks = []; sw_blocks_full = true;
761761
sw_failaction = Some ifso
762762
} as px)
763763
)
@@ -795,9 +795,9 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
795795
| {
796796
sw_failaction = None ;
797797
sw_blocks = [];
798-
sw_numblocks = 0;
798+
sw_blocks_full = 0;
799799
sw_consts ;
800-
sw_numconsts ;
800+
sw_consts_full ;
801801
} ->
802802
begin match happens_to_be_diff sw_consts with
803803
| Some 0 -> e
@@ -810,19 +810,19 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
810810
Lam.switch e
811811
{sw_failaction = None;
812812
sw_blocks = [];
813-
sw_numblocks = true;
813+
sw_blocks_full = true;
814814
sw_consts =
815815
Ext_list.map_snd sw_consts convert_aux;
816-
sw_numconsts =
817-
Ext_list.length_ge sw_consts sw_numconsts;
816+
sw_consts_full =
817+
Ext_list.length_ge sw_consts sw_consts_full;
818818
sw_names = s.sw_names;
819819
}
820820
end
821821
| _ ->
822822
Lam.switch e
823-
{ sw_numconsts = Ext_list.length_ge s.sw_consts s.sw_numconsts ;
823+
{ sw_consts_full = Ext_list.length_ge s.sw_consts s.sw_consts_full ;
824824
sw_consts = Ext_list.map_snd s.sw_consts convert_aux;
825-
sw_numblocks = Ext_list.length_ge s.sw_blocks s.sw_numblocks;
825+
sw_blocks_full = Ext_list.length_ge s.sw_blocks s.sw_blocks_full;
826826
sw_blocks = Ext_list.map_snd s.sw_blocks convert_aux;
827827
sw_failaction =Ext_option.map s.sw_failaction convert_aux;
828828
sw_names = s.sw_names } in

jscomp/core/lam_exit_count.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ let incr_exit (exits : collection) i =
5050
For Lstringswitch ^
5151
5252
For Lswitch, if it is not exhuastive pattern match, default will be counted twice.
53-
Since for pattern match, we will test whether it is an integer or block, both have default cases predicate: [sw_numconsts] vs nconsts
53+
Since for pattern match, we will test whether it is an integer or block, both have default cases predicate: [sw_consts_full] vs nconsts
5454
*)
5555
let count_helper (lam : Lam.t) : collection =
5656
let exits : collection = Hash_int.create 17 in
@@ -90,7 +90,7 @@ let count_helper (lam : Lam.t) : collection =
9090
match sw.sw_failaction with
9191
| None -> ()
9292
| Some al ->
93-
if not sw.sw_numconsts && not sw.sw_numblocks
93+
if not sw.sw_consts_full && not sw.sw_blocks_full
9494
then
9595
(count al ; count al)
9696
else

jscomp/core/lam_iter.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let inner_iter (l : t) (f : t -> unit ) : unit =
4141
| Lletrec(decl, body) ->
4242
f body;
4343
Ext_list.iter_snd decl f
44-
| Lswitch(arg, {sw_consts; sw_numconsts = _ ; sw_blocks; sw_numblocks = _; sw_failaction}) ->
44+
| Lswitch(arg, {sw_consts; sw_consts_full = _ ; sw_blocks; sw_blocks_full = _; sw_failaction}) ->
4545
f arg;
4646
Ext_list.iter_snd sw_consts f;
4747
Ext_list.iter_snd sw_blocks f;
@@ -93,7 +93,7 @@ let inner_exists (l : t) (f : t -> bool) : bool =
9393
| Lletrec(decl, body) ->
9494
f body ||
9595
Ext_list.exists_snd decl f
96-
| Lswitch(arg, {sw_consts; sw_numconsts = _; sw_blocks; sw_numblocks = _; sw_failaction}) ->
96+
| Lswitch(arg, {sw_consts; sw_consts_full = _; sw_blocks; sw_blocks_full = _; sw_failaction}) ->
9797
f arg ||
9898
Ext_list.exists_snd sw_consts f ||
9999
Ext_list.exists_snd sw_blocks f ||

0 commit comments

Comments
 (0)