Skip to content

Commit 5ccdd88

Browse files
authored
Rename Js.Bigint -> Js.BigInt (#6696)
* rename Js.Bigint -> Js.BigInt * update change log
1 parent f0dda99 commit 5ccdd88

20 files changed

+43
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#### :rocket: New Feature
1616

17-
- Add the primitive bigint type https://github.com/rescript-lang/rescript-compiler/pull/6670
17+
- Add the primitive bigint type https://github.com/rescript-lang/rescript-compiler/pull/6670 https://github.com/rescript-lang/rescript-compiler/pull/6696
1818

1919
#### :bug: Bug Fix
2020

jscomp/core/js_analyzer.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ let rec eq_expression ({ expression_desc = x0 } : J.expression)
158158
| Undefined x -> y0 = Undefined x
159159
| Number (Int { i }) -> (
160160
match y0 with Number (Int { i = j }) -> i = j | _ -> false)
161-
| Number (Bigint {positive = p0; value = v0}) -> (
162-
match y0 with Number (Bigint {positive = p1; value = v1}) -> p0 = p1 && v0 = v1 | _ -> false)
161+
| Number (BigInt {positive = p0; value = v0}) -> (
162+
match y0 with Number (BigInt {positive = p1; value = v1}) -> p0 = p1 && v0 = v1 | _ -> false)
163163
| Number (Float _) -> false
164164
(* begin match y0 with
165165
| Number (Float j) ->

jscomp/core/js_dump.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ and expression_desc cxt ~(level : int) f x : cxt =
664664
Int32.to_string i
665665
(* check , js convention with ocaml lexical convention *)
666666
| Uint i -> Format.asprintf "%lu" i
667-
| Bigint {positive; value} -> Format.asprintf "%sn" (Bigint_utils.to_string positive value)
667+
| BigInt {positive; value} -> Format.asprintf "%sn" (Bigint_utils.to_string positive value)
668668
in
669669
let need_paren =
670670
if s.[0] = '-' then level > 13

jscomp/core/js_exp_make.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ let obj_int_tag_literal : t =
312312

313313
let int ?comment ?c i : t = { expression_desc = Number (Int { i; c }); comment }
314314

315-
let bigint ?comment sign i : t = { expression_desc = Number (Bigint {positive=sign; value=i}); comment}
315+
let bigint ?comment sign i : t = { expression_desc = Number (BigInt {positive=sign; value=i}); comment}
316316

317-
let zero_bigint_literal : t = {expression_desc = Number (Bigint {positive=true; value="0"}); comment = None}
317+
let zero_bigint_literal : t = {expression_desc = Number (BigInt {positive=true; value="0"}); comment = None}
318318

319319
let small_int i : t =
320320
match i with
@@ -807,7 +807,7 @@ let tag_type = function
807807
| Ast_untagged_variants.String s -> str s ~delim:DStarJ
808808
| Int i -> small_int i
809809
| Float f -> float f
810-
| Bigint i ->
810+
| BigInt i ->
811811
let sign, i = Bigint_utils.parse_bigint i in
812812
bigint sign i
813813
| Bool b -> bool b

jscomp/core/js_op.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ type number =
132132
| Float of float_lit
133133
| Int of { i : int32; c : int option }
134134
| Uint of int32
135-
| Bigint of bigint_lit
135+
| BigInt of bigint_lit
136136

137137
(* becareful when constant folding +/-,
138138
since we treat it as js nativeint, bitwise operators:

jscomp/core/js_stmt_make.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ let string_switch ?(comment : string option)
138138
match switch_case with
139139
| String s ->
140140
if s = txt then Some x.switch_body else None
141-
| Int _ | Float _ | Bigint _ | Bool _ | Null | Undefined | Untagged _ ->
141+
| Int _ | Float _ | BigInt _ | Bool _ | Null | Undefined | Untagged _ ->
142142
None)
143143
with
144144
| Some case -> case

jscomp/core/lam_primitive.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type t =
8080
| Psubfloat
8181
| Pmulfloat
8282
| Pdivfloat
83-
(* Bigint operations *)
83+
(* BigInt operations *)
8484
| Pnegbigint
8585
| Paddbigint
8686
| Psubbigint

jscomp/ml/ast_untagged_variants.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ type tag_type =
8181
| String of string
8282
| Int of int
8383
| Float of string
84-
| Bigint of string
84+
| BigInt of string
8585
| Bool of bool
8686
| Null
8787
| Undefined (* literal or tagged block *)
@@ -126,7 +126,7 @@ let process_tag_type (attrs : Parsetree.attributes) =
126126
| Some f -> st := Some (Float f));
127127
(match Ast_payload.is_single_bigint payload with
128128
| None -> ()
129-
| Some i -> st := Some (Bigint i));
129+
| Some i -> st := Some (BigInt i));
130130
(match Ast_payload.is_single_bool payload with
131131
| None -> ()
132132
| Some b -> st := Some (Bool b));
@@ -291,7 +291,7 @@ let checkInvariant ~isUntaggedDef ~(consts : (Location.t * tag) list)
291291
| Some (String s) -> addStringLiteral ~loc s
292292
| Some (Int i) -> addNonstringLiteral ~loc (string_of_int i)
293293
| Some (Float f) -> addNonstringLiteral ~loc f
294-
| Some (Bigint i) -> addNonstringLiteral ~loc i
294+
| Some (BigInt i) -> addNonstringLiteral ~loc i
295295
| Some Null -> addNonstringLiteral ~loc "null"
296296
| Some Undefined -> addNonstringLiteral ~loc "undefined"
297297
| Some (Bool b) -> addNonstringLiteral ~loc (if b then "true" else "false")
@@ -398,7 +398,7 @@ module DynamicChecks = struct
398398
in
399399
let literals_overlaps_with_bigint () =
400400
Ext_list.exists literal_cases (function
401-
| Bigint _ -> true
401+
| BigInt _ -> true
402402
| _ -> false)
403403
in
404404
let literals_overlaps_with_boolean () =
@@ -488,5 +488,5 @@ module DynamicChecks = struct
488488
| Untagged UnknownType ->
489489
(* This should not happen because unknown must be the only non-literal case *)
490490
assert false
491-
| Bool _ | Float _ | Int _ | Bigint _ | String _ | Null | Undefined -> x
491+
| Bool _ | Float _ | Int _ | BigInt _ | String _ | Null | Undefined -> x
492492
end

