Skip to content

Commit 573770a

Browse files
committed
Simplify Has_env/No_env
1 parent 5dd9c92 commit 573770a

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

jscomp/core/lam_compile_env.ml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ let query_external_id_info (module_id : Ident.t) (name : string) : ident_info =
149149
[Runtime]
150150
and [externals]*)
151151
type _ t =
152-
| No_env : (path * Js_cmj_format.t) t
152+
| No_env : bool t
153153
| Has_env : Env.t -> bool t (* Indicate it is pure or not *)
154154

155155

@@ -170,7 +170,7 @@ let query_and_add_if_not_exist
170170
| Has_env _ ->
171171
found true
172172
| No_env ->
173-
found cmj_info)
173+
found (Js_cmj_format.is_pure cmj_table))
174174
| Ml
175175
->
176176
let (cmj_path, cmj_table) as cmj_info =
@@ -185,7 +185,7 @@ let query_and_add_if_not_exist
185185
found (Js_cmj_format.is_pure cmj_table)
186186
end
187187
| No_env ->
188-
found cmj_info)
188+
found (Js_cmj_format.is_pure cmj_table))
189189

190190

191191
| External _ ->
@@ -198,7 +198,7 @@ let query_and_add_if_not_exist
198198
->
199199
found false
200200
| No_env ->
201-
found (Ext_string.empty, Js_cmj_format.no_pure_dummy)
201+
found false
202202
(* FIXME: #154, it come from External, should be okay *)
203203
end
204204

@@ -207,22 +207,22 @@ let query_and_add_if_not_exist
207207
begin match env with
208208
| Has_env _ ->
209209
found (Js_cmj_format.is_pure cmj_table)
210-
| No_env -> found (cmj_path,cmj_table)
210+
| No_env -> found (Js_cmj_format.is_pure cmj_table)
211211
end
212212

213213
| Some (Runtime {cmj_path; cmj_table}) ->
214214
begin match env with
215215
| Has_env _ ->
216216
found true
217217
| No_env ->
218-
found (cmj_path, cmj_table)
218+
found (Js_cmj_format.is_pure cmj_table)
219219
end
220220
| Some External ->
221221
begin match env with
222222
| Has_env _ ->
223223
found false
224224
| No_env ->
225-
found (Ext_string.empty, Js_cmj_format.no_pure_dummy) (* External is okay *)
225+
found false (* External is okay *)
226226
end
227227

228228

@@ -277,8 +277,7 @@ let is_pure_module (id : Lam_module_ident.t) =
277277
id.kind = Runtime ||
278278
query_and_add_if_not_exist id No_env
279279
~not_found:(fun _ -> false)
280-
~found:(fun (_,x) ->
281-
Js_cmj_format.is_pure x)
280+
~found:(fun x -> x)
282281

283282
let get_required_modules
284283
extras

jscomp/core/lam_compile_env.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ type path = string
3939

4040

4141
type _ t =
42-
| No_env : (path * Js_cmj_format.t) t
42+
| No_env : bool t
4343
| Has_env : Env.t -> bool t
4444

4545

lib/4.02.3/unstable/js_compiler.ml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96495,7 +96495,7 @@ type path = string
9649596495

9649696496

9649796497
type _ t =
96498-
| No_env : (path * Js_cmj_format.t) t
96498+
| No_env : bool t
9649996499
| Has_env : Env.t -> bool t
9650096500

9650196501

@@ -96729,7 +96729,7 @@ let query_external_id_info (module_id : Ident.t) (name : string) : ident_info =
9672996729
[Runtime]
9673096730
and [externals]*)
9673196731
type _ t =
96732-
| No_env : (path * Js_cmj_format.t) t
96732+
| No_env : bool t
9673396733
| Has_env : Env.t -> bool t (* Indicate it is pure or not *)
9673496734

9673596735

@@ -96750,7 +96750,7 @@ let query_and_add_if_not_exist
9675096750
| Has_env _ ->
9675196751
found true
9675296752
| No_env ->
96753-
found cmj_info)
96753+
found (Js_cmj_format.is_pure cmj_table))
9675496754
| Ml
9675596755
->
9675696756
let (cmj_path, cmj_table) as cmj_info =
@@ -96765,7 +96765,7 @@ let query_and_add_if_not_exist
9676596765
found (Js_cmj_format.is_pure cmj_table)
9676696766
end
9676796767
| No_env ->
96768-
found cmj_info)
96768+
found (Js_cmj_format.is_pure cmj_table))
9676996769

9677096770

