Skip to content

Commit 2254caf

Browse files
committed
tweak
1 parent 2449a0d commit 2254caf

13 files changed

+254
-918
lines changed

Diff for: jscomp/frontend/ast_external.ml

+55-52
Original file line numberDiff line numberDiff line change
@@ -116,61 +116,64 @@ let handleExternalInStru
116116
pval_prim;
117117
pval_attributes
118118
}} in
119+
let normal () =
120+
if not no_inline_cross_module then
121+
external_result
122+
else
123+
let open Ast_helper in
124+
Str.include_ ~loc
125+
(Incl.mk ~loc
126+
(Mod.constraint_ ~loc
127+
(Mod.structure ~loc
128+
[external_result])
129+
(Mty.signature ~loc [
130+
{
131+
psig_desc = Psig_value {
132+
prim with
133+
pval_type ;
134+
pval_prim = [];
135+
pval_attributes ;
136+
};
137+
psig_loc = loc
138+
}]))) in
119139
if !send_pipe then
120140
let [@warning "-8"] ((_::params) as args) = Ast_core_type.get_curry_labels pval_type in
121141
let arity = List.length args in
122-
let open Ast_helper in
123-
Str.include_ ~loc
124-
(Incl.mk ~loc
125-
(Mod.structure ~loc
126-
[external_result;
127-
Str.value
128-
~loc Nonrecursive [
129-
Vb.mk ~loc
130-
(Pat.var ~loc prim.pval_name)
142+
if arity = 1 then normal () else
143+
let open Ast_helper in
144+
Str.include_ ~loc
145+
(Incl.mk ~loc
146+
(Mod.structure ~loc
147+
[external_result;
148+
Str.value
149+
~loc Nonrecursive [
150+
Vb.mk ~loc
151+
(Pat.var ~loc prim.pval_name)
131152

132-
(let body = (Exp.apply ~loc
133-
(Exp.ident ~loc {txt = Lident prim.pval_name.txt; loc })
134-
(Ext_list.mapi args (fun i x ->
135-
match x with
136-
| Asttypes.Nolabel ->
137-
Asttypes.Nolabel, Exp.ident {txt = Lident ("arg"^string_of_int i); loc}
138-
| Labelled s
139-
| Optional s
140-
->
141-
x, Exp.ident {txt = Lident s ; loc}
142-
))
143-
) in
144-
snd @@
145-
Ext_list.fold_right
146-
params (0, Exp.fun_ Nolabel None (Pat.var ~loc { txt = "arg0"; loc} ) body) (
147-
fun arg (i, obj) ->
148-
i + 1, Exp.fun_ arg None
149-
(Pat.var ~loc {txt = (match arg with | Labelled s | Optional s -> s
150-
| Nolabel -> "arg" ^ string_of_int (arity - i - 1)); loc}) obj
151-
)
152-
)
153-
]
154-
])
155-
)
153+
(let body = (Exp.apply ~loc
154+
(Exp.ident ~loc {txt = Lident prim.pval_name.txt; loc })
155+
(Ext_list.mapi args (fun i x ->
156+
match x with
157+
| Asttypes.Nolabel ->
158+
Asttypes.Nolabel, Exp.ident {txt = Lident ("arg"^string_of_int i); loc}
159+
| Labelled s
160+
| Optional s
161+
->
162+
x, Exp.ident {txt = Lident s ; loc}
163+
))
164+
) in
165+
snd @@
166+
Ext_list.fold_right
167+
params (0, Exp.fun_ Nolabel None (Pat.var ~loc { txt = "arg0"; loc} ) body) (
168+
fun arg (i, obj) ->
169+
i + 1, Exp.fun_ arg None
170+
(Pat.var ~loc {txt = (match arg with | Labelled s | Optional s -> s
171+
| Nolabel -> "arg" ^ string_of_int (arity - i - 1)); loc}) obj
172+
)
173+
)
174+
]
175+
])
176+
)
156177
else
157-
if not no_inline_cross_module then
158-
external_result
159-
else
160-
let open Ast_helper in
161-
Str.include_ ~loc
162-
(Incl.mk ~loc
163-
(Mod.constraint_ ~loc
164-
(Mod.structure ~loc
165-
[external_result])
166-
(Mty.signature ~loc [
167-
{
168-
psig_desc = Psig_value {
169-
prim with
170-
pval_type ;
171-
pval_prim = [];
172-
pval_attributes ;
173-
};
174-
psig_loc = loc
175-
}])))
178+
normal()
176179

Diff for: jscomp/main/builtin_cmi_datasets.ml

+9-9
Large diffs are not rendered by default.

Diff for: jscomp/main/builtin_cmj_datasets.ml

+7-7
Large diffs are not rendered by default.

Diff for: jscomp/test/js_string_test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
var Mt = require("./mt.js");
4-
var Js_array = require("../../lib/js/js_array.js");
54
var Belt_Option = require("../../lib/js/belt_Option.js");
65
var Caml_option = require("../../lib/js/caml_option.js");
76

