Skip to content

Commit 31ab245

Browse files
committed
Revert "unparen shift ops"
This reverts commit 5d308e7.
1 parent 5d308e7 commit 31ab245

37 files changed

+117
-105
lines changed

compiler/core/js_dump.ml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,13 @@ and expression_desc cxt ~(level : int) f x : cxt =
717717
expression_desc cxt ~level:(level : int) f (Is_null_or_undefined e1)
718718
| Bin (op, e1, e2) ->
719719
let out, lft, rght = Js_op_util.op_prec op in
720-
let need_paren = level > out in
720+
let need_paren =
721+
level > out
722+
||
723+
match op with
724+
| Lsl | Lsr | Asr -> true
725+
| _ -> false
726+
in
721727
(* We are more conservative here, to make the generated code more readable
722728
to the user *)
723729
P.cond_paren_group f need_paren (fun _ ->
@@ -729,7 +735,13 @@ and expression_desc cxt ~(level : int) f x : cxt =
729735
| String_append (e1, e2) ->
730736
let op : Js_op.binop = Plus in
731737
let out, lft, rght = Js_op_util.op_prec op in
732-
let need_paren = level > out in
738+
let need_paren =
739+
level > out
740+
||
741+
match op with
742+
| Lsl | Lsr | Asr -> true
743+
| _ -> false
744+
in
733745
P.cond_paren_group f need_paren (fun _ ->
734746
let cxt = expression ~level:lft cxt f e1 in
735747
P.space f;

lib/es6/Belt_HashMap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ function set0(h, key, value, eq, hash) {
6666
};
6767
h.size = h.size + 1 | 0;
6868
}
69-
if (h.size > buckets_len << 1) {
69+
if (h.size > (buckets_len << 1)) {
7070
let odata = h.buckets;
7171
let osize = odata.length;
72-
let nsize = osize << 1;
72+
let nsize = (osize << 1);
7373
if (nsize < osize) {
7474
return;
7575
}

lib/es6/Belt_HashMapInt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ function set(h, key, value) {
6363
};
6464
h.size = h.size + 1 | 0;
6565
}
66-
if (h.size > buckets_len << 1) {
66+
if (h.size > (buckets_len << 1)) {
6767
let odata = h.buckets;
6868
let osize = odata.length;
69-
let nsize = osize << 1;
69+
let nsize = (osize << 1);
7070
if (nsize < osize) {
7171
return;
7272
}

lib/es6/Belt_HashMapString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ function set(h, key, value) {
6363
};
6464
h.size = h.size + 1 | 0;
6565
}
66-
if (h.size > buckets_len << 1) {
66+
if (h.size > (buckets_len << 1)) {
6767
let odata = h.buckets;
6868
let osize = odata.length;
69-
let nsize = osize << 1;
69+
let nsize = (osize << 1);
7070
if (nsize < osize) {
7171
return;
7272
}

lib/es6/Belt_HashSet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add0(h, key, hash, eq) {
9393
next: undefined
9494
};
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

lib/es6/Belt_HashSetInt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add(h, key) {
9393
};
9494
h.size = h.size + 1 | 0;
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

lib/es6/Belt_HashSetString.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ function add(h, key) {
9393
};
9494
h.size = h.size + 1 | 0;
9595
}
96-
if (h.size > buckets_len << 1) {
96+
if (h.size > (buckets_len << 1)) {
9797
let odata = h.buckets;
9898
let osize = odata.length;
99-
let nsize = osize << 1;
99+
let nsize = (osize << 1);
100100
if (nsize < osize) {
101101
return;
102102
}

lib/es6/Belt_internalBucketsType.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ function power_2_above(_x, n) {
77
if (x >= n) {
88
return x;
99
}
10-
if (x << 1 < x) {
10+
if ((x << 1) < x) {
1111
return x;
1212
}
13-
_x = x << 1;
13+
_x = (x << 1);
1414
continue;
1515
};
1616
}

lib/es6/Primitive_hash.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function unsafe_pop(q) {
4444
}
4545

4646
function rotl32(x, n) {
47-
return x << n | x >>> (32 - n | 0) | 0;
47+
return (x << n) | (x >>> (32 - n | 0)) | 0;
4848
}
4949

5050
function hash_mix_int(h, d) {
@@ -58,26 +58,26 @@ function hash_mix_int(h, d) {
5858
}
5959

6060
function hash_final_mix(h) {
61-
let h$1 = h ^ h >>> 16;
61+
let h$1 = h ^ (h >>> 16);
6262
h$1 = Math.imul(h$1, -2048144789);
63-
h$1 = h$1 ^ h$1 >>> 13;
63+
h$1 = h$1 ^ (h$1 >>> 13);
6464
h$1 = Math.imul(h$1, -1028477387);
65-
return h$1 ^ h$1 >>> 16;
65+
return h$1 ^ (h$1 >>> 16);
6666
}
6767

6868
function hash_mix_string(h, s) {
6969
let len = s.length;
7070
let block = (len / 4 | 0) - 1 | 0;
7171
let hash = h;
7272
for (let i = 0; i <= block; ++i) {
73-
let j = i << 2;
74-
let w = s.charCodeAt(j) | s.charCodeAt(j + 1 | 0) << 8 | s.charCodeAt(j + 2 | 0) << 16 | s.charCodeAt(j + 3 | 0) << 24;
73+
let j = (i << 2);
74+
let w = s.charCodeAt(j) | (s.charCodeAt(j + 1 | 0) << 8) | (s.charCodeAt(j + 2 | 0) << 16) | (s.charCodeAt(j + 3 | 0) << 24);
7575
hash = hash_mix_int(hash, w);
7676
}
7777
let modulo = len & 3;
7878
if (modulo !== 0) {
79-
let w$1 = modulo === 3 ? s.charCodeAt(len - 1 | 0) << 16 | s.charCodeAt(len - 2 | 0) << 8 | s.charCodeAt(len - 3 | 0) : (
80-
modulo === 2 ? s.charCodeAt(len - 1 | 0) << 8 | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0)
79+
let w$1 = modulo === 3 ? (s.charCodeAt(len - 1 | 0) << 16) | (s.charCodeAt(len - 2 | 0) << 8) | s.charCodeAt(len - 3 | 0) : (
80+
modulo === 2 ? (s.charCodeAt(len - 1 | 0) << 8) | s.charCodeAt(len - 2 | 0) : s.charCodeAt(len - 1 | 0)
8181
);
8282
hash = hash_mix_int(hash, w$1);
8383
}
@@ -117,7 +117,7 @@ function hash(count, _limit, seed, obj) {
117117
let size = obj$1.length | 0;
118118
if (size !== 0) {
119119
let obj_tag = obj$1.TAG;
120-
let tag = size << 10 | obj_tag;
120+
let tag = (size << 10) | obj_tag;
121121
s = hash_mix_int(s, tag);
122122
let v = size - 1 | 0;
123123
let block = v < num ? v : num;
@@ -133,7 +133,7 @@ function hash(count, _limit, seed, obj) {
133133
}
134134
return size
135135
})(obj$1, v => push_back(queue, v));
136-
s = hash_mix_int(s, size$1 << 10 | 0);
136+
s = hash_mix_int(s, (size$1 << 10) | 0);
137137
}
138138
}
139139

lib/js/Belt_HashMap.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ function set0(h, key, value, eq, hash) {
6666
};
6767
h.size = h.size + 1 | 0;
6868
}
69-
if (h.size > buckets_len << 1) {
69+
if (h.size > (buckets_len << 1)) {
7070
let odata = h.buckets;
7171
let osize = odata.length;
72-
let nsize = osize << 1;
72+
let nsize = (osize << 1);
7373
if (nsize < osize) {
7474
return;
7575
}

0 commit comments

Comments
 (0)