Skip to content

Commit 76d56c7

Browse files
committed
almost done
1 parent 7649d79 commit 76d56c7

19 files changed

+94
-98
lines changed

jscomp/core/lam.ml

+23-7
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,15 @@ let not_ loc x : t =
14181418
prim ~primitive:Pnot ~args:[x] loc
14191419

14201420

1421+
let has_boolean_type (x : t) =
1422+
match x with
1423+
| Lprim {primitive =
1424+
Pnot | Psequand |
1425+
Psequor | Pisout | Pintcomp _ | Pfloatcomp _;}
1426+
| Lprim {primitive = Pccall {prim_name = "caml_string_equal" | "caml_string_notequal"}}
1427+
-> true
1428+
| _ -> false
1429+
14211430
let if_ (a : t) (b : t) c =
14221431
match a with
14231432
| Lconst v ->
@@ -1445,14 +1454,21 @@ let if_ (a : t) (b : t) c =
14451454
| Const_immstring _ -> b
14461455
end
14471456
| _ ->
1448-
begin match a, b, c with
1449-
| Lprim {primitive = Pintcomp _;}, Lconst(Const_js_true), Lconst(Const_js_false)
1450-
-> a
1451-
| Lprim {primitive = Pintcomp _;loc}, Lconst(Const_js_false), Lconst(Const_js_true)
1452-
-> not_ loc a
1457+
1458+
begin match b, c with
1459+
| Lconst(Const_js_true), Lconst(Const_js_false)
1460+
->
1461+
if has_boolean_type a then a
1462+
else Lifthenelse (a,b,c)
1463+
| Lconst(Const_js_false), Lconst(Const_js_true)
1464+
->
1465+
if has_boolean_type a then
1466+
not_ Location.none a
1467+
else
1468+
Lifthenelse (a,b,c)
14531469
| _ ->
1454-
1455-
Lifthenelse (a,b,c)
1470+
Lifthenelse (a,b,c)
1471+
14561472
end
14571473

14581474

jscomp/test/bs_hashtbl_string_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function hash_string(s) {
1616
return Caml_hash_primitive.caml_hash_final_mix(Caml_hash_primitive.caml_hash_mix_string(0, s));
1717
}
1818