@@ -282,7 +281,9 @@ var suites_1 = {
282281
"hello ",
283282
undefined
284283
],
285-
_1: Belt_Option.map(Caml_option.null_to_opt("hello word".match(/hello (world)?/)), Js_array.copy)
284+
_1: Belt_Option.map(Caml_option.null_to_opt("hello word".match(/hello (world)?/)), (function (prim) {
285+
return prim.slice();
286+
}))
286287
};
287288
})
288289
],

Diff for: jscomp/test/js_typed_array_test.js

+32-32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: lib/4.06.1/unstable/js_compiler.ml

+74-73
Large diffs are not rendered by default.

Diff for: lib/4.06.1/whole_compiler.ml

+74-73
Large diffs are not rendered by default.

Diff for: lib/es6/js_array.js

-35
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ function fillRangeInPlace(arg1, start, end_, arg0) {
2828
return arg0.fill(arg1, start, end_);
2929
}
3030

31-
function pop(arg0) {
32-
return Caml_option.undefined_to_opt(arg0.pop());
33-
}
34-
3531
function push(arg1, arg0) {
3632
return arg0.push(arg1);
3733
}
@@ -40,18 +36,6 @@ function pushMany(arg1, arg0) {
4036
return Caml_splice_call.spliceObjApply(arg0, "push", [arg1]);
4137
}
4238

43-
function reverseInPlace(arg0) {
44-
return arg0.reverse();
45-
}
46-
47-
function shift(arg0) {
48-
return Caml_option.undefined_to_opt(arg0.shift());
49-
}
50-
51-
function sortInPlace(arg0) {
52-
return arg0.sort();
53-
}
54-
5539
function sortInPlaceWith(arg1, arg0) {
5640
return arg0.sort(Curry.__2(arg1));
5741
}
@@ -116,22 +100,10 @@ function slice(start, end_, arg0) {
116100
return arg0.slice(start, end_);
117101
}
118102

119-
function copy(arg0) {
120-
return arg0.slice();
121-
}
122-
123103
function sliceFrom(arg1, arg0) {
124104
return arg0.slice(arg1);
125105
}
126106

127-
function toString(arg0) {
128-
return arg0.toString();
129-
}
130-
131-
function toLocaleString(arg0) {
132-
return arg0.toLocaleString();
133-
}
134-
135107
function every(arg1, arg0) {
136108
return arg0.every(Curry.__1(arg1));
137109
}
@@ -213,12 +185,8 @@ export {
213185
fillInPlace ,
214186
fillFromInPlace ,
215187
fillRangeInPlace ,
216-
pop ,
217188
push ,
218189
pushMany ,
219-
reverseInPlace ,
220-
shift ,
221-
sortInPlace ,
222190
sortInPlaceWith ,
223191
spliceInPlace ,
224192
removeFromInPlace ,
@@ -234,10 +202,7 @@ export {
234202
lastIndexOf ,
235203
lastIndexOfFrom ,
236204
slice ,
237-
copy ,
238205
sliceFrom ,
239-
toString ,
240-
toLocaleString ,
241206
every ,
242207
everyi ,
243208
filter ,

Diff for: lib/es6/js_string.js

-30
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ function match_(arg1, arg0) {
6464
return Caml_option.null_to_opt(arg0.match(arg1));
6565
}
6666

67-
function normalize(arg0) {
68-
return arg0.normalize();
69-
}
70-
7167
function normalizeByForm(arg1, arg0) {
7268
return arg0.normalize(arg1);
7369
}
@@ -152,26 +148,6 @@ function substringToEnd(from, arg0) {
152148
return arg0.substring(from);
153149
}
154150

155-
function toLowerCase(arg0) {
156-
return arg0.toLowerCase();
157-
}
158-
159-
function toLocaleLowerCase(arg0) {
160-
return arg0.toLocaleLowerCase();
161-
}
162-
163-
function toUpperCase(arg0) {
164-
return arg0.toUpperCase();
165-
}
166-
167-
function toLocaleUpperCase(arg0) {
168-
return arg0.toLocaleUpperCase();
169-
}
170-
171-
function trim(arg0) {
172-
return arg0.trim();
173-
}
174-
175151
function anchor(arg1, arg0) {
176152
return arg0.anchor(arg1);
177153
}
@@ -196,7 +172,6 @@ export {
196172
lastIndexOfFrom ,
197173
localeCompare ,
198174
match_ ,
199-
normalize ,
200175
normalizeByForm ,
201176
repeat ,
202177
replace ,
@@ -218,11 +193,6 @@ export {
218193
substrAtMost ,
219194
substring ,
220195
substringToEnd ,
221-
toLowerCase ,
222-
toLocaleLowerCase ,
223-
toUpperCase ,
224-
toLocaleUpperCase ,
225-
trim ,
226196
anchor ,
227197
link ,
228198

0 commit comments

Comments
 (0)