jscomp/ml/lambda.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ type primitive =
229229
| Pnegfloat | Pabsfloat
230230
| Paddfloat | Psubfloat | Pmulfloat | Pdivfloat
231231
| Pfloatcomp of comparison
232-
(* Bigint operations *)
232+
(* BigInt operations *)
233233
| Pnegbigint | Paddbigint | Psubbigint | Ppowbigint
234234
| Pmulbigint | Pdivbigint | Pmodbigint
235235
| Pandbigint | Porbigint | Pxorbigint

jscomp/ml/lambda.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ type primitive =
195195
| Pnegfloat | Pabsfloat
196196
| Paddfloat | Psubfloat | Pmulfloat | Pdivfloat
197197
| Pfloatcomp of comparison
198-
(* Bigint operations *)
198+
(* BigInt operations *)
199199
| Pnegbigint | Paddbigint | Psubbigint | Ppowbigint
200200
| Pmulbigint | Pdivbigint | Pmodbigint
201201
| Pandbigint | Porbigint | Pxorbigint

jscomp/ml/printlambda.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let print_boxed_integer_conversion ppf bi1 bi2 =
6464
fprintf ppf "%s_of_%s" (boxed_integer_name bi2) (boxed_integer_name bi1)
6565

6666
let boxed_integer_mark name = function
67-
| Pbigint -> Printf.sprintf "Bigint.%s" name
67+
| Pbigint -> Printf.sprintf "BigInt.%s" name
6868
| Pint32 -> Printf.sprintf "Int32.%s" name
6969
| Pint64 -> Printf.sprintf "Int64.%s" name
7070

