Skip to content

Commit 476789a

Browse files
committed
tweak
1 parent 407d24b commit 476789a

File tree

5 files changed

+76
-104
lines changed

5 files changed

+76
-104
lines changed

jscomp/core/js_cmj_format.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,5 +248,9 @@ let pp_cmj
248248
type path = string
249249
type cmj_load_info = {
250250
cmj_table : t ;
251-
cmj_path : path ;
251+
cmj_path : path
252+
(*
253+
Note it is the package path we want
254+
for ES6_global module spec
255+
*)
252256
}

jscomp/core/lam_compile_env.ml

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,14 @@
2929

3030

3131

32-
(* module E = Js_exp_make
33-
module S = Js_stmt_make
34-
*)
32+
3533

3634
type env_value =
3735
| Ml of Js_cmj_format.cmj_load_info
38-
(* | Runtime of Js_cmj_load.cmj_load_info *)
39-
(**
40-
[Runtime (pure, path, cmj_format)]
41-
A built in module probably from our runtime primitives,
42-
so it does not have any [signature]
43-
44-
*)
4536
| External
46-
(** Also a js file, but this belong to third party
47-
*)
37+
(** Also a js file, but this belong to third party
38+
we never load runtime/*.cmj
39+
*)
4840

4941

5042

@@ -61,9 +53,11 @@ type ident_info = {
6153
*)
6254

6355

64-
56+
(** It stores module => env_value mapping
57+
*)
6558
let cached_tbl : env_value Lam_module_ident.Hash.t
6659
= Lam_module_ident.Hash.create 31
60+
6761
let (+>) = Lam_module_ident.Hash.add cached_tbl
6862

6963

@@ -99,11 +93,8 @@ let add_js_module
9993
let lam_module_ident =
10094
Lam_module_ident.of_external id module_name in
10195
match Lam_module_ident.Hash.find_key_opt cached_tbl lam_module_ident with
102-
| None ->
103-
Lam_module_ident.Hash.add
104-
cached_tbl
105-
lam_module_ident
106-
External;
96+
| None ->
97+
lam_module_ident +> External;
10798
id
10899
| Some old_key ->
109100
old_key.id
@@ -124,7 +115,6 @@ let query_external_id_info (module_id : Ident.t) (name : string) : ident_info =
124115
cmj_load_info.cmj_table
125116
| Some (Ml { cmj_table } )
126117
-> cmj_table
127-
(* | Some (Runtime _) -> assert false *)
128118
| Some External -> assert false in
129119
let arity , closed_lambda =
130120
Js_cmj_format.query_by_name cmj_table name
@@ -154,9 +144,7 @@ let get_package_path_from_cmj
154144
(cmj_path,
155145
Js_cmj_format.get_npm_package_path cmj_table,
156146
Js_cmj_format.get_cmj_case cmj_table )
157-
| Some (
158-
External (*|
159-
Runtime _ *) ) ->
147+
| Some External ->
160148
assert false
161149
(* called by {!Js_name_of_module_id.string_of_module_id}
162150
can not be External
@@ -166,8 +154,9 @@ let get_package_path_from_cmj
166154
| Runtime
167155
| External _ -> assert false
168156
| Ml ->
169-
let ({Js_cmj_format.cmj_table} as cmj_load_info) =
157+
let cmj_load_info =
170158
Js_cmj_load.find_cmj_exn (Lam_module_ident.name id ^ Literals.suffix_cmj) in
159+
let cmj_table = cmj_load_info.cmj_table in
171160
id +> Ml cmj_load_info;
172161
(cmj_load_info.cmj_path,
173162
Js_cmj_format.get_npm_package_path cmj_table,
@@ -204,10 +193,10 @@ let get_required_modules
204193
(hard_dependencies
205194
: Lam_module_ident.Hash_set.t) : Lam_module_ident.t list =
206195
Lam_module_ident.Hash.iter cached_tbl (fun id _ ->
207-
if not @@ is_pure_module id
196+
if not (is_pure_module id)
208197
then add hard_dependencies id);
209198
Lam_module_ident.Hash_set.iter extras (fun id ->
210-
(if not @@ is_pure_module id
199+
(if not (is_pure_module id)
211200
then add hard_dependencies id : unit)
212201
);
213202
Lam_module_ident.Hash_set.elements hard_dependencies

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -383094,7 +383094,11 @@ let pp_cmj
383094383094
type path = string
383095383095
type cmj_load_info = {
383096383096
cmj_table : t ;
383097-
cmj_path : path ;
383097+
cmj_path : path
383098+
(*
383099+
Note it is the package path we want
383100+
for ES6_global
383101+
*)
383098383102
}
383099383103
end
383100383104
module Builtin_cmj_datasets
@@ -388755,22 +388759,14 @@ end = struct
388755388759

388756388760

388757388761

388758-
(* module E = Js_exp_make
388759-
module S = Js_stmt_make
388760-
*)
388762+
388761388763

388762388764
type env_value =
388763388765
| Ml of Js_cmj_format.cmj_load_info
388764-
(* | Runtime of Js_cmj_load.cmj_load_info *)
388765-
(**
388766-
[Runtime (pure, path, cmj_format)]
388767-
A built in module probably from our runtime primitives,
388768-
so it does not have any [signature]
388769-
388770-
*)
388771388766
| External
388772-
(** Also a js file, but this belong to third party
388773-
*)
388767+
(** Also a js file, but this belong to third party
388768+
we never load runtime/*.cmj
388769+
*)
388774388770

388775388771

388776388772

@@ -388787,9 +388783,11 @@ type ident_info = {
388787388783
*)
388788388784

388789388785

388790-
388786+
(** It stores module => env_value mapping
388787+
*)
388791388788
let cached_tbl : env_value Lam_module_ident.Hash.t
388792388789
= Lam_module_ident.Hash.create 31
388790+
388793388791
let (+>) = Lam_module_ident.Hash.add cached_tbl
388794388792

388795388793

@@ -388825,11 +388823,8 @@ let add_js_module
388825388823
let lam_module_ident =
388826388824
Lam_module_ident.of_external id module_name in
388827388825
match Lam_module_ident.Hash.find_key_opt cached_tbl lam_module_ident with
388828-
| None ->
388829-
Lam_module_ident.Hash.add
388830-
cached_tbl
388831-
lam_module_ident
388832-
External;
388826+
| None ->
388827+
lam_module_ident +> External;
388833388828
id
388834388829
| Some old_key ->
388835388830
old_key.id
@@ -388850,7 +388845,6 @@ let query_external_id_info (module_id : Ident.t) (name : string) : ident_info =
388850388845
cmj_load_info.cmj_table
388851388846
| Some (Ml { cmj_table } )
388852388847
-> cmj_table
388853-
(* | Some (Runtime _) -> assert false *)
388854388848
| Some External -> assert false in
388855388849
let arity , closed_lambda =
388856388850
Js_cmj_format.query_by_name cmj_table name
@@ -388880,9 +388874,7 @@ let get_package_path_from_cmj
388880388874
(cmj_path,
388881388875
Js_cmj_format.get_npm_package_path cmj_table,
388882388876
Js_cmj_format.get_cmj_case cmj_table )
388883-
| Some (
388884-
External (*|
388885-
Runtime _ *) ) ->
388877+
| Some External ->
388886388878
assert false
388887388879
(* called by {!Js_name_of_module_id.string_of_module_id}
388888388880
can not be External
@@ -388892,8 +388884,9 @@ let get_package_path_from_cmj
388892388884
| Runtime
388893388885
| External _ -> assert false
388894388886
| Ml ->
388895-
let ({Js_cmj_format.cmj_table} as cmj_load_info) =
388887+
let cmj_load_info =
388896388888
Js_cmj_load.find_cmj_exn (Lam_module_ident.name id ^ Literals.suffix_cmj) in
388889+
let cmj_table = cmj_load_info.cmj_table in
388897388890
id +> Ml cmj_load_info;
388898388891
(cmj_load_info.cmj_path,
388899388892
Js_cmj_format.get_npm_package_path cmj_table,
@@ -388930,10 +388923,10 @@ let get_required_modules
388930388923
(hard_dependencies
388931388924
: Lam_module_ident.Hash_set.t) : Lam_module_ident.t list =
388932388925
Lam_module_ident.Hash.iter cached_tbl (fun id _ ->
388933-
if not @@ is_pure_module id
388926+
if not (is_pure_module id)
388934388927
then add hard_dependencies id);
388935388928
Lam_module_ident.Hash_set.iter extras (fun id ->
388936-
(if not @@ is_pure_module id
388929+
(if not (is_pure_module id)
388937388930
then add hard_dependencies id : unit)
388938388931
);
388939388932
Lam_module_ident.Hash_set.elements hard_dependencies

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -383094,7 +383094,11 @@ let pp_cmj
383094383094
type path = string
383095383095
type cmj_load_info = {
383096383096
cmj_table : t ;
383097-
cmj_path : path ;
383097+
cmj_path : path
383098+
(*
383099+
Note it is the package path we want
383100+
for ES6_global
383101+
*)
383098383102
}
383099383103
end
383100383104
module Builtin_cmj_datasets
@@ -388755,22 +388759,14 @@ end = struct
388755388759

388756388760

388757388761

388758-
(* module E = Js_exp_make
388759-
module S = Js_stmt_make
388760-
*)
388762+
388761388763

388762388764
type env_value =
388763388765
| Ml of Js_cmj_format.cmj_load_info
388764-
(* | Runtime of Js_cmj_load.cmj_load_info *)
388765-
(**
388766-
[Runtime (pure, path, cmj_format)]
388767-
A built in module probably from our runtime primitives,
388768-
so it does not have any [signature]
388769-
388770-
*)
388771388766
| External
388772-
(** Also a js file, but this belong to third party
388773-
*)
388767+
(** Also a js file, but this belong to third party
388768+
we never load runtime/*.cmj
388769+
*)
388774388770

388775388771

388776388772

@@ -388787,9 +388783,11 @@ type ident_info = {
388787388783
*)
388788388784

388789388785

388790-
388786+
(** It stores module => env_value mapping
388787+
*)
388791388788
let cached_tbl : env_value Lam_module_ident.Hash.t
388792388789
= Lam_module_ident.Hash.create 31
388790+
388793388791
let (+>) = Lam_module_ident.Hash.add cached_tbl
388794388792

388795388793

@@ -388825,11 +388823,8 @@ let add_js_module
388825388823
let lam_module_ident =
388826388824
Lam_module_ident.of_external id module_name in
388827388825
match Lam_module_ident.Hash.find_key_opt cached_tbl lam_module_ident with
388828-
| None ->
388829-
Lam_module_ident.Hash.add
388830-
cached_tbl
388831-
lam_module_ident
388832-
External;
388826+
| None ->
388827+
lam_module_ident +> External;
388833388828
id
388834388829
| Some old_key ->
388835388830
old_key.id
@@ -388850,7 +388845,6 @@ let query_external_id_info (module_id : Ident.t) (name : string) : ident_info =
388850388845
cmj_load_info.cmj_table
388851388846
| Some (Ml { cmj_table } )
388852388847
-> cmj_table
388853-
(* | Some (Runtime _) -> assert false *)
388854388848
| Some External -> assert false in
388855388849
let arity , closed_lambda =
388856388850
Js_cmj_format.query_by_name cmj_table name
@@ -388880,9 +388874,7 @@ let get_package_path_from_cmj
388880388874
(cmj_path,
388881388875
Js_cmj_format.get_npm_package_path cmj_table,
388882388876
Js_cmj_format.get_cmj_case cmj_table )
388883-
| Some (
388884-
External (*|
388885-
Runtime _ *) ) ->
388877+
| Some External ->
388886388878
assert false
388887388879
(* called by {!Js_name_of_module_id.string_of_module_id}
388888388880
can not be External
@@ -388892,8 +388884,9 @@ let get_package_path_from_cmj
388892388884
| Runtime
388893388885
| External _ -> assert false
388894388886
| Ml ->
388895-
let ({Js_cmj_format.cmj_table} as cmj_load_info) =
388887+
let cmj_load_info =
388896388888
Js_cmj_load.find_cmj_exn (Lam_module_ident.name id ^ Literals.suffix_cmj) in
388889+
let cmj_table = cmj_load_info.cmj_table in
388897388890
id +> Ml cmj_load_info;
388898388891
(cmj_load_info.cmj_path,
388899388892
Js_cmj_format.get_npm_package_path cmj_table,
@@ -388930,10 +388923,10 @@ let get_required_modules
388930388923
(hard_dependencies
388931388924
: Lam_module_ident.Hash_set.t) : Lam_module_ident.t list =
388932388925
Lam_module_ident.Hash.iter cached_tbl (fun id _ ->
388933-
if not @@ is_pure_module id
388926+
if not (is_pure_module id)
388934388927
then add hard_dependencies id);
388935388928
Lam_module_ident.Hash_set.iter extras (fun id ->
388936-
(if not @@ is_pure_module id
388929+
(if not (is_pure_module id)
388937388930
then add hard_dependencies id : unit)
388938388931
);
388939388932
Lam_module_ident.Hash_set.elements hard_dependencies

0 commit comments

Comments
 (0)