19-
var hashString = (function (str) {
19+
var hashString = function (str){ {
2020
var hash = 5381,
2121
i = str.length | 0;
2222

@@ -25,7 +25,7 @@ var hashString = (function (str) {
2525
}
2626
return hash
2727
}
28-
);
28+
};
2929

3030
var $$String = Belt_Id.hashable(Hashtbl.hash, (function (x, y) {
3131
return x === y;
@@ -342,4 +342,4 @@ exports.HI = HI;
342342
exports.bench6 = bench6;
343343
exports.S = S;
344344
exports.bench7 = bench7;
345-
/* hashString Not a pure module */
345+
/* String Not a pure module */

jscomp/test/bs_hashtbl_string_test.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ external final_mix : seed -> seed = "caml_hash_final_mix"
66
let hash_string s =
77
final_mix (caml_hash_mix_string 0 s)
88

9-
let hashString : string -> int = [%raw{|function (str) {
9+
let hashString : string -> int = fun%raw (str) -> {| {
1010
var hash = 5381,
1111
i = str.length | 0;
1212

@@ -15,7 +15,7 @@ let hashString : string -> int = [%raw{|function (str) {
1515
}
1616
return hash
1717
}
18-
|}]
18+
|}
1919

2020
module String =
2121
(val Belt.Id.hashable

jscomp/test/bs_mutable_set_test.js

+12-18
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ for(var i = 0 ,i_finish = r.length - 1 | 0; i <= i_finish; ++i){
5151
Belt_MutableSetInt.remove(u, r[i]);
5252
}
5353

54-
b("File \"bs_mutable_set_test.ml\", line 32, characters 4-11", Belt_internalAVLset.isEmpty(u.data));
54+
b("File \"bs_mutable_set_test.ml\", line 32, characters 4-11", Belt_MutableSetInt.isEmpty(u));
5555

5656
Belt_MutableSetInt.add(u, 0);
5757

@@ -63,13 +63,13 @@ Belt_MutableSetInt.add(u, 0);
6363

6464
eq("File \"bs_mutable_set_test.ml\", line 37, characters 5-12", Belt_internalAVLset.size(u.data), 3);
6565

66-
b("File \"bs_mutable_set_test.ml\", line 38, characters 4-11", !Belt_internalAVLset.isEmpty(u.data));
66+
b("File \"bs_mutable_set_test.ml\", line 38, characters 4-11", !Belt_MutableSetInt.isEmpty(u));
6767

6868
for(var i$1 = 0; i$1 <= 3; ++i$1){
6969
Belt_MutableSetInt.remove(u, i$1);
7070
}
7171

72-
b("File \"bs_mutable_set_test.ml\", line 42, characters 4-11", Belt_internalAVLset.isEmpty(u.data));
72+
b("File \"bs_mutable_set_test.ml\", line 42, characters 4-11", Belt_MutableSetInt.isEmpty(u));
7373

7474
Belt_MutableSetInt.mergeMany(u, Array_data_util.randomRange(0, 20000));
7575

@@ -101,7 +101,7 @@ b("File \"bs_mutable_set_test.ml\", line 56, characters 4-11", Belt_internalSetI
101101

102102
Belt_MutableSetInt.removeMany(u, Array_data_util.randomRange(10000, 30000));
103103

104-
b("File \"bs_mutable_set_test.ml\", line 58, characters 4-11", Belt_internalAVLset.isEmpty(u.data));
104+
b("File \"bs_mutable_set_test.ml\", line 58, characters 4-11", Belt_MutableSetInt.isEmpty(u));
105105

106106
var xs$1 = Array_data_util.randomRange(1000, 2000);
107107

@@ -141,11 +141,9 @@ eq("File \"bs_mutable_set_test.ml\", line 69, characters 5-12", indeedAded, 1000
141141

142142
eq("File \"bs_mutable_set_test.ml\", line 70, characters 5-12", Belt_internalAVLset.size(v.data), 1501);
143143

144-
var d = {
145-
data: Belt_internalAVLset.empty
146-
};
147-
148-
b("File \"bs_mutable_set_test.ml\", line 71, characters 4-11", Belt_internalAVLset.isEmpty(d.data));
144+
b("File \"bs_mutable_set_test.ml\", line 71, characters 4-11", Belt_MutableSetInt.isEmpty({
145+
data: Belt_internalAVLset.empty
146+
}));
149147

150148
eq("File \"bs_mutable_set_test.ml\", line 72, characters 5-12", Belt_internalAVLset.minimum(v.data), /* Some */[500]);
151149

@@ -193,9 +191,7 @@ b("File \"bs_mutable_set_test.ml\", line 86, characters 5-12", Belt_MutableSetIn
193191

194192
b("File \"bs_mutable_set_test.ml\", line 87, characters 4-11", Belt_MutableSetInt.subset(bb, v));
195193

196-
var d$1 = Belt_MutableSetInt.intersect(aa, bb);
197-
198-
b("File \"bs_mutable_set_test.ml\", line 88, characters 4-11", Belt_internalAVLset.isEmpty(d$1.data));
194+
b("File \"bs_mutable_set_test.ml\", line 88, characters 4-11", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa, bb)));
199195

200196
var c = Belt_MutableSetInt.removeCheck(v, 1000);
201197

@@ -219,9 +215,7 @@ b("File \"bs_mutable_set_test.ml\", line 95, characters 5-12", Belt_MutableSetIn
219215

220216
b("File \"bs_mutable_set_test.ml\", line 96, characters 4-11", Belt_MutableSetInt.subset(bb$1, v));
221217

222-
var d$2 = Belt_MutableSetInt.intersect(aa$1, bb$1);
223-
224-
b("File \"bs_mutable_set_test.ml\", line 97, characters 4-11", Belt_internalAVLset.isEmpty(d$2.data));
218+
b("File \"bs_mutable_set_test.ml\", line 97, characters 4-11", Belt_MutableSetInt.isEmpty(Belt_MutableSetInt.intersect(aa$1, bb$1)));
225219

226220
var xs$2 = Array_data_util.randomRange(0, 100);
227221

@@ -465,7 +459,7 @@ for(var i$4 = 0 ,i_finish$2 = vv.length - 1 | 0; i$4 <= i_finish$2; ++i$4){
465459

466460
eq("File \"bs_mutable_set_test.ml\", line 206, characters 5-12", Belt_internalAVLset.size(v$3.data), 0);
467461

468-
b("File \"bs_mutable_set_test.ml\", line 207, characters 4-11", Belt_internalAVLset.isEmpty(v$3.data));
462+
b("File \"bs_mutable_set_test.ml\", line 207, characters 4-11", Belt_MutableSetInt.isEmpty(v$3));
469463

470464
var xs$25 = Belt_Array.makeBy(30, (function (i) {
471465
return i;
@@ -646,11 +640,11 @@ var xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), (function (x) {
646640
return (x << 1);
647641
}));
648642

649-
var d$3 = {
643+
var d = {
650644
data: Belt_internalSetInt.fromArray(xs$30)
651645
};
652646

653-
var match$8 = Belt_MutableSetInt.split(d$3, 1001);
647+
var match$8 = Belt_MutableSetInt.split(d, 1001);
654648

655649
var match$9 = match$8[0];
656650

jscomp/test/bs_poly_mutable_map_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ eq("File \"bs_poly_mutable_map_test.ml\", line 29, characters 7-14", Belt_intern
6969

7070
Belt_MutableMap.removeMany(a0, Array_data_util.randomRange(0, 100));
7171

72-
b("File \"bs_poly_mutable_map_test.ml\", line 31, characters 6-13", Belt_internalAVLtree.isEmpty(a0.data));
72+
b("File \"bs_poly_mutable_map_test.ml\", line 31, characters 6-13", Belt_MutableMap.isEmpty(a0));
7373

7474
Mt.from_pair_suites("bs_poly_mutable_map_test.ml", suites[0]);
7575

jscomp/test/bs_poly_mutable_set_test.js

+10-16
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ for(var i = 0 ,i_finish = r.length - 1 | 0; i <= i_finish; ++i){
5959
Belt_MutableSet.remove(u, r[i]);
6060
}
6161

62-
b("File \"bs_poly_mutable_set_test.ml\", line 30, characters 4-11", Belt_internalAVLset.isEmpty(u.data));
62+
b("File \"bs_poly_mutable_set_test.ml\", line 30, characters 4-11", Belt_MutableSet.isEmpty(u));
6363

6464
Belt_MutableSet.add(u, 0);
6565

@@ -71,13 +71,13 @@ Belt_MutableSet.add(u, 0);
7171

7272
eq("File \"bs_poly_mutable_set_test.ml\", line 35, characters 5-12", Belt_internalAVLset.size(u.data), 3);
7373

74-
b("File \"bs_poly_mutable_set_test.ml\", line 36, characters 4-11", !Belt_internalAVLset.isEmpty(u.data));
74+
b("File \"bs_poly_mutable_set_test.ml\", line 36, characters 4-11", !Belt_MutableSet.isEmpty(u));
7575

7676
for(var i$1 = 0; i$1 <= 3; ++i$1){
7777
Belt_MutableSet.remove(u, i$1);
7878
}
7979

80-
b("File \"bs_poly_mutable_set_test.ml\", line 40, characters 4-11", Belt_internalAVLset.isEmpty(u.data));
80+
b("File \"bs_poly_mutable_set_test.ml\", line 40, characters 4-11", Belt_MutableSet.isEmpty(u));
8181

8282
Belt_MutableSet.mergeMany(u, Array_data_util.randomRange(0, 20000));
8383

@@ -109,7 +109,7 @@ b("File \"bs_poly_mutable_set_test.ml\", line 54, characters 4-11", Belt_Mutable
109109

110110
Belt_MutableSet.removeMany(u, Array_data_util.randomRange(10000, 30000));
111111

112-
b("File \"bs_poly_mutable_set_test.ml\", line 56, characters 4-11", Belt_internalAVLset.isEmpty(u.data));
112+
b("File \"bs_poly_mutable_set_test.ml\", line 56, characters 4-11", Belt_MutableSet.isEmpty(u));
113113

114114
var v = fromArray(Array_data_util.randomRange(1000, 2000));
115115

@@ -145,12 +145,10 @@ eq("File \"bs_poly_mutable_set_test.ml\", line 67, characters 5-12", indeedAded,
145145

146146
eq("File \"bs_poly_mutable_set_test.ml\", line 68, characters 5-12", Belt_internalAVLset.size(v.data), 1501);
147147

148-
var d = {
149-
cmp: IntCmp[/* cmp */0],
150-
data: Belt_internalAVLset.empty
151-
};
152-
153-
b("File \"bs_poly_mutable_set_test.ml\", line 69, characters 4-11", Belt_internalAVLset.isEmpty(d.data));
148+
b("File \"bs_poly_mutable_set_test.ml\", line 69, characters 4-11", Belt_MutableSet.isEmpty({
149+
cmp: IntCmp[/* cmp */0],
150+
data: Belt_internalAVLset.empty
151+
}));
154152

155153
eq("File \"bs_poly_mutable_set_test.ml\", line 70, characters 5-12", Belt_internalAVLset.minimum(v.data), /* Some */[500]);
156154

@@ -196,9 +194,7 @@ b("File \"bs_poly_mutable_set_test.ml\", line 84, characters 5-12", Belt_Mutable
196194

197195
b("File \"bs_poly_mutable_set_test.ml\", line 85, characters 4-11", Belt_MutableSet.subset(bb, v));
198196

199-
var d$1 = Belt_MutableSet.intersect(aa, bb);
200-
201-
b("File \"bs_poly_mutable_set_test.ml\", line 86, characters 4-11", Belt_internalAVLset.isEmpty(d$1.data));
197+
b("File \"bs_poly_mutable_set_test.ml\", line 86, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa, bb)));
202198

203199
var c = Belt_MutableSet.removeCheck(v, 1000);
204200

@@ -222,9 +218,7 @@ b("File \"bs_poly_mutable_set_test.ml\", line 93, characters 5-12", Belt_Mutable
222218

223219
b("File \"bs_poly_mutable_set_test.ml\", line 94, characters 4-11", Belt_MutableSet.subset(bb$1, v));
224220

225-
var d$2 = Belt_MutableSet.intersect(aa$1, bb$1);
226-
227-
b("File \"bs_poly_mutable_set_test.ml\", line 95, characters 4-11", Belt_internalAVLset.isEmpty(d$2.data));
221+
b("File \"bs_poly_mutable_set_test.ml\", line 95, characters 4-11", Belt_MutableSet.isEmpty(Belt_MutableSet.intersect(aa$1, bb$1)));
228222

229223
var aa$2 = fromArray(Array_data_util.randomRange(0, 100));
230224

jscomp/test/flow_parser_reg_test.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -11065,10 +11065,8 @@ function case_list(env, _param) {
1106511065
var switcher = param - 2 | 0;
1106611066
if (switcher > 29 || switcher < 0) {
1106711067
return switcher === 32;
11068-
} else if (switcher > 28 || switcher < 1) {
11069-
return true;
1107011068
} else {
11071-
return false;
11069+
return switcher > 28 || switcher < 1;
1107211070
}
1107311071
} else {
1107411072
return false;

jscomp/test/qcc.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ function getq() {
130130
function isid(param) {
131131
var switcher = param - 91 | 0;
132132
if (switcher > 5 || switcher < 0) {
133-
if ((switcher + 26 >>> 0) > 57) {
134-
return false;
135-
} else {
136-
return true;
137-
}
133+
return (switcher + 26 >>> 0) <= 57;
138134
} else {
139135
return switcher === 4;
140136
}

jscomp/test/tscanf_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ function test10() {
832832
]), (function (s1, s2, s3, s4, s5, s6) {
833833
return s1 + (s2 + (s3 + (s4 + (s5 + s6))));
834834
}));
835-
if (res === "Unechaine:celle-cietcelle-la!" && unit("\"a\\\n b\"") === "ab" && unit("\"\\\n ab\"") === "ab" && unit("\"\n\\\n ab\"") === "\nab" && unit("\"\n\\\n a\nb\"") === "\na\nb" && unit("\"\n\\\n \\\n a\nb\"") === "\na\nb" && unit("\"\n\\\n a\n\\\nb\\\n\"") === "\na\nb" && unit("\"a\\\n \"") === "a") {
836-
return true;
835+
if (res === "Unechaine:celle-cietcelle-la!" && unit("\"a\\\n b\"") === "ab" && unit("\"\\\n ab\"") === "ab" && unit("\"\n\\\n ab\"") === "\nab" && unit("\"\n\\\n a\nb\"") === "\na\nb" && unit("\"\n\\\n \\\n a\nb\"") === "\na\nb" && unit("\"\n\\\n a\n\\\nb\\\n\"") === "\na\nb") {
836+
return unit("\"a\\\n \"") === "a";
837837
} else {
838838
return false;
839839
}

lib/js/belt_MutableMap.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ function clear(m) {
165165
}
166166

167167
function isEmpty(d) {
168-
return Belt_internalAVLtree.isEmpty(d.data);
168+
var x = d.data;
169+
return x === null;
169170
}
170171

171172
function minKey(m) {

lib/js/belt_MutableMapInt.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function make() {
1111
}
1212

1313
function isEmpty(m) {
14-
return Belt_internalAVLtree.isEmpty(m.data);
14+
var x = m.data;
15+
return x === null;
1516
}
1617

1718
function clear(m) {

lib/js/belt_MutableMapString.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ function make() {
1111
}
1212

1313
function isEmpty(m) {
14-
return Belt_internalAVLtree.isEmpty(m.data);
14+
var x = m.data;
15+
return x === null;
1516
}
1617

1718
function clear(m) {

lib/js/belt_MutableSet.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ function make(id) {
200200
}
201201

202202
function isEmpty(d) {
203-
return Belt_internalAVLset.isEmpty(d.data);
203+
var n = d.data;
204+
return n === null;
204205
}
205206

206207
function minimum(d) {

lib/js/belt_MutableSetInt.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ function make() {
197197
}
198198

199199
function isEmpty(d) {
200-
return Belt_internalAVLset.isEmpty(d.data);
200+
var n = d.data;
201+
return n === null;
201202
}
202203

203204
function minimum(d) {

lib/js/belt_MutableSetString.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ function make() {
197197
}
198198

199199
function isEmpty(d) {
200-
return Belt_internalAVLset.isEmpty(d.data);
200+
var n = d.data;
201+
return n === null;
201202
}
202203

203204
function minimum(d) {

lib/js/belt_internalAVLset.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ function removeMinAuxWithRef(n, v) {
166166
}
167167

168168
function isEmpty(n) {
169-
if (n !== null) {
170-
return false;
171-
} else {
172-
return true;
173-
}
169+
return n === null;
174170
}
175171

176172
function stackAllLeft(_v, _s) {

lib/js/belt_internalAVLtree.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,7 @@ function removeMinAuxWithRef(n, kr, vr) {
254254
}
255255

256256
function isEmpty(x) {
257-
if (x !== null) {
258-
return false;
259-
} else {
260-
return true;
261-
}
257+
return x === null;
262258
}
263259

264260
function stackAllLeft(_v, _s) {

0 commit comments

Comments
 (0)