Skip to content

Commit b9e3f33

Browse files
Use native bigint type
1 parent 6725ea4 commit b9e3f33

21 files changed

+64
-73
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
"src/**/*.mjs"
2525
],
2626
"peerDependencies": {
27-
"rescript": ">=11.0.0 || ^11.1.0-rc.2"
27+
"rescript": "^11.1.0-rc.6"
2828
},
2929
"devDependencies": {
3030
"@babel/code-frame": "7.18.6",
3131
"@rescript/tools": "^0.5.0",
32-
"rescript": "11.1.0-rc.2"
32+
"rescript": "11.1.0-rc.6"
3333
}
3434
}

scripts/DocTests.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function prepareCompiler() {
6565
stdio: "ignore",
6666
cwd: compilerDir
6767
});
68-
var dict = JSON.parse(Fs.readFileSync(Path.join(corePath, "package.json")), undefined);
68+
var dict = JSON.parse(Fs.readFileSync(Path.join(corePath, "package.json")));
6969
var currentCoreVersion;
7070
if (!Array.isArray(dict) && (dict === null || typeof dict !== "object") && typeof dict !== "number" && typeof dict !== "string" && typeof dict !== "boolean") {
7171
throw {
@@ -179,7 +179,7 @@ function extractDocFromFile(file) {
179179
"doc",
180180
file
181181
]);
182-
return Tools_Docgen.decodeFromJson(JSON.parse(spawn.stdout.toString(), undefined));
182+
return Tools_Docgen.decodeFromJson(JSON.parse(spawn.stdout.toString()));
183183
}
184184

