Skip to content

Commit 2405b97

Browse files
committed
renaming
1 parent b20ecf3 commit 2405b97

14 files changed

+52
-84
lines changed

jscomp/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ CORE_SRCS= js_runtime_modules \
278278
lam_compile_util \
279279
lam_id_kind \
280280
lam_stats \
281-
lam_compile_defs \
281+
lam_compile_context\
282282
js_map js_fold js_fold_basic js_pass_scope\
283283
js_op_util js_analyzer js_shake js_exp_make js_long js_of_lam_exception js_of_lam_module js_of_lam_array js_of_lam_block js_of_lam_string\
284284
js_of_lam_tuple js_of_lam_record js_of_lam_float_record js_arr lam_compile_const \

jscomp/all.depend

+12-12
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ core/lam_compile_util.cmi : core/js_op.cmx
301301
core/lam_id_kind.cmi : core/lam_arity.cmi core/lam.cmi
302302
core/lam_stats.cmi : core/lam_id_kind.cmi ext/ident_set.cmi \
303303
ext/ident_hashtbl.cmi
304-
core/lam_compile_defs.cmi : core/lam_stats.cmi core/lam.cmi core/j.cmx \
304+
core/lam_compile_context.cmi : core/lam_stats.cmi core/lam.cmi core/j.cmx \
305305
ext/ident_map.cmi
306306
core/js_fold_basic.cmi : core/lam_module_ident.cmi core/j.cmx \
307307
ext/ident_set.cmi
@@ -353,18 +353,18 @@ core/js_dump_program.cmi : core/js_packages_info.cmi core/j.cmx \
353353
ext/ext_pp.cmi
354354
core/js_pass_debug.cmi : core/j.cmx
355355
core/js_of_lam_option.cmi : core/j.cmx
356-
core/js_output.cmi : core/lam_compile_defs.cmi core/lam.cmi core/j.cmx
356+
core/js_output.cmi : core/lam_compile_context.cmi core/lam.cmi core/j.cmx
357357
core/lam_compile_global.cmi : core/lam.cmi core/j.cmx
358358
core/lam_dispatch_primitive.cmi : core/j.cmx
359359
core/lam_bounded_vars.cmi : core/lam.cmi ext/ident_hashtbl.cmi
360360
core/lam_beta_reduce.cmi : core/lam_stats.cmi core/lam_closure.cmi \
361361
core/lam.cmi ext/ident_map.cmi
362-
core/lam_compile_external_call.cmi : core/lam_compile_defs.cmi core/j.cmx \
362+
core/lam_compile_external_call.cmi : core/lam_compile_context.cmi core/j.cmx \
363363
syntax/ast_ffi_types.cmi syntax/ast_arg.cmi
364364
core/lam_compile_external_obj.cmi : core/j.cmx syntax/ast_arg.cmi
365-
core/lam_compile_primitive.cmi : core/lam_compile_defs.cmi core/lam.cmi \
365+
core/lam_compile_primitive.cmi : core/lam_compile_context.cmi core/lam.cmi \
366366
core/j.cmx
367-
core/lam_compile.cmi : core/lam_compile_defs.cmi core/lam.cmi \
367+
core/lam_compile.cmi : core/lam_compile_context.cmi core/lam.cmi \
368368
core/js_output.cmi core/j.cmx
369369
core/lam_pass_exits.cmi : core/lam.cmi
370370
core/lam_pass_count.cmi : core/lam.cmi ext/ident_hashtbl.cmi
@@ -430,9 +430,9 @@ core/lam_compile_util.cmx : core/js_op.cmx core/lam_compile_util.cmi
430430
core/lam_id_kind.cmx : core/lam_arity.cmx core/lam.cmx core/lam_id_kind.cmi
431431
core/lam_stats.cmx : core/lam_id_kind.cmx ext/ident_set.cmx \
432432
ext/ident_hashtbl.cmx core/lam_stats.cmi
433-
core/lam_compile_defs.cmx : core/lam_stats.cmx core/lam.cmx core/j.cmx \
433+
core/lam_compile_context.cmx : core/lam_stats.cmx core/lam.cmx core/j.cmx \
434434
ext/int_map.cmx ext/ident_map.cmx ext/ext_list.cmx \
435-
core/lam_compile_defs.cmi
435+
core/lam_compile_context.cmi
436436
core/js_map.cmx : core/j.cmx
437437
core/js_fold.cmx : core/j.cmx
438438
core/js_fold_basic.cmx : core/lam_module_ident.cmx \
@@ -560,7 +560,7 @@ core/js_pass_debug.cmx : core/js_dump_program.cmx common/js_config.cmx \
560560
core/js_pass_debug.cmi
561561
core/js_of_lam_option.cmx : core/js_runtime_modules.cmx core/js_exp_make.cmx \
562562
core/js_analyzer.cmx core/j.cmx core/js_of_lam_option.cmi
563-
core/js_output.cmx : core/lam_compile_defs.cmx core/lam_analysis.cmx \
563+
core/js_output.cmx : core/lam_compile_context.cmx core/lam_analysis.cmx \
564564
core/lam.cmx core/js_stmt_make.cmx core/js_exp_make.cmx core/js_dump.cmx \
565565
core/js_analyzer.cmx core/j.cmx ext/ext_list.cmx core/js_output.cmi
566566
core/lam_compile_global.cmx : core/type_util.cmx core/lam_module_ident.cmx \
@@ -580,7 +580,7 @@ core/lam_beta_reduce.cmx : core/lam_util.cmx core/lam_stats.cmx \
580580
core/lam_analysis.cmx core/lam.cmx ext/ident_map.cmx \
581581
ext/ident_hashtbl.cmx ext/ext_list.cmx core/lam_beta_reduce.cmi
582582
core/lam_compile_external_call.cmx : core/lam_compile_env.cmx \
583-
core/lam_compile_defs.cmx core/lam_compile_const.cmx \
583+
core/lam_compile_context.cmx core/lam_compile_const.cmx \
584584
core/js_runtime_modules.cmx core/js_of_lam_variant.cmx \
585585
core/js_of_lam_option.cmx core/js_exp_make.cmx core/js_arr.cmx \
586586
core/js_analyzer.cmx core/j.cmx ext/ext_list.cmx ext/ext_ident.cmx \
@@ -593,7 +593,7 @@ core/lam_compile_external_obj.cmx : core/lam_compile_external_call.cmx \
593593
core/lam_compile_external_obj.cmi
594594
core/lam_compile_primitive.cmx : core/lam_print.cmx \
595595
core/lam_dispatch_primitive.cmx core/lam_compile_external_call.cmx \
596-
core/lam_compile_defs.cmx core/lam.cmx core/js_runtime_modules.cmx \
596+
core/lam_compile_context.cmx core/lam.cmx core/js_runtime_modules.cmx \
597597
core/js_op_util.cmx core/js_of_lam_string.cmx core/js_of_lam_record.cmx \
598598
core/js_of_lam_option.cmx core/js_of_lam_float_record.cmx \
599599
core/js_of_lam_exception.cmx core/js_of_lam_block.cmx \
@@ -604,7 +604,7 @@ core/lam_compile.cmx : ext/literals.cmx core/lam_util.cmx \
604604
common/lam_methname.cmx core/lam_exit_code.cmx \
605605
core/lam_eta_conversion.cmx core/lam_compile_primitive.cmx \
606606
core/lam_compile_global.cmx core/lam_compile_external_obj.cmx \
607-
core/lam_compile_env.cmx core/lam_compile_defs.cmx \
607+
core/lam_compile_env.cmx core/lam_compile_context.cmx \
608608
core/lam_compile_const.cmx core/lam_closure.cmx core/lam_beta_reduce.cmx \
609609
core/lam_arity.cmx core/lam_analysis.cmx core/lam.cmx \
610610
core/js_stmt_make.cmx core/js_runtime_modules.cmx core/js_output.cmx \
@@ -642,7 +642,7 @@ core/lam_compile_main.cmx : ext/literals.cmx core/lam_util.cmx \
642642
core/lam_pass_exits.cmx core/lam_pass_deep_flatten.cmx \
643643
core/lam_pass_collect.cmx core/lam_pass_alpha_conversion.cmx \
644644
core/lam_module_ident.cmx core/lam_group.cmx core/lam_compile_env.cmx \
645-
core/lam_compile_defs.cmx core/lam_compile.cmx core/lam_coercion.cmx \
645+
core/lam_compile_context.cmx core/lam_compile.cmx core/lam_coercion.cmx \
646646
core/lam_analysis.cmx core/lam.cmx core/js_stmt_make.cmx \
647647
core/js_shake.cmx core/js_runtime_modules.cmx \
648648
core/js_pass_tailcall_inline.cmx core/js_pass_scope.cmx \

