Skip to content

Commit bfd2553

Browse files
committed
Tweak find ml_id_pos
1 parent 9488bfb commit bfd2553

File tree

3 files changed

+78
-102
lines changed

3 files changed

+78
-102
lines changed

jscomp/core/lam_compile_env.ml

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ type env_value =
5656

5757

5858
type ident_info = {
59-
(* id : Ident.t; *)
6059
name : string;
6160
arity : Js_cmj_format.arity;
6261
closed_lambda : Lam.t option
@@ -89,16 +88,16 @@ let reset () =
8988
*)
9089
let add_js_module
9190
(hint_name : External_ffi_types.module_bind_name)
92-
module_name : Ident.t
91+
(module_name : string) : Ident.t
9392
=
9493
let id =
95-
Ident.create @@
94+
Ident.create
9695
(match hint_name with
9796
| Phint_name hint_name ->
98-
Ext_string.capitalize_ascii hint_name
99-
(* make sure the module name is capitalized
100-
TODO: maybe a warning if the user hint is not good
101-
*)
97+
Ext_string.capitalize_ascii hint_name
98+
(* make sure the module name is capitalized
99+
TODO: maybe a warning if the user hint is not good
100+
*)
102101
| Phint_nothing ->
103102
Ext_modulename.js_id_name_of_hint_name module_name
104103
)
@@ -122,33 +121,26 @@ let add_js_module
122121

123122
let cached_find_ml_id_pos (module_id : Ident.t) name : ident_info =
124123
let oid = Lam_module_ident.of_ml module_id in
125-
match Lam_module_ident.Hash.find_opt cached_tbl oid with
126-
| None ->
127-
let cmj_path, cmj_table =
128-
Js_cmj_load.find_cmj_exn (module_id.name ^ Literals.suffix_cmj) in
129-
oid +> Ml { cmj_table ; cmj_path } ;
130-
let arity, closed_lambda =
131-
Js_cmj_format.query_by_name cmj_table name
132-
in
133-
{
134-
name ;
135-
arity ;
136-
closed_lambda
137-
}
138-
139-
| Some (Ml { cmj_table } )
140-
->
141-
let arity , closed_lambda =
142-
Js_cmj_format.query_by_name cmj_table name
143-
in
144-
{
145-
name;
146-
arity;
147-
closed_lambda
148-
(* TODO shall we cache the arity ?*)
149-
}
150-
| Some (Runtime _) -> assert false
151-
| Some External -> assert false
124+
let cmj_table =
125+
match Lam_module_ident.Hash.find_opt cached_tbl oid with
126+
| None ->
127+
let cmj_path, cmj_table =
128+
Js_cmj_load.find_cmj_exn (module_id.name ^ Literals.suffix_cmj) in
129+
oid +> Ml { cmj_table ; cmj_path } ;
130+
cmj_table
131+
| Some (Ml { cmj_table } )
132+
-> cmj_table
133+
| Some (Runtime _) -> assert false
134+
| Some External -> assert false in
135+
let arity , closed_lambda =
136+
Js_cmj_format.query_by_name cmj_table name
137+
in
138+
{
139+
name;
140+
arity;
141+
closed_lambda
142+
(* TODO shall we cache the arity ?*)
143+
}
152144

153145

154146

lib/4.02.3/unstable/js_compiler.ml

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -96636,7 +96636,6 @@ type env_value =
9663696636

9663796637

9663896638
type ident_info = {
96639-
(* id : Ident.t; *)
9664096639
name : string;
9664196640
arity : Js_cmj_format.arity;
9664296641
closed_lambda : Lam.t option
@@ -96669,16 +96668,16 @@ let reset () =
9666996668
*)
9667096669
let add_js_module
9667196670
(hint_name : External_ffi_types.module_bind_name)
96672-
module_name : Ident.t
96671+
(module_name : string) : Ident.t
9667396672
=
9667496673
let id =
96675-
Ident.create @@
96674+
Ident.create
9667696675
(match hint_name with
9667796676
| Phint_name hint_name ->
96678-
Ext_string.capitalize_ascii hint_name
96679-
(* make sure the module name is capitalized
96680-
TODO: maybe a warning if the user hint is not good
96681-
*)
96677+
Ext_string.capitalize_ascii hint_name
96678+
(* make sure the module name is capitalized
96679+
TODO: maybe a warning if the user hint is not good
96680+
*)
9668296681
| Phint_nothing ->
9668396682
Ext_modulename.js_id_name_of_hint_name module_name
9668496683
)
@@ -96702,33 +96701,26 @@ let add_js_module
9670296701

