Skip to content

Commit 34301c2

Browse files
authored
Merge pull request #3792 from BuckleScript/simplify_global_module_compilation
Simplify global module compilation
2 parents c6f95d2 + aa5ca09 commit 34301c2

18 files changed

+56
-725
lines changed

jscomp/core/js_exp_make.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ let external_var_dot ?comment ~external_name:name ?dot (id : Ident.t) : t =
106106
{expression_desc = Var (Qualified(id, External name, dot)); comment }
107107

108108

109-
(* let ml_var ?comment (id : Ident.t) : t =
110-
{expression_desc = Var (Qualified (id, Ml, None)); comment} *)
109+
let ml_module_as_var ?comment (id : Ident.t) : t =
110+
{expression_desc = Var (Qualified (id, Ml, None)); comment}
111111

112112
(* Static_index .....................**)
113113
let runtime_call ?comment module_name fn_name args =

jscomp/core/js_exp_make.mli

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ val external_var_dot :
7575
Ident.t ->
7676
t
7777

78+
val ml_module_as_var :
79+
?comment:string ->
80+
Ident.t ->
81+
t
82+
7883
val runtime_call :
7984
?comment:string ->
8085
string -> (* module_name *)

jscomp/core/js_fold_basic.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class count_hard_dependencies =
5858
match vid with
5959
| Qualified (id,kind,_) ->
6060
add_lam_module_ident hard_dependencies (Lam_module_ident.mk kind id); self
61-
| Id id -> self
61+
| Id id ->
62+
self
6263
method! expression x : 'self_type =
6364
(* check {!Js_pass_scope} when making changes *)
6465
(match Js_block_runtime.check_additional_id x with

jscomp/core/lam_beta_reduce.ml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,7 @@ let propogate_beta_reduce
7979
| Some ident_info ->
8080
Ident_hashtbl.add meta.ident_tbl param ident_info
8181
end;
82-
arg
83-
| Lglobal_module ident
84-
->
85-
(* It's not completeness, its to make it sound..
86-
Pass global module as an argument
87-
*)
88-
Lam_compile_global.expand_global_module_as_lam ident meta.env
82+
arg
8983
(* alias meta param ident (Module (Global ident)) Strict *)
9084
| Lprim {primitive = Pmakeblock (_, _, Immutable) ;args ; _} ->
9185

@@ -143,10 +137,6 @@ let propogate_beta_reduce_with_map
143137
Ident_hashtbl.add meta.ident_tbl param ident_info
144138
end;
145139
arg
146-
| Lglobal_module ident
147-
->
148-
(* It's not completeness, its to make it sound.. *)
149-
Lam_compile_global.expand_global_module_as_lam ident meta.env
150140
(* alias meta param ident (Module (Global ident)) Strict *)
151141
| Lprim {primitive = Pmakeblock (_, _, Immutable ) ; args} ->
152142
Ident_hashtbl.replace meta.ident_tbl param

jscomp/core/lam_compile.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,9 +1565,9 @@ and compile_lambda
15651565
(* introduced by
15661566
1. {[ include Array --> let include = Array ]}
15671567
2. inline functor application
1568-
*)
1569-
let exp = Lam_compile_global.expand_global_module i lambda_cxt.meta.env in
1570-
Js_output.output_of_block_and_expression lambda_cxt.continuation [] exp
1568+
*)
1569+
Js_output.output_of_block_and_expression lambda_cxt.continuation []
1570+
(E.ml_module_as_var i )
15711571

15721572
| Lprim prim_info ->
15731573
compile_prim prim_info lambda_cxt

jscomp/core/lam_compile_global.ml

Lines changed: 0 additions & 74 deletions
This file was deleted.

jscomp/core/lam_compile_global.mli

Lines changed: 0 additions & 38 deletions
This file was deleted.

jscomp/core/ocaml_types.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
type t
3737

3838
val empty : t
39-
val length : t -> int
39+
4040

4141

4242

@@ -47,4 +47,4 @@ val find_serializable_signatures_by_path :
4747

4848
val get_name : t -> int -> string
4949

50-
val map : (string -> 'a) -> t -> 'a list
50+

jscomp/test/functor_app_test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ function eq(loc, x, y) {
2727
return /* () */0;
2828
}
2929

30-
var Y0 = Functor_def.Make(/* Functor_inst */{
31-
say: Functor_inst.say
32-
});
30+
var Y0 = Functor_def.Make(Functor_inst);
3331

34-
var Y1 = Functor_def.Make(/* Functor_inst */{
35-
say: Functor_inst.say
36-
});
32+
var Y1 = Functor_def.Make(Functor_inst);
3733

3834
eq("File \"functor_app_test.ml\", line 23, characters 6-13", Curry._2(Y0.h, 1, 2), 4);
3935

jscomp/test/module_alias_test.js

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,7 @@ function eq(loc, x, y) {
2727
}
2828

2929
function f(x) {
30-
var L = /* List */{
31-
length: List.length,
32-
hd: List.hd,
33-
tl: List.tl,
34-
nth: List.nth,
35-
rev: List.rev,
36-
append: List.append,
37-
rev_append: List.rev_append,
38-
concat: List.concat,
39-
flatten: List.flatten,
40-
iter: List.iter,
41-
iteri: List.iteri,
42-
map: List.map,
43-
mapi: List.mapi,
44-
rev_map: List.rev_map,
45-
fold_left: List.fold_left,
46-
fold_right: List.fold_right,
47-
iter2: List.iter2,
48-
map2: List.map2,
49-
rev_map2: List.rev_map2,
50-
fold_left2: List.fold_left2,
51-
fold_right2: List.fold_right2,
52-
for_all: List.for_all,
53-
exists: List.exists,
54-
for_all2: List.for_all2,
55-
exists2: List.exists2,
56-
mem: List.mem,
57-
memq: List.memq,
58-
find: List.find,
59-
filter: List.filter,
60-
find_all: List.find_all,
61-
partition: List.partition,
62-
assoc: List.assoc,
63-
assq: List.assq,
64-
mem_assoc: List.mem_assoc,
65-
mem_assq: List.mem_assq,
66-
remove_assoc: List.remove_assoc,
67-
remove_assq: List.remove_assq,
68-
split: List.split,
69-
combine: List.combine,
70-
sort: List.sort,
71-
stable_sort: List.stable_sort,
72-
fast_sort: List.fast_sort,
73-
sort_uniq: List.sort_uniq,
74-
merge: List.merge
75-
};
30+
var L = List;
7631
console.log(x);
7732
console.log(List.length(x));
7833
return L;

0 commit comments

Comments
 (0)