jscomp/bin/whole_compiler.ml

+3-19
Original file line numberDiff line numberDiff line change
@@ -88666,11 +88666,11 @@ type cxt = {
8866688666
meta : Lam_stats.t ;
8866788667
}
8866888668

88669-
val empty_handler_map : jmp_table
88669+
val empty_handler_map : jmp_table
8867088670

8867188671
val add_jmps :
8867288672
Ident.t * (jbl_label * 'a * Ident.t list) list ->
88673-
jmp_table -> jmp_table * (int * 'a) list
88673+
jmp_table -> jmp_table * (jbl_label * 'a) list
8867488674

8867588675
val find_exn : jbl_label -> cxt -> value
8867688676
end = struct
@@ -88702,17 +88702,8 @@ end = struct
8870288702

8870388703

8870488704

88705-
88706-
88707-
88708-
8870988705
type jbl_label = int
8871088706

88711-
(* module HandlerMap = Map.Make(struct
88712-
type t = jbl_label
88713-
let compare x y= compare (x : int) y
88714-
end )
88715-
*)
8871688707
module HandlerMap = Int_map
8871788708
type value = {
8871888709
exit_id : Ident.t ;
@@ -88758,20 +88749,13 @@ type cxt = {
8875888749
should_return : return_type;
8875988750
jmp_table : jmp_table;
8876088751
meta : Lam_stats.t ;
88761-
(* include_alias : *)
88762-
(* (\** It's correct to add more, we can do this in lambda optimization pass *)
88763-
(* *\) *)
88764-
(* (Ident.t , Ident.t) Hashtbl.t *)
88765-
(* Used when compiling [Lstaticraise] *)
8876688752
}
8876788753

8876888754
let empty_handler_map = HandlerMap.empty
8876988755

8877088756

8877188757

88772-
(*
88773-
always keep key id positive, specifically no [0] generated
88774-
*)
88758+
(* always keep key id positive, specifically no [0] generated *)
8877588759
let add_jmps (exit_id, code_table)
8877688760
(m : value HandlerMap.t) =
8877788761
let map, handlers =

jscomp/core/js_output.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type t = {
4646
*)
4747
}
4848

49-
type st = Lam_compile_defs.st
49+
type st = Lam_compile_context.st
5050

5151
let make ?value ?(finished=False) block = {block ; value ; finished }
5252

@@ -59,7 +59,7 @@ let dummy = {value = None; block = []; finished = Dummy }
5959

6060
let handle_name_tail
6161
(name : st)
62-
(should_return : Lam_compile_defs.return_type)
62+
(should_return : Lam_compile_context.return_type)
6363
lam (exp : J.expression) : t =
6464
begin match name, should_return with
6565
| EffectCall, ReturnFalse ->
@@ -79,7 +79,7 @@ let handle_name_tail
7979

8080
let handle_block_return
8181
(st : st)
82-
(should_return : Lam_compile_defs.return_type)
82+
(should_return : Lam_compile_context.return_type)
8383
(lam : Lam.t) (block : J.block) exp : t =
8484
match st, should_return with
8585
| Declare (kind,n), ReturnFalse ->

jscomp/core/js_output.mli

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
containing that step
3636
*)
3737

38-
type st = Lam_compile_defs.st
38+
type st = Lam_compile_context.st
3939

4040
type finished =
4141
| True
@@ -66,13 +66,13 @@ val dummy : t
6666

6767

6868
val handle_name_tail :
69-
Lam_compile_defs.st ->
70-
Lam_compile_defs.return_type ->
69+
Lam_compile_context.st ->
70+
Lam_compile_context.return_type ->
7171
Lam.t -> J.expression -> t
7272

7373
val handle_block_return :
74-
Lam_compile_defs.st ->
75-
Lam_compile_defs.return_type ->
74+
Lam_compile_context.st ->
75+
Lam_compile_context.return_type ->
7676
Lam.t ->
7777
J.block -> J.expression -> t
7878

jscomp/core/lam_compile.ml

+14-14
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ type default_case =
113113
*)
114114
let rec
115115
compile_external_field
116-
(cxt : Lam_compile_defs.cxt)
116+
(cxt : Lam_compile_context.cxt)
117117
lam
118118
(id : Ident.t)
119119
(pos : int)
@@ -164,7 +164,7 @@ let rec
164164
*)
165165

166166
and compile_external_field_apply
167-
(cxt : Lam_compile_defs.cxt)
167+
(cxt : Lam_compile_context.cxt)
168168
lam
169169
args_lambda
170170
(id : Ident.t)
@@ -237,7 +237,7 @@ and compile_external_field_apply
237237
args (List.length args ))
238238
)
239239