9677196771
| External _ ->
@@ -96778,7 +96778,7 @@ let query_and_add_if_not_exist
9677896778
->
9677996779
found false
9678096780
| No_env ->
96781-
found (Ext_string.empty, Js_cmj_format.no_pure_dummy)
96781+
found false
9678296782
(* FIXME: #154, it come from External, should be okay *)
9678396783
end
9678496784

@@ -96787,22 +96787,22 @@ let query_and_add_if_not_exist
9678796787
begin match env with
9678896788
| Has_env _ ->
9678996789
found (Js_cmj_format.is_pure cmj_table)
96790-
| No_env -> found (cmj_path,cmj_table)
96790+
| No_env -> found (Js_cmj_format.is_pure cmj_table)
9679196791
end
9679296792

9679396793
| Some (Runtime {cmj_path; cmj_table}) ->
9679496794
begin match env with
9679596795
| Has_env _ ->
9679696796
found true
9679796797
| No_env ->
96798-
found (cmj_path, cmj_table)
96798+
found (Js_cmj_format.is_pure cmj_table)
9679996799
end
9680096800
| Some External ->
9680196801
begin match env with
9680296802
| Has_env _ ->
9680396803
found false
9680496804
| No_env ->
96805-
found (Ext_string.empty, Js_cmj_format.no_pure_dummy) (* External is okay *)
96805+
found false (* External is okay *)
9680696806
end
9680796807

9680896808

@@ -96857,8 +96857,7 @@ let is_pure_module (id : Lam_module_ident.t) =
9685796857
id.kind = Runtime ||
9685896858
query_and_add_if_not_exist id No_env
9685996859
~not_found:(fun _ -> false)
96860-
~found:(fun (_,x) ->
96861-
Js_cmj_format.is_pure x)
96860+
~found:(fun x -> x)
9686296861

9686396862
let get_required_modules
9686496863
extras

lib/4.02.3/whole_compiler.ml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84016,7 +84016,7 @@ type path = string
8401684016

8401784017

8401884018
type _ t =
84019-
| No_env : (path * Js_cmj_format.t) t
84019+
| No_env : bool t
8402084020
| Has_env : Env.t -> bool t
8402184021

8402284022

@@ -84250,7 +84250,7 @@ let query_external_id_info (module_id : Ident.t) (name : string) : ident_info =
8425084250
[Runtime]
8425184251
and [externals]*)
8425284252
type _ t =
84253-
| No_env : (path * Js_cmj_format.t) t
84253+
| No_env : bool t
8425484254
| Has_env : Env.t -> bool t (* Indicate it is pure or not *)
8425584255

8425684256

@@ -84271,7 +84271,7 @@ let query_and_add_if_not_exist
8427184271
| Has_env _ ->
8427284272
found true
8427384273
| No_env ->
84274-
found cmj_info)
84274+
found (Js_cmj_format.is_pure cmj_table))
8427584275
| Ml
8427684276
->
8427784277
let (cmj_path, cmj_table) as cmj_info =
@@ -84286,7 +84286,7 @@ let query_and_add_if_not_exist
8428684286
found (Js_cmj_format.is_pure cmj_table)
8428784287
end
8428884288
| No_env ->
84289-
found cmj_info)
84289+
found (Js_cmj_format.is_pure cmj_table))
8429084290

8429184291

8429284292
| External _ ->
@@ -84299,7 +84299,7 @@ let query_and_add_if_not_exist
8429984299
->
8430084300
found false
8430184301
| No_env ->
84302-
found (Ext_string.empty, Js_cmj_format.no_pure_dummy)
84302+
found false
8430384303
(* FIXME: #154, it come from External, should be okay *)
8430484304
end
8430584305

@@ -84308,22 +84308,22 @@ let query_and_add_if_not_exist
8430884308
begin match env with
8430984309
| Has_env _ ->
8431084310
found (Js_cmj_format.is_pure cmj_table)
84311-
| No_env -> found (cmj_path,cmj_table)
84311+
| No_env -> found (Js_cmj_format.is_pure cmj_table)
8431284312
end
8431384313

8431484314
| Some (Runtime {cmj_path; cmj_table}) ->
8431584315
begin match env with
8431684316
| Has_env _ ->
8431784317
found true
8431884318
| No_env ->
84319-
found (cmj_path, cmj_table)
84319+
found (Js_cmj_format.is_pure cmj_table)
8432084320
end
8432184321
| Some External ->
8432284322
begin match env with
8432384323
| Has_env _ ->
8432484324
found false
8432584325
| No_env ->
84326-
found (Ext_string.empty, Js_cmj_format.no_pure_dummy) (* External is okay *)
84326+
found false (* External is okay *)
8432784327
end
8432884328

8432984329

@@ -84378,8 +84378,7 @@ let is_pure_module (id : Lam_module_ident.t) =
8437884378
id.kind = Runtime ||
8437984379
query_and_add_if_not_exist id No_env
8438084380
~not_found:(fun _ -> false)
84381-
~found:(fun (_,x) ->
84382-
Js_cmj_format.is_pure x)
84381+
~found:(fun x -> x)
8438384382

8438484383
let get_required_modules
8438584384
extras

0 commit comments

Comments
 (0)