Skip to content

Commit 249eda3

Browse files
committed
Remove env as an argument
1 parent e7c20a0 commit 249eda3

File tree

12 files changed

+92
-110
lines changed

12 files changed

+92
-110
lines changed

jscomp/core/lam_compile_env.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,33 +161,33 @@ type _ t =
161161
let query_and_add_if_not_exist
162162
(type u)
163163
(oid : Lam_module_ident.t)
164-
~(found: bool -> _) =
164+
=
165165
match Lam_module_ident.Hash.find_opt cached_tbl oid with
166166
| None ->
167167
begin match oid.kind with
168168
| Runtime ->
169169
let (cmj_path, cmj_table) as cmj_info =
170170
Js_cmj_load.find_cmj_exn (Lam_module_ident.name oid ^ Literals.suffix_cmj) in
171171
oid +> Runtime {cmj_path;cmj_table} ;
172-
found (Js_cmj_format.is_pure cmj_table)
172+
Js_cmj_format.is_pure cmj_table
173173
| Ml
174174
->
175175
let (cmj_path, cmj_table) as cmj_info =
176176
Js_cmj_load.find_cmj_exn (Lam_module_ident.name oid ^ Literals.suffix_cmj) in
177177
oid +> Ml {cmj_table;cmj_path } ;
178-
found (Js_cmj_format.is_pure cmj_table)
178+
Js_cmj_format.is_pure cmj_table
179179
| External _ ->
180180
oid +> External;
181181
(** This might be wrong, if we happen to expand an js module
182182
we should assert false (but this in general should not happen)
183183
FIXME: #154, it come from External, should be okay
184184
*)
185-
found false
185+
false
186186
end
187187
| Some (Ml { cmj_table })
188188
| Some (Runtime {cmj_table}) ->
189-
found (Js_cmj_format.is_pure cmj_table)
190-
| Some External -> found false
189+
Js_cmj_format.is_pure cmj_table
190+
| Some External -> false
191191

192192

193193

@@ -228,7 +228,7 @@ let add = Lam_module_ident.Hash_set.add
228228
let is_pure_module (id : Lam_module_ident.t) =
229229
id.kind = Runtime ||
230230
query_and_add_if_not_exist id
231-
~found:(fun x -> x)
231+
232232

233233
let get_required_modules
234234
extras

jscomp/core/lam_compile_main.ml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ let no_side_effects (rest : Lam_group.t list) : string option =
117117
else None (* TODO :*))
118118

119119

120-
let _d = fun env s lam ->
120+
let _d = fun s lam ->
121121
#if undefined BS_RELEASE_BUILD then
122-
Lam_util.dump env s lam ;
122+
Lam_util.dump s lam ;
123123
Ext_log.dwarn ~__POS__ "START CHECKING PASS %s@." s;
124124
ignore @@ Lam_check.check !Location.input_name lam;
125125
Ext_log.dwarn ~__POS__ "FINISH CHECKING PASS %s@." s;
@@ -146,23 +146,23 @@ let compile
146146
let lam, may_required_modules = Lam_convert.convert export_ident_sets lam in
147147

148148
let _j = Js_pass_debug.dump in
149-
let lam = _d env "initial" lam in
149+
let lam = _d "initial" lam in
150150
let lam = Lam_pass_deep_flatten.deep_flatten lam in
151-
let lam = _d env "flatten0" lam in
151+
let lam = _d "flatten0" lam in
152152
let meta =
153-
Lam_pass_collect.count_alias_globals env
153+
Lam_pass_collect.count_alias_globals
154154
export_idents export_ident_sets lam in
155155
let lam =
156156
let lam =
157157
lam
158-
|> _d env "flattern1"
158+
|> _d "flattern1"
159159
|> Lam_pass_exits.simplify_exits
160-
|> _d env "simplyf_exits"
160+
|> _d "simplyf_exits"
161161
|> (fun lam -> Lam_pass_collect.collect_helper meta lam; lam)
162162
|> Lam_pass_remove_alias.simplify_alias meta
163-
|> _d env "simplify_alias"
163+
|> _d "simplify_alias"
164164
|> Lam_pass_deep_flatten.deep_flatten
165-
|> _d env "flatten2"
165+
|> _d "flatten2"
166166
in (* Inling happens*)
167167

168168
let () = Lam_pass_collect.collect_helper meta lam in
@@ -171,29 +171,29 @@ let compile
171171
let () = Lam_pass_collect.collect_helper meta lam in
172172
let lam =
173173
lam
174-
|> _d env "alpha_before"
174+
|> _d "alpha_before"
175175
|> Lam_pass_alpha_conversion.alpha_conversion meta
176-
|> _d env "alpha_after"
176+
|> _d "alpha_after"
177177
|> Lam_pass_exits.simplify_exits in
178178
let () = Lam_pass_collect.collect_helper meta lam in
179179

180180