185185
function getExamples(param) {

src/Core__BigInt.res

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
1-
type t = Js.Types.bigint_val
1+
@val external asIntN: (~width: int, bigint) => bigint = "BigInt.asIntN"
2+
@val external asUintN: (~width: int, bigint) => bigint = "BigInt.asUintN"
23

3-
@val external asIntN: (~width: int, t) => t = "BigInt.asIntN"
4-
@val external asUintN: (~width: int, t) => t = "BigInt.asUintN"
4+
@val external fromString: string => bigint = "BigInt"
5+
@val external fromInt: int => bigint = "BigInt"
6+
@val external fromFloat: float => bigint = "BigInt"
57

6-
@val external fromString: string => t = "BigInt"
7-
@val external fromInt: int => t = "BigInt"
8-
@val external fromFloat: float => t = "BigInt"
8+
@send external toString: bigint => string = "toString"
9+
@send external toStringWithRadix: (bigint, ~radix: int) => string = "toString"
10+
@send external toLocaleString: bigint => string = "toLocaleString"
911

10-
@send external toString: t => string = "toString"
11-
@send external toStringWithRadix: (t, ~radix: int) => string = "toString"
12-
@send external toLocaleString: t => string = "toLocaleString"
13-
14-
@val external toFloat: t => float = "Number"
12+
@val external toFloat: bigint => float = "Number"
1513

1614
let toInt = t => t->toFloat->Core__Int.fromFloat
1715

18-
external \"+": (t, t) => t = "%addfloat"
19-
external \"-": (t, t) => t = "%subfloat"
20-
external \"*": (t, t) => t = "%mulfloat"
21-
external \"/": (t, t) => t = "%divfloat"
16+
external \"+": (bigint, bigint) => bigint = "%addfloat"
17+
external \"-": (bigint, bigint) => bigint = "%subfloat"
18+
external \"*": (bigint, bigint) => bigint = "%mulfloat"
19+
external \"/": (bigint, bigint) => bigint = "%divfloat"
2220

23-
external add: (t, t) => t = "%addfloat"
24-
external sub: (t, t) => t = "%subfloat"
25-
external mul: (t, t) => t = "%mulfloat"
26-
external div: (t, t) => t = "%divfloat"
21+
external add: (bigint, bigint) => bigint = "%addfloat"
22+
external sub: (bigint, bigint) => bigint = "%subfloat"
23+
external mul: (bigint, bigint) => bigint = "%mulfloat"
24+
external div: (bigint, bigint) => bigint = "%divfloat"
2725

28-
@noalloc external mod: (t, t) => t = "?fmod_float"
26+
@noalloc external mod: (bigint, bigint) => bigint = "?fmod_float"
2927

30-
external land: (t, t) => t = "%andint"
31-
external lor: (t, t) => t = "%orint"
32-
external lxor: (t, t) => t = "%xorint"
28+
external land: (bigint, bigint) => bigint = "%andint"
29+
external lor: (bigint, bigint) => bigint = "%orint"
30+
external lxor: (bigint, bigint) => bigint = "%xorint"
3331

34-
external lsl: (t, t) => t = "%lslint"
35-
external asr: (t, t) => t = "%asrint"
32+
external lsl: (bigint, bigint) => bigint = "%lslint"
33+
external asr: (bigint, bigint) => bigint = "%asrint"
3634

37-
let exp = (x: t, y: t) => {
35+
let exp = (x: bigint, y: bigint) => {
3836
let _ = x
3937
let _ = y
4038
%raw(`x ** y`)

src/Core__DataView.res

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: i
2020
@send external getFloat32: t => float = "getFloat32"
2121
@send external getFloat64: t => float = "getFloat64"
2222

23-
@send external getBigInt64: t => Core__BigInt.t = "getBigInt64"
24-
@send external getBigUint64: t => Core__BigInt.t = "getBigUint64"
23+
@send external getBigInt64: t => bigint = "getBigInt64"
24+
@send external getBigUint64: t => bigint = "getBigUint64"
2525

2626
@send external setInt8: (t, int) => unit = "setInt8"
2727
@send external setUint8: (t, int) => unit = "setUint8"
@@ -33,5 +33,5 @@ external fromBufferWithRange: (Core__ArrayBuffer.t, ~byteOffset: int, ~length: i
3333
@send external setFloat32: (t, float) => unit = "setFloat32"
3434
@send external setFloat64: (t, float) => unit = "setFloat64"
3535

36-
@send external setBigInt64: (t, Core__BigInt.t) => unit = "setBigInt64"
37-
@send external setBigUint64: (t, Core__BigInt.t) => unit = "setBigUint64"
36+
@send external setBigInt64: (t, bigint) => unit = "setBigInt64"
37+
@send external setBigUint64: (t, bigint) => unit = "setBigUint64"

src/Core__Type.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module Classify = {
1515
| Object(object)
1616
| Function(function)
1717
| Symbol(Core__Symbol.t)
18-
| BigInt(Core__BigInt.t)
18+
| BigInt(bigint)
1919

2020
@val external _internalClass: 'a => string = "Object.prototype.toString.call"
2121
external _asBool: 'a => bool = "%identity"
@@ -24,7 +24,7 @@ module Classify = {
2424
external _asObject: 'a => object = "%identity"
2525
external _asFunction: 'a => function = "%identity"
2626
external _asSymbol: 'a => Core__Symbol.t = "%identity"
27-
external _asBigInt: 'a => Core__BigInt.t = "%identity"
27+
external _asBigInt: 'a => bigint = "%identity"
2828

2929
let classify = value => {
3030
switch _internalClass(value) {

src/Core__Type.resi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module Classify: {
5959
| Object(object)
6060
| Function(function)
6161
| Symbol(Core__Symbol.t)
62-
| BigInt(Core__BigInt.t)
62+
| BigInt(bigint)
6363

6464
/**
6565
`classify(anyValue)`

src/intl/Core__Intl__NumberFormat.res

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,16 @@ external formatIntToParts: (t, int) => array<numberFormatPart> = "formatToParts"
194194
external formatIntRangeToParts: (t, ~start: int, ~end: int) => array<numberFormatRangePart> =
195195
"formatRange"
196196

197-
@send external formatBigInt: (t, Core__BigInt.t) => string = "format"
197+
@send external formatBigInt: (t, bigint) => string = "format"
198198

199199
@send
200-
external formatBigIntRange: (t, ~start: Core__BigInt.t, ~end: Core__BigInt.t) => array<string> =
201-
"formatRange"
200+
external formatBigIntRange: (t, ~start: bigint, ~end: bigint) => array<string> = "formatRange"
202201
@send
203-
external formatBigIntToParts: (t, Core__BigInt.t) => array<numberFormatPart> = "formatToParts"
202+
external formatBigIntToParts: (t, bigint) => array<numberFormatPart> = "formatToParts"
204203

205204
@send
206-
external formatBigIntRangeToParts: (
207-
t,
208-
~start: Core__BigInt.t,
209-
~end: Core__BigInt.t,
210-
) => array<numberFormatPart> = "formatRange"
205+
external formatBigIntRangeToParts: (t, ~start: bigint, ~end: bigint) => array<numberFormatPart> =
206+
"formatRange"
211207

212208
@send external formatString: (t, string) => string = "format"
213209

src/intl/Core__Intl__PluralRules.res

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type rule = [#zero | #one | #two | #few | #many | #other]
5050

5151
@send external select: (t, float) => rule = "select"
5252
@send external selectInt: (t, int) => rule = "select"
53-
@send external selectBigInt: (t, Core__BigInt.t) => rule = "select"
53+
@send external selectBigInt: (t, bigint) => rule = "select"
5454

5555
@send
5656
external selectRange: (t, ~start: float, ~end: float) => rule = "selectRange"
@@ -59,5 +59,4 @@ external selectRange: (t, ~start: float, ~end: float) => rule = "selectRange"
5959
external selectRangeInt: (t, ~start: int, ~end: int) => rule = "selectRange"
6060

6161
@send
62-
external selectRangeBigInt: (t, ~start: Core__BigInt.t, ~end: Core__BigInt.t) => rule =
63-
"selectRange"
62+
external selectRangeBigInt: (t, ~start: bigint, ~end: bigint) => rule = "selectRange"

src/typed-arrays/Core__BigInt64Array.res

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** The `BigInt64Array` typed array represents an array of 64-bit signed integers in platform byte order. See [BigInt64Array on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array)
22
*/
3-
type t = Core__TypedArray.t<Core__BigInt.t>
3+
type t = Core__TypedArray.t<bigint>
44

55
module Constants = {
66
/**`bytesPerElement` returns the element size. See [BYTES_PER_ELEMENT on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/BYTES_PER_ELEMENT)
@@ -12,7 +12,7 @@ module Constants = {
1212
/** `fromArray` creates a `BigInt64Array` from an array of values. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)
1313
*/
1414
@new
15-
external fromArray: array<Core__BigInt.t> => t = "BigInt64Array"
15+
external fromArray: array<bigint> => t = "BigInt64Array"
1616

1717
/** `fromBuffer` creates a `BigInt64Array` from an `ArrayBuffer.t`. See [TypedArray constructor on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array/BigInt64Array)
1818
@@ -51,5 +51,4 @@ external fromArrayLikeOrIterable: 'a => t = "BigInt64Array.from"
5151
/** `fromArrayLikeOrIterableWithMap` creates a `BigInt64Array` from an array-like or iterable object and applies the mapping function to each item. The mapping function expects (value, index). See [TypedArray.from on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/from)
5252
*/
5353
@val
54-
external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => Core__BigInt.t) => t =
55-
"BigInt64Array.from"
54+
external fromArrayLikeOrIterableWithMap: ('a, ('b, int) => bigint) => t = "BigInt64Array.from"

0 commit comments

Comments
 (0)