jscomp/ml/variant_coercion.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let variant_has_same_runtime_representation_as_target ~(targetPath : Path.t)
3939
path_same Predef.path_string
4040
|| (* unboxed Number(float) :> float *)
4141
path_same Predef.path_float
42-
|| (* unboxed Bigint(bigint) :> bigint *)
42+
|| (* unboxed BigInt(bigint) :> bigint *)
4343
path_same Predef.path_bigint
4444
| Cstr_tuple [] -> (
4545
(* Check that @as payloads match with the target path to coerce to.
@@ -48,7 +48,7 @@ let variant_has_same_runtime_representation_as_target ~(targetPath : Path.t)
4848
| None | Some (String _) -> Path.same targetPath Predef.path_string
4949
| Some (Int _) -> Path.same targetPath Predef.path_int
5050
| Some (Float _) -> Path.same targetPath Predef.path_float
51-
| Some (Bigint _) -> Path.same targetPath Predef.path_bigint
51+
| Some (BigInt _) -> Path.same targetPath Predef.path_bigint
5252
| Some (Null | Undefined | Bool _ | Untagged _) -> false)
5353
| _ -> false
5454
in

jscomp/others/js.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ module Float = Js_float
259259
module Int = Js_int
260260
(** Provide utilities for int *)
261261

262-
module Bigint = Js_bigint
262+
module BigInt = Js_bigint
263263
(** Provide utilities for bigint *)
264264

265265
module File = Js_file

jscomp/others/js_bigint.res

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ number as a `bigint` if successfully parsed. Uncaught syntax exception otherwise
99
1010
```rescript
1111
/* returns 123n */
12-
Js.Bigint.fromStringExn("123")
12+
Js.BigInt.fromStringExn("123")
1313
1414
/* returns 0n */
15-
Js.Bigint.fromStringExn("")
15+
Js.BigInt.fromStringExn("")
1616
1717
/* returns 17n */
18-
Js.Bigint.fromStringExn("0x11")
18+
Js.BigInt.fromStringExn("0x11")
1919
2020
/* returns 3n */
21-
Js.Bigint.fromStringExn("0b11")
21+
Js.BigInt.fromStringExn("0b11")
2222
2323
/* returns 9n */
24-
Js.Bigint.fromStringExn("0o11")
24+
Js.BigInt.fromStringExn("0o11")
2525
2626
/* catch exception */
2727
try {
28-
Js.Bigint.fromStringExn("a")
28+
Js.BigInt.fromStringExn("a")
2929
} catch {
3030
| _ => ...
3131
}
@@ -62,20 +62,20 @@ See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Referen
6262
6363
```rescript
6464
/* prints "123" */
65-
Js.Bigint.toString(123n)->Js.log
65+
Js.BigInt.toString(123n)->Js.log
6666
```
6767
*/
6868
external toString: bigint => string = "toString"
6969

7070
@send
7171
/**
72-
Returns a string with a language-sensitive representation of this Bigint value.
72+
Returns a string with a language-sensitive representation of this BigInt value.
7373
7474
## Examples
7575
7676
```rescript
7777
/* prints "123" */
78-
Js.Bigint.toString(123n)->Js.log
78+
Js.BigInt.toString(123n)->Js.log
7979
```
8080
*/
8181
external toLocaleString: bigint => string = "toLocaleString"

jscomp/runtime/js.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ module Float = Js_float
225225
module Int = Js_int
226226
(** Provide utilities for int *)
227227

228-
module Bigint = Js_bigint
228+
module BigInt = Js_bigint
229229
(** Provide utilities for bigint *)
230230

231231
module File = Js_file

jscomp/test/VariantCoercion.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ module CoerceFromFloatToVariant = {
8282
}
8383

8484
module CoerceFromBigintToVariant = {
85-
@unboxed type bigints = Bigint(bigint) | @as(1n) First | @as(2n) Second | @as(3n) Third
85+
@unboxed type bigints = BigInt(bigint) | @as(1n) First | @as(2n) Second | @as(3n) Third
8686
let a = 100n
8787
let aa = 1n
8888
let b: bigints = (a :> bigints)
8989
let bb: bigints = (aa :> bigints)
9090

91-
@unboxed type mixed = Bigint(bigint) | @as(1n) One | @as(null) Null | Two
91+
@unboxed type mixed = BigInt(bigint) | @as(1n) One | @as(null) Null | Two
9292
let c = 120n
9393
let cc: mixed = (c :> mixed)
9494
}

jscomp/test/bigint_test.res

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ let bigint_lessequal = (x: bigint, y) => x <= y
1616
let generic_lessequal = \"<="
1717
let bigint_greaterequal = (x: bigint, y) => x >= y
1818
let generic_greaterequal = \">="
19-
let bigint_land = Js.Bigint.land
20-
let bigint_lor = Js.Bigint.lor
21-
let bigint_lxor = Js.Bigint.lxor
22-
let bigint_lsl = Js.Bigint.lsl
23-
let bigint_asr = Js.Bigint.asr
19+
let bigint_land = Js.BigInt.land
20+
let bigint_lor = Js.BigInt.lor
21+
let bigint_lxor = Js.BigInt.lxor
22+
let bigint_lsl = Js.BigInt.lsl
23+
let bigint_asr = Js.BigInt.asr
2424

2525
let () = {
2626
eq(__LOC__, bigint_compare(1n, 1n), 0)

jscomp/test/caml_compare_bigint_test.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let isEqual = (title, num1, num2) => list{
4242

4343
let five = bigint("5")
4444

45-
/** Not comparing floats and Bigint; not sure this is correct since works in JavaScript */
45+
/** Not comparing floats and BigInt; not sure this is correct since works in JavaScript */
4646
let suites: Mt.pair_suites = \"@"(
4747
isLessThan("123 and 555555", bigint("123"), bigint("555555")),
4848
\"@"(

lib/es6/js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var Float;
5151

5252
var Int;
5353

54-
var Bigint;
54+
var $$BigInt;
5555

5656
var $$File;
5757

@@ -101,7 +101,7 @@ export {
101101
Types ,
102102
Float ,
103103
Int ,
104-
Bigint ,
104+
$$BigInt ,
105105
$$File ,
106106
$$Blob ,
107107
$$Option ,

lib/js/js.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var Float;
5151

5252
var Int;
5353

54-
var Bigint;
54+
var $$BigInt;
5555

5656
var $$File;
5757

@@ -100,7 +100,7 @@ exports.TypedArray2 = TypedArray2;
100100
exports.Types = Types;
101101
exports.Float = Float;
102102
exports.Int = Int;
103-
exports.Bigint = Bigint;
103+
exports.$$BigInt = $$BigInt;
104104
exports.$$File = $$File;
105105
exports.$$Blob = $$Blob;
106106
exports.$$Option = $$Option;

0 commit comments

Comments
 (0)