240-
and compile_let let_kind (cxt : Lam_compile_defs.cxt) id (arg : Lam.t) : Js_output.t =
240+
and compile_let let_kind (cxt : Lam_compile_context.cxt) id (arg : Lam.t) : Js_output.t =
241241
compile_lambda {cxt with st = Declare (let_kind, id); should_return = ReturnFalse } arg
242242
(**
243243
The second return values are values which need to be wrapped using
@@ -248,7 +248,7 @@ and compile_let let_kind (cxt : Lam_compile_defs.cxt) id (arg : Lam.t) : Js_out
248248
249249
*)
250250
and compile_recursive_let ~all_bindings
251-
(cxt : Lam_compile_defs.cxt)
251+
(cxt : Lam_compile_context.cxt)
252252
(id : Ident.t)
253253
(arg : Lam.t) : Js_output.t * Ident.t list =
254254
match arg with
@@ -264,7 +264,7 @@ and compile_recursive_let ~all_bindings
264264
*)
265265
Js_output.handle_name_tail (Declare (Alias, id)) ReturnFalse arg
266266
(
267-
let ret : Lam_compile_defs.return_label =
267+
let ret : Lam_compile_context.return_label =
268268
{id;
269269
label = continue_label;
270270
params;
@@ -276,7 +276,7 @@ and compile_recursive_let ~all_bindings
276276
{ cxt with
277277
st = EffectCall;
278278
should_return = ReturnTrue (Some ret );
279-
jmp_table = Lam_compile_defs.empty_handler_map} body in
279+
jmp_table = Lam_compile_context.empty_handler_map} body in
280280
if ret.triggered then
281281
let body_block = Js_output.to_block output in
282282
E.ocaml_fun
@@ -407,14 +407,14 @@ and compile_general_cases :
407407
'a .
408408
('a -> J.expression) ->
409409
(J.expression -> J.expression -> J.expression) ->
410-
Lam_compile_defs.cxt ->
410+
Lam_compile_context.cxt ->
411411
(?default:J.block ->
412412
?declaration:Lam.let_kind * Ident.t ->
413413
_ -> 'a J.case_clause list -> J.statement) ->
414414
_ ->
415415
('a * Lam.t) list -> default_case -> J.block
416416
= fun f eq cxt switch v table default ->
417-
let wrap (cxt : Lam_compile_defs.cxt) k =
417+
let wrap (cxt : Lam_compile_context.cxt) k =
418418
let cxt, define =
419419
match cxt.st with
420420
| Declare (kind, did)
@@ -494,7 +494,7 @@ and compile_string_cases cxt = compile_general_cases E.str E.string_equal cxt
494494
for high order currying *)
495495
and
496496
compile_lambda
497-
({st ; should_return; jmp_table; meta = {env ; _} } as cxt : Lam_compile_defs.cxt)
497+
({st ; should_return; jmp_table; meta = {env ; _} } as cxt : Lam_compile_context.cxt)
498498
(lam : Lam.t) : Js_output.t =
499499
begin
500500
match lam with
@@ -509,7 +509,7 @@ and
509509
( compile_lambda
510510
{ cxt with st = EffectCall;
511511
should_return = ReturnTrue None; (* Refine*)
512-
jmp_table = Lam_compile_defs.empty_handler_map} body)))
512+
jmp_table = Lam_compile_context.empty_handler_map} body)))
513513