9670396702
let cached_find_ml_id_pos (module_id : Ident.t) name : ident_info =
9670496703
let oid = Lam_module_ident.of_ml module_id in
96705-
match Lam_module_ident.Hash.find_opt cached_tbl oid with
96706-
| None ->
96707-
let cmj_path, cmj_table =
96708-
Js_cmj_load.find_cmj_exn (module_id.name ^ Literals.suffix_cmj) in
96709-
oid +> Ml { cmj_table ; cmj_path } ;
96710-
let arity, closed_lambda =
96711-
Js_cmj_format.query_by_name cmj_table name
96712-
in
96713-
{
96714-
name ;
96715-
arity ;
96716-
closed_lambda
96717-
}
96718-
96719-
| Some (Ml { cmj_table } )
96720-
->
96721-
let arity , closed_lambda =
96722-
Js_cmj_format.query_by_name cmj_table name
96723-
in
96724-
{
96725-
name;
96726-
arity;
96727-
closed_lambda
96728-
(* TODO shall we cache the arity ?*)
96729-
}
96730-
| Some (Runtime _) -> assert false
96731-
| Some External -> assert false
96704+
let cmj_table =
96705+
match Lam_module_ident.Hash.find_opt cached_tbl oid with
96706+
| None ->
96707+
let cmj_path, cmj_table =
96708+
Js_cmj_load.find_cmj_exn (module_id.name ^ Literals.suffix_cmj) in
96709+
oid +> Ml { cmj_table ; cmj_path } ;
96710+
cmj_table
96711+
| Some (Ml { cmj_table } )
96712+
-> cmj_table
96713+
| Some (Runtime _) -> assert false
96714+
| Some External -> assert false in
96715+
let arity , closed_lambda =
96716+
Js_cmj_format.query_by_name cmj_table name
96717+
in
96718+
{
96719+
name;
96720+
arity;
96721+
closed_lambda
96722+
(* TODO shall we cache the arity ?*)
96723+
}
9673296724

9673396725

9673496726

lib/4.02.3/whole_compiler.ml

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -84157,7 +84157,6 @@ type env_value =
8415784157

8415884158

8415984159
type ident_info = {
84160-
(* id : Ident.t; *)
8416184160
name : string;
8416284161
arity : Js_cmj_format.arity;
8416384162
closed_lambda : Lam.t option
@@ -84190,16 +84189,16 @@ let reset () =
8419084189
*)
8419184190
let add_js_module
8419284191
(hint_name : External_ffi_types.module_bind_name)
84193-
module_name : Ident.t
84192+
(module_name : string) : Ident.t
8419484193
=
8419584194
let id =
84196-
Ident.create @@
84195+
Ident.create
8419784196
(match hint_name with
8419884197
| Phint_name hint_name ->
84199-
Ext_string.capitalize_ascii hint_name
84200-
(* make sure the module name is capitalized
84201-
TODO: maybe a warning if the user hint is not good
84202-
*)
84198+
Ext_string.capitalize_ascii hint_name
84199+
(* make sure the module name is capitalized
84200+
TODO: maybe a warning if the user hint is not good
84201+
*)
8420384202
| Phint_nothing ->
8420484203
Ext_modulename.js_id_name_of_hint_name module_name
8420584204
)
@@ -84223,33 +84222,26 @@ let add_js_module
8422384222

8422484223
let cached_find_ml_id_pos (module_id : Ident.t) name : ident_info =
8422584224
let oid = Lam_module_ident.of_ml module_id in
84226-
match Lam_module_ident.Hash.find_opt cached_tbl oid with
84227-
| None ->
84228-
let cmj_path, cmj_table =
84229-
Js_cmj_load.find_cmj_exn (module_id.name ^ Literals.suffix_cmj) in
84230-
oid +> Ml { cmj_table ; cmj_path } ;
84231-
let arity, closed_lambda =
84232-
Js_cmj_format.query_by_name cmj_table name
84233-
in
84234-
{
84235-
name ;
84236-
arity ;
84237-
closed_lambda
84238-
}
84239-
84240-
| Some (Ml { cmj_table } )
84241-
->
84242-
let arity , closed_lambda =
84243-
Js_cmj_format.query_by_name cmj_table name
84244-
in
84245-
{
84246-
name;
84247-
arity;
84248-
closed_lambda
84249-
(* TODO shall we cache the arity ?*)
84250-
}
84251-
| Some (Runtime _) -> assert false
84252-
| Some External -> assert false
84225+
let cmj_table =
84226+
match Lam_module_ident.Hash.find_opt cached_tbl oid with
84227+
| None ->
84228+
let cmj_path, cmj_table =
84229+
Js_cmj_load.find_cmj_exn (module_id.name ^ Literals.suffix_cmj) in
84230+
oid +> Ml { cmj_table ; cmj_path } ;
84231+
cmj_table
84232+
| Some (Ml { cmj_table } )
84233+
-> cmj_table
84234+
| Some (Runtime _) -> assert false
84235+
| Some External -> assert false in
84236+
let arity , closed_lambda =
84237+
Js_cmj_format.query_by_name cmj_table name
84238+
in
84239+
{
84240+
name;
84241+
arity;
84242+
closed_lambda
84243+
(* TODO shall we cache the arity ?*)
84244+
}
8425384245

8425484246

8425584247

0 commit comments

Comments
 (0)