181181
lam
182-
|> _d env "simplify_alias_before"
182+
|> _d "simplify_alias_before"
183183
|> Lam_pass_remove_alias.simplify_alias meta
184-
|> _d env "alpha_conversion"
184+
|> _d "alpha_conversion"
185185
|> Lam_pass_alpha_conversion.alpha_conversion meta
186-
|> _d env "before-simplify_lets"
186+
|> _d "before-simplify_lets"
187187
(* we should investigate a better way to put different passes : )*)
188188
|> Lam_pass_lets_dce.simplify_lets
189189

190-
|> _d env "before-simplify-exits"
190+
|> _d "before-simplify-exits"
191191
(* |> (fun lam -> Lam_pass_collect.collect_helper meta lam
192192
; Lam_pass_remove_alias.simplify_alias meta lam) *)
193193
(* |> Lam_group_pass.scc_pass
194194
|> _d "scc" *)
195195
|> Lam_pass_exits.simplify_exits
196-
|> _d env "simplify_lets"
196+
|> _d "simplify_lets"
197197
#if undefined BS_RELEASE_BUILD then
198198
|> (fun lam ->
199199
let () =

jscomp/core/lam_pass_collect.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,13 @@ let collect_helper (meta : Lam_stats.t) (lam : Lam.t) =
180180

181181

182182
let count_alias_globals
183-
env
184183
(export_idents : Ident.t list)
185184
(export_sets : Ident_set.t)
186185
(lam : Lam.t) : Lam_stats.t =
187186
let meta : Lam_stats.t =
188187
{alias_tbl = Ident_hashtbl.create 31 ;
189188
ident_tbl = Ident_hashtbl.create 31;
190-
191189
exports = export_idents;
192-
env;
193190
export_idents = export_sets;
194191
} in
195192
collect_helper meta lam ;

jscomp/core/lam_pass_collect.mli

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ val collect_helper : Lam_stats.t -> Lam.t -> unit
8181

8282
(** return a new [meta] *)
8383
val count_alias_globals :
84-
Env.t ->
8584
Ident.t list ->
8685
Ident_set.t ->
8786
Lam.t ->

jscomp/core/lam_print.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ let lambda_as_module env ppf (lam : Lam.t) =
595595
env_lambda env ppf lam;
596596
fprintf ppf "; lambda-failure"
597597

598-
let seriaize env (filename : string) (lam : Lam.t) : unit =
598+
let seriaize (filename : string) (lam : Lam.t) : unit =
599599
let ou = open_out filename in
600600
let old = Format.get_margin () in
601601
let () = Format.set_margin 10000 in

jscomp/core/lam_print.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ val primitive: Format.formatter -> Lam_primitive.t -> unit
3030

3131
val env_lambda : Env.t -> Format.formatter -> Lam.t -> unit
3232

33-
val seriaize : 'a -> string -> Lam.t -> unit
33+
val seriaize : string -> Lam.t -> unit
3434

3535
val lambda_to_string : Lam.t -> string
3636

jscomp/core/lam_stats.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ type ident_tbl = Lam_id_kind.t Ident_hashtbl.t
5454

5555

5656
type t = {
57-
env : Env.t;
5857
export_idents : Ident_set.t ;
5958
exports : Ident.t list ; (*It is kept since order matters? *)
60-
6159
alias_tbl : alias_tbl;
6260
ident_tbl : ident_tbl;
6361
(** we don't need count arities for all identifiers, for identifiers

jscomp/core/lam_stats.mli

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,9 @@ type ident_tbl = Lam_id_kind.t Ident_hashtbl.t
4343

4444

4545
type t = {
46-
env : Env.t;
4746
export_idents : Ident_set.t ;
4847
exports : Ident.t list ;
49-
alias_tbl : alias_tbl;
50-
51-
48+
alias_tbl : alias_tbl;
5249
ident_tbl : ident_tbl;
5350
(** we don't need count arities for all identifiers, for identifiers
5451
for sure it's not a function, there is no need to count them

jscomp/core/lam_util.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ let generate_label ?(name="") () =
224224
let log_counter = ref 0
225225

226226

227-
let dump env ext lam =
227+
let dump ext lam =
228228
#if BS_COMPILER_IN_BROWSER || BS_RELEASE_BUILD then
229229
()
230230
#else
@@ -234,7 +234,7 @@ let dump env ext lam =
234234
begin
235235
incr log_counter;
236236
Ext_log.dwarn ~__POS__ "\n@[[TIME:]%s: %f@]@." ext (Sys.time () *. 1000.);
237-
Lam_print.seriaize env
237+
Lam_print.seriaize
238238
(Ext_filename.new_extension
239239
!Location.input_name
240240
(Printf.sprintf ".%02d%s.lam" !log_counter ext)

jscomp/core/lam_util.mli

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ val generate_label : ?name:string -> unit -> J.label
7171

7272

7373
(** [dump] when {!Js_config.is_same_file}*)
74-
val dump : Env.t -> string -> Lam.t -> unit
74+
val dump :
75+
string ->
76+
Lam.t ->
77+
unit
7578

7679

7780
val not_function : Lam.t -> bool

0 commit comments

Comments
 (0)