514514

515515
| Lapply{
@@ -837,7 +837,7 @@ and
837837
( compile_lambda
838838
{ cxt with st = EffectCall;
839839
should_return = ReturnTrue None;
840-
jmp_table = Lam_compile_defs.empty_handler_map}
840+
jmp_table = Lam_compile_context.empty_handler_map}
841841
body)))
842842
| _ -> assert false
843843
end
@@ -1128,7 +1128,7 @@ and
11281128
if Ext_list.length_ge sw_blocks sw_numblocks
11291129
then Complete
11301130
else Default x in
1131-
let compile_whole ({st; _} as cxt : Lam_compile_defs.cxt ) =
1131+
let compile_whole ({st; _} as cxt : Lam_compile_context.cxt ) =
11321132
match sw_numconsts, sw_numblocks,
11331133
compile_lambda {cxt with should_return = ReturnFalse; st = NeedValue}
11341134
lam with
@@ -1178,7 +1178,7 @@ and
11781178
| Lstaticraise(i, largs) -> (* TODO handlding *largs*)
11791179
(* [i] is the jump table, [largs] is the arguments passed to [Lstaticcatch]*)
11801180
begin
1181-
match Lam_compile_defs.find_exn i cxt with
1181+
match Lam_compile_context.find_exn i cxt with
11821182
| {exit_id; args ; order_id} ->
11831183
let args_code =
11841184
(Js_output.concat @@ List.map2 (
@@ -1240,7 +1240,7 @@ and
12401240
(* TODO: handle NeedValue *)
12411241
let exit_id = Ext_ident.create_tmp ~name:"exit" () in
12421242
let exit_expr = E.var exit_id in
1243-
let jmp_table, handlers = Lam_compile_defs.add_jmps (exit_id, code_table) jmp_table in
1243+
let jmp_table, handlers = Lam_compile_context.add_jmps (exit_id, code_table) jmp_table in
12441244

12451245
(* Declaration First, body and handler have the same value *)
12461246
(* There is a bug in google closure compiler:

jscomp/core/lam_compile.mli

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333

3434
val compile_let :
3535
Lam.let_kind ->
36-
Lam_compile_defs.cxt ->
36+
Lam_compile_context.cxt ->
3737
J.ident ->
3838
Lam.t ->
3939
Js_output.t
4040

41-
val compile_recursive_lets : Lam_compile_defs.cxt -> (Ident.t * Lam.t) list -> Js_output.t
41+
val compile_recursive_lets : Lam_compile_context.cxt -> (Ident.t * Lam.t) list -> Js_output.t
4242

43-
val compile_lambda : Lam_compile_defs.cxt -> Lam.t -> Js_output.t
43+
val compile_lambda : Lam_compile_context.cxt -> Lam.t -> Js_output.t

jscomp/core/lam_compile_defs.ml jscomp/core/lam_compile_context.ml

+1-17
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,8 @@
2525

2626

2727

28-
29-
30-
31-
3228
type jbl_label = int
3329

34-
(* module HandlerMap = Map.Make(struct
35-
type t = jbl_label
36-
let compare x y= compare (x : int) y
37-
end )
38-
*)
3930
module HandlerMap = Int_map
4031
type value = {
4132
exit_id : Ident.t ;
@@ -81,20 +72,13 @@ type cxt = {
8172
should_return : return_type;
8273
jmp_table : jmp_table;
8374
meta : Lam_stats.t ;
84-
(* include_alias : *)
85-
(* (\** It's correct to add more, we can do this in lambda optimization pass *)
86-
(* *\) *)
87-
(* (Ident.t , Ident.t) Hashtbl.t *)
88-
(* Used when compiling [Lstaticraise] *)
8975
}
9076

9177
let empty_handler_map = HandlerMap.empty
9278

9379

9480

95-
(*
96-
always keep key id positive, specifically no [0] generated
97-
*)
81+
(* always keep key id positive, specifically no [0] generated *)
9882
let add_jmps (exit_id, code_table)
9983
(m : value HandlerMap.t) =
10084
let map, handlers =

jscomp/core/lam_compile_defs.mli jscomp/core/lam_compile_context.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ type cxt = {
8484
meta : Lam_stats.t ;
8585
}
8686

87-
val empty_handler_map : jmp_table
87+
val empty_handler_map : jmp_table
8888

8989
val add_jmps :
9090
Ident.t * (jbl_label * 'a * Ident.t list) list ->
91-
jmp_table -> jmp_table * (int * 'a) list
91+
jmp_table -> jmp_table * (jbl_label * 'a) list
9292

9393
val find_exn : jbl_label -> cxt -> value

0 commit comments

Comments
 (0)