Skip to content

Commit 76726a7

Browse files
committed
wip
1 parent f0b6de9 commit 76726a7

File tree

8 files changed

+51
-1
lines changed

8 files changed

+51
-1
lines changed

lib/es6/Stdlib_Int.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ function clamp(min, max, value) {
6262
}
6363
}
6464

65+
function lnot(x) {
66+
return x ^ -1;
67+
}
68+
69+
let Bitwise = {
70+
lnot: lnot
71+
};
72+
6573
let Ref = {};
6674

6775
let Constants = {
@@ -75,6 +83,7 @@ export {
7583
range,
7684
rangeWithOptions,
7785
clamp,
86+
Bitwise,
7887
Ref,
7988
}
8089
/* No side effect */

lib/js/Stdlib_Int.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ function clamp(min, max, value) {
6262
}
6363
}
6464

65+
function lnot(x) {
66+
return x ^ -1;
67+
}
68+
69+
let Bitwise = {
70+
lnot: lnot
71+
};
72+
6573
let Ref = {};
6674

6775
let Constants = {
@@ -74,5 +82,6 @@ exports.fromString = fromString;
7482
exports.range = range;
7583
exports.rangeWithOptions = rangeWithOptions;
7684
exports.clamp = clamp;
85+
exports.Bitwise = Bitwise;
7786
exports.Ref = Ref;
7887
/* No side effect */

runtime/Stdlib_Int.res

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,18 @@ external shiftLeft: (int, int) => int = "%lslint"
105105
external shiftRight: (int, int) => int = "%asrint"
106106
external shiftRightUnsigned: (int, int) => int = "%lsrint"
107107

108+
module Bitwise = {
109+
external land: (int, int) => int = "%andint"
110+
external lor: (int, int) => int = "%orint"
111+
external lxor: (int, int) => int = "%xorint"
112+
113+
external lsl: (int, int) => int = "%lslint"
114+
external lsr: (int, int) => int = "%lsrint"
115+
external asr: (int, int) => int = "%asrint"
116+
117+
let lnot = x => lxor(x, -1)
118+
}
119+
108120
external ignore: int => unit = "%ignore"
109121

110122
module Ref = {

runtime/Stdlib_Int.resi

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Int.toPrecisionWithPrecision(1, ~digits=2) // "1.0"
186186
- `RangeError`: If `digits` is not between 1 and 100 (inclusive).
187187
Implementations are allowed to support larger and smaller values as well.
188188
ECMA-262 only requires a precision of up to 21 significant digits.
189-
189+
190190
*/
191191
@send @deprecated("Use `toPrecision` instead")
192192
external toPrecisionWithPrecision: (int, ~digits: int) => string = "toPrecision"
@@ -471,6 +471,22 @@ Int.shiftRightUnsigned(4, 1) == 2
471471
*/
472472
external shiftRightUnsigned: (int, int) => int = "%lsrint"
473473

474+
module Bitwise = {
475+
@deprecated({
476+
reason: "Use `Int.bitwiseAnd` instead",
477+
reason: Int.bitwiseAnd
478+
})
479+
external land: (int, int) => int = "%andint"
480+
external lor: (int, int) => int = "%orint"
481+
external lxor: (int, int) => int = "%xorint"
482+
483+
external lsl: (int, int) => int = "%lslint"
484+
external lsr: (int, int) => int = "%lsrint"
485+
external asr: (int, int) => int = "%asrint"
486+
487+
let lnot: int => int
488+
}
489+
474490
/**
475491
`ignore(int)` ignores the provided int and returns unit.
476492
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
StdlibMigration_Int.res: File did not need migration
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let result = Int.Bitwise.land(1, 2)

tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Array.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,4 @@ let reduceRight2 = Array.reduceRight([1, 2, 3], 0, (acc, x) => acc + x)
166166

167167
let reduceRighti1 = [1, 2, 3]->Array.reduceRightWithIndex(0, (acc, x, i) => acc + x + i)
168168
let reduceRighti2 = Array.reduceRightWithIndex([1, 2, 3], 0, (acc, x, i) => acc + x + i)
169+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
StdlibMigration_Int.res: File did not need migration

0 commit comments

Comments
 (0)