Skip to content

Commit fbae812

Browse files
committed
simplify query
1 parent 573770a commit fbae812

File tree

4 files changed

+24
-75
lines changed

4 files changed

+24
-75
lines changed

jscomp/core/lam_compile_env.ml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type _ t =
158158
let query_and_add_if_not_exist
159159
(type u)
160160
(oid : Lam_module_ident.t)
161-
(env : u t) ~not_found ~(found: u -> _) =
161+
(env : u t) ~not_found ~(found: bool -> _) =
162162
match Lam_module_ident.Hash.find_opt cached_tbl oid with
163163
| None ->
164164
begin match oid.kind with
@@ -192,38 +192,21 @@ let query_and_add_if_not_exist
192192
oid +> External;
193193
(** This might be wrong, if we happen to expand an js module
194194
we should assert false (but this in general should not happen)
195+
FIXME: #154, it come from External, should be okay
195196
*)
196-
begin match env with
197-
| Has_env _
198-
->
199-
found false
200-
| No_env ->
201-
found false
202-
(* FIXME: #154, it come from External, should be okay *)
203-
end
204-
205-
end
206-
| Some (Ml { cmj_table; cmj_path}) ->
207-
begin match env with
208-
| Has_env _ ->
209-
found (Js_cmj_format.is_pure cmj_table)
210-
| No_env -> found (Js_cmj_format.is_pure cmj_table)
197+
found false
211198
end
212-
199+
| Some (Ml { cmj_table; cmj_path}) ->
200+
found (Js_cmj_format.is_pure cmj_table)
213201
| Some (Runtime {cmj_path; cmj_table}) ->
214202
begin match env with
215203
| Has_env _ ->
216204
found true
217205
| No_env ->
218206
found (Js_cmj_format.is_pure cmj_table)
219207
end
220-
| Some External ->
221-
begin match env with
222-
| Has_env _ ->
223-
found false
224-
| No_env ->
225-
found false (* External is okay *)
226-
end
208+
| Some External -> found false
209+
227210

228211

229212

jscomp/core/lam_compile_env.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ val query_external_id_info :
9999
val query_and_add_if_not_exist :
100100
Lam_module_ident.t ->
101101
'a t -> not_found:(unit -> 'b) ->
102-
found:('a -> 'b) -> 'b
102+
found:(bool -> 'b) -> 'b
103103

104104
val is_pure_module : Lam_module_ident.t -> bool
105105

lib/4.02.3/unstable/js_compiler.ml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -96555,7 +96555,7 @@ val query_external_id_info :
9655596555
val query_and_add_if_not_exist :
9655696556
Lam_module_ident.t ->
9655796557
'a t -> not_found:(unit -> 'b) ->
96558-
found:('a -> 'b) -> 'b
96558+
found:(bool -> 'b) -> 'b
9655996559

9656096560
val is_pure_module : Lam_module_ident.t -> bool
9656196561

@@ -96738,7 +96738,7 @@ type _ t =
9673896738
let query_and_add_if_not_exist
9673996739
(type u)
9674096740
(oid : Lam_module_ident.t)
96741-
(env : u t) ~not_found ~(found: u -> _) =
96741+
(env : u t) ~not_found ~(found: bool -> _) =
9674296742
match Lam_module_ident.Hash.find_opt cached_tbl oid with
9674396743
| None ->
9674496744
begin match oid.kind with
@@ -96772,38 +96772,21 @@ let query_and_add_if_not_exist
9677296772
oid +> External;
9677396773
(** This might be wrong, if we happen to expand an js module
9677496774
we should assert false (but this in general should not happen)
96775+
FIXME: #154, it come from External, should be okay
9677596776
*)
96776-
begin match env with
96777-
| Has_env _
96778-
->
96779-
found false
96780-
| No_env ->
96781-
found false
96782-
(* FIXME: #154, it come from External, should be okay *)
96783-
end
96784-
96785-
end
96786-
| Some (Ml { cmj_table; cmj_path}) ->
96787-
begin match env with
96788-
| Has_env _ ->
96789-
found (Js_cmj_format.is_pure cmj_table)
96790-
| No_env -> found (Js_cmj_format.is_pure cmj_table)
96777+
found false
9679196778
end
96792-
96779+
| Some (Ml { cmj_table; cmj_path}) ->
96780+
found (Js_cmj_format.is_pure cmj_table)
9679396781
| Some (Runtime {cmj_path; cmj_table}) ->
9679496782
begin match env with
9679596783
| Has_env _ ->
9679696784
found true
9679796785
| No_env ->
9679896786
found (Js_cmj_format.is_pure cmj_table)
9679996787
end
96800-
| Some External ->
96801-
begin match env with
96802-
| Has_env _ ->
96803-
found false
96804-
| No_env ->
96805-
found false (* External is okay *)
96806-
end
96788+
| Some External -> found false
96789+
9680796790

9680896791

9680996792

lib/4.02.3/whole_compiler.ml

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -84076,7 +84076,7 @@ val query_external_id_info :
8407684076
val query_and_add_if_not_exist :
8407784077
Lam_module_ident.t ->
8407884078
'a t -> not_found:(unit -> 'b) ->
84079-
found:('a -> 'b) -> 'b
84079+
found:(bool -> 'b) -> 'b
8408084080

8408184081
val is_pure_module : Lam_module_ident.t -> bool
8408284082

@@ -84259,7 +84259,7 @@ type _ t =
8425984259
let query_and_add_if_not_exist
8426084260
(type u)
8426184261
(oid : Lam_module_ident.t)
84262-
(env : u t) ~not_found ~(found: u -> _) =
84262+
(env : u t) ~not_found ~(found: bool -> _) =
8426384263
match Lam_module_ident.Hash.find_opt cached_tbl oid with
8426484264
| None ->
8426584265
begin match oid.kind with
@@ -84293,38 +84293,21 @@ let query_and_add_if_not_exist
8429384293
oid +> External;
8429484294
(** This might be wrong, if we happen to expand an js module
8429584295
we should assert false (but this in general should not happen)
84296+
FIXME: #154, it come from External, should be okay
8429684297
*)
84297-
begin match env with
84298-
| Has_env _
84299-
->
84300-
found false
84301-
| No_env ->
84302-
found false
84303-
(* FIXME: #154, it come from External, should be okay *)
84304-
end
84305-
84306-
end
84307-
| Some (Ml { cmj_table; cmj_path}) ->
84308-
begin match env with
84309-
| Has_env _ ->
84310-
found (Js_cmj_format.is_pure cmj_table)
84311-
| No_env -> found (Js_cmj_format.is_pure cmj_table)
84298+
found false
8431284299
end
84313-
84300+
| Some (Ml { cmj_table; cmj_path}) ->
84301+
found (Js_cmj_format.is_pure cmj_table)
8431484302
| Some (Runtime {cmj_path; cmj_table}) ->
8431584303
begin match env with
8431684304
| Has_env _ ->
8431784305
found true
8431884306
| No_env ->
8431984307
found (Js_cmj_format.is_pure cmj_table)
8432084308
end
84321-
| Some External ->
84322-
begin match env with
84323-
| Has_env _ ->
84324-
found false
84325-
| No_env ->
84326-
found false (* External is okay *)
84327-
end
84309+
| Some External -> found false
84310+
8432884311

8432984312

8433084313

0 commit comments

Comments
 (0)