Skip to content

Commit 471ec88

Browse files
committed
Add bigint type
This patch adds a bigint type to WebIDL with the following properties: - bigint corresponds directly to BigInt - The conversion from JS is based on ToBigInt, namely it throws on Number. - bigint is not grouped as a "numeric" type, as this category is often used to refer to types which have a JavaScript representation of Number. - bigint is included in the overloading resolution algorithm, and it's possible to overload a function for BigInt and numeric arguments. - bigint constants are provided with syntax analogous to JS. - bigint is included in the es-to-union algorithm. Although it may be on the early side for such a change, the lack of BigInt WebIDL integration is already coming up in some designs for integrating BigInt with the Web Platform, such as w3c/IndexedDB#231
1 parent c159bcc commit 471ec88

File tree

1 file changed

+108
-4
lines changed

1 file changed

+108
-4
lines changed

index.bs

Lines changed: 108 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,21 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
192192
text: own property; url: sec-own-property
193193
text: Property Descriptor; url: sec-property-descriptor-specification-type
194194
text: realm; url: realm
195+
urlPrefix: https://tc39.github.io/proposal-bigint/; spec: BIGINT
196+
text: ToBigInt; url: #sec-to-bigint; type: abstract-op
197+
text: BigInt; url: #sec-ecmascript-language-types-bigint-type; type: dfn
195198
</pre>
196199

197200
<pre class=biblio>
198201
{
199202
"GEOMETRY": {
200203
"aliasOf": "GEOMETRY-1"
204+
},
205+
"BIGINT": {
206+
"href": "https://tc39.github.io/proposal-bigint/",
207+
"title": "BigInt Specification",
208+
"publisher": "TC39",
209+
"status": "Stage 3 proposal"
201210
}
202211
}
203212
</pre>
@@ -1592,7 +1601,8 @@ constant declaration gives the value of the constant, which can be
15921601
one of the two boolean literal tokens (<emu-t>true</emu-t>
15931602
and <emu-t>false</emu-t>),
15941603
the <emu-t>null</emu-t> token, an
1595-
<emu-t class="regex"><a href="#prod-integer">integer</a></emu-t> token,
1604+
<emu-t class="regex"><a href="#prod-integer">integer</a></emu-t> token, a
1605+
<emu-t class="regex"><a href="#prod-bigint">bigint</a></emu-t> token,
15961606
a <emu-t class="regex"><a href="#prod-float">float</a></emu-t> token,
15971607
or one of the three special floating point constant values
15981608
(<emu-t>-Infinity</emu-t>, <emu-t>Infinity</emu-t> and <emu-t>NaN</emu-t>).
@@ -1734,6 +1744,7 @@ The following extended attributes are applicable to constants:
17341744
BooleanLiteral
17351745
FloatLiteral
17361746
integer
1747+
bigint
17371748
"null"
17381749
</pre>
17391750

@@ -3468,6 +3479,9 @@ the following algorithm returns <i>true</i>.
34683479
</div></th>
34693480
<th><div>
34703481
<span>numeric types</span>
3482+
</div></th>
3483+
<th><div>
3484+
<span>bigint</span>
34713485
</div></th>
34723486
<th><div>
34733487
<span>string types</span>
@@ -3502,6 +3516,7 @@ the following algorithm returns <i>true</i>.
35023516
<td>●</td>
35033517
<td>●</td>
35043518
<td>●</td>
3519+
<td>●</td>
35053520
</tr>
35063521
<tr>
35073522
<th>numeric types</th>
@@ -3514,11 +3529,26 @@ the following algorithm returns <i>true</i>.
35143529
<td>●</td>
35153530
<td>●</td>
35163531
<td>●</td>
3532+
<td>●</td>
3533+
</tr>
3534+
<tr>
3535+
<th>bigint</th>
3536+
<td class="belowdiagonal"></td>
3537+
<td class="belowdiagonal"></td>
3538+
<td></td>
3539+
<td>●</td>
3540+
<td>●</td>
3541+
<td>●</td>
3542+
<td>●</td>
3543+
<td>●</td>
3544+
<td>●</td>
3545+
<td>●</td>
35173546
</tr>
35183547
<tr>
35193548
<th>string types</th>
35203549
<td class="belowdiagonal"></td>
35213550
<td class="belowdiagonal"></td>
3551+
<td class="belowdiagonal"></td>
35223552
<td></td>
35233553
<td>●</td>
35243554
<td>●</td>
@@ -3532,6 +3562,7 @@ the following algorithm returns <i>true</i>.
35323562
<td class="belowdiagonal"></td>
35333563
<td class="belowdiagonal"></td>
35343564
<td class="belowdiagonal"></td>
3565+
<td class="belowdiagonal"></td>
35353566
<td></td>
35363567
<td>●</td>
35373568
<td></td>
@@ -3545,6 +3576,7 @@ the following algorithm returns <i>true</i>.
35453576
<td class="belowdiagonal"></td>
35463577
<td class="belowdiagonal"></td>
35473578
<td class="belowdiagonal"></td>
3579+
<td class="belowdiagonal"></td>
35483580
<td></td>
35493581
<td>●</td>
35503582
<td>●</td>
@@ -3558,6 +3590,7 @@ the following algorithm returns <i>true</i>.
35583590
<td class="belowdiagonal"></td>
35593591
<td class="belowdiagonal"></td>
35603592
<td class="belowdiagonal"></td>
3593+
<td class="belowdiagonal"></td>
35613594
<td>(a)</td>
35623595
<td>●</td>
35633596
<td>●</td>
@@ -3571,6 +3604,7 @@ the following algorithm returns <i>true</i>.
35713604
<td class="belowdiagonal"></td>
35723605
<td class="belowdiagonal"></td>
35733606
<td class="belowdiagonal"></td>
3607+
<td class="belowdiagonal"></td>
35743608
<td></td>
35753609
<td></td>
35763610
<td>●</td>
@@ -3584,6 +3618,7 @@ the following algorithm returns <i>true</i>.
35843618
<td class="belowdiagonal"></td>
35853619
<td class="belowdiagonal"></td>
35863620
<td class="belowdiagonal"></td>
3621+
<td class="belowdiagonal"></td>
35873622
<td></td>
35883623
<td>●</td>
35893624
</tr>
@@ -3597,6 +3632,7 @@ the following algorithm returns <i>true</i>.
35973632
<td class="belowdiagonal"></td>
35983633
<td class="belowdiagonal"></td>
35993634
<td class="belowdiagonal"></td>
3635+
<td class="belowdiagonal"></td>
36003636
<td></td>
36013637
</tr>
36023638
</table>
@@ -5356,7 +5392,7 @@ the [=integer types=],
53565392
{{unrestricted double}}.
53575393

53585394
The <dfn id="dfn-primitive-type" export>primitive types</dfn> are
5359-
{{boolean}} and the [=numeric types=].
5395+
{{boolean}}, {{bigint}} and the [=numeric types=].
53605396

53615397
The <dfn id="dfn-string-type" export>string types</dfn> are
53625398
{{DOMString}}, all [=enumeration types=],
@@ -5464,6 +5500,7 @@ type.
54645500
"boolean"
54655501
"byte"
54665502
"octet"
5503+
"bigint"
54675504
</pre>
54685505

54695506
<pre class="grammar" id="prod-UnrestrictedFloatType">
@@ -5579,6 +5616,18 @@ The [=type name=] of the
55795616
{{octet}} type is "<code>Octet</code>".
55805617

55815618

5619+
<h4 id="idl-bigint" interface>bigint</h4>
5620+
5621+
The {{bigint}} type is an arbitrary integer, unrestricted in range.
5622+
5623+
{{bigint}} constant values in IDL are
5624+
represented with <emu-t class="regex"><a href="#prod-bigint">bigint</a></emu-t>
5625+
tokens.
5626+
5627+
The [=type name=] of the
5628+
{{bigint}} type is “BigInt”.
5629+
5630+
55825631
<h4 oldids="dom-short" id="idl-short" interface>short</h4>
55835632

55845633
The {{short}} type is a signed integer
@@ -6865,6 +6914,9 @@ ECMAScript value type.
68656914
1. If <a abstract-op>Type</a>(|V|) is Number, then
68666915
return the result of <a href="#es-to-unrestricted-double">converting</a> |V|
68676916
to an {{unrestricted double}}.
6917+
1. If <a abstract-op>Type</a>(|V|) is [=BigInt=], then
6918+
return the result of <a href="#es-to-bigint">converting</a> |V|
6919+
to an {{bigint}}.
68686920
1. If <a abstract-op>Type</a>(|V|) is String, then
68696921
return the result of <a href="#es-DOMString">converting</a> |V|
68706922
to a {{DOMString}}.
@@ -7295,6 +7347,27 @@ value when its bit pattern is interpreted as an unsigned 64 bit integer.
72957347
{{unrestricted double}} value.
72967348
</div>
72977349

7350+
<h4 id="es-bigint">bigint</h4>
7351+
7352+
<div id="es-to-bigint" algorithm="convert an ECMAScript value to a bigint">
7353+
7354+
An ECMAScript value |V| is [=converted to an IDL value|converted=]
7355+
to an IDL {{bigint}} value by running the following algorithm:
7356+
7357+
1. Let |x| be [=?=] <a abstract-op>ToBigInt</a>(|V|).
7358+
1. Return the IDL {{bigint}} value that represents the same numeric
7359+
value as |x|.
7360+
</div>
7361+
7362+
<div id="bigint-to-es" algorithm="convert a bigint to an ECMAScript value">
7363+
7364+
The result of [=converted to an ECMAScript value|converting=]
7365+
an IDL {{bigint}} value to an ECMAScript value is a [=BigInt=]:
7366+
7367+
1. Return the [=BigInt=] value that represents the same numeric value
7368+
as the IDL {{bigint}} value.
7369+
</div>
7370+
72987371

72997372
<h4 id="es-DOMString">DOMString</h4>
73007373

@@ -7989,23 +8062,30 @@ that correspond to the union’s [=member types=].
79898062
1. If |types| includes {{object}}, then return the IDL value
79908063
that is a reference to the object |V|.
79918064
1. If <a abstract-op>Type</a>(|V|) is Boolean, then:
7992-
1. If |types| includes a {{boolean}},
8065+
1. If |types| includes {{boolean}},
79938066
then return the result of [=converted to an IDL value|converting=]
79948067
|V| to {{boolean}}.
79958068
1. If <a abstract-op>Type</a>(|V|) is Number, then:
79968069
1. If |types| includes a [=numeric type=],
79978070
then return the result of [=converted to an IDL value|converting=]
79988071
|V| to that [=numeric type=].
8072+
1. If <a abstract-op>Type</a>(|V|) is [=BigInt=], then:
8073+
1. If |types| includes {{bigint}},
8074+
then return the result of [=converted to an IDL value|converting=]
8075+
|V| to {{bigint}}
79998076
1. If |types| includes a [=string type=],
80008077
then return the result of
80018078
[=converted to an IDL value|converting=]
80028079
|V| to that type.
80038080
1. If |types| includes a [=numeric type=],
80048081
then return the result of [=converted to an IDL value|converting=]
80058082
|V| to that [=numeric type=].
8006-
1. If |types| includes a {{boolean}},
8083+
1. If |types| includes {{boolean}},
80078084
then return the result of [=converted to an IDL value|converting=]
80088085
|V| to {{boolean}}.
8086+
1. If |types| includes a {{bigint}},
8087+
then return the result of [=converted to an IDL value|converting=]
8088+
|V| to {{bigint}}.
80098089
1. [=ECMAScript/Throw=] a {{ECMAScript/TypeError}}.
80108090
</div>
80118091

@@ -10593,6 +10673,16 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
1059310673

1059410674
then remove from |S| all other entries.
1059510675

10676+
1. Otherwise: if <a abstract-op>Type</a>(|V|) is [=BigInt=]
10677+
and there is an entry in |S| that has one of the following types at position |i| of its type list,
10678+
* {{bigint}}
10679+
* a [=nullable type|nullable=] {{bigint}}
10680+
* an [=annotated type=] whose [=annotated types/inner type=] is one of the above types
10681+
* a [=union type=], [=nullable type|nullable=] union type, or [=annotated type|annotated=] union type
10682+
that has one of the above types in its [=flattened member types=]
10683+
10684+
then remove from |S| all other entries.
10685+
1059610686
1. Otherwise: if there is an entry in |S| that has one of the following types at position |i| of its type list,
1059710687
* a [=string type=]
1059810688
* a [=nullable type|nullable=] version of any of the above types
@@ -10620,6 +10710,15 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
1062010710

1062110711
then remove from |S| all other entries.
1062210712

10713+
1. Otherwise: if there is an entry in |S| that has one of the following types at position |i| of its type list,
10714+
* {{bigint}}
10715+
* a [=nullable type|nullable=] {{bigint}}
10716+
* an [=annotated type=] whose [=annotated types/inner type=] is one of the above types
10717+
* a [=union type=], [=nullable type|nullable=] union type, or [=annotated type|annotated=] union type
10718+
that has one of the above types in its [=flattened member types=]
10719+
10720+
then remove from |S| all other entries.
10721+
1062310722
1. Otherwise: if there is an entry in |S| that has {{any}} at position |i|
1062410723
of its type list, then remove from |S| all other entries.
1062510724
1. Otherwise: [=ECMAScript/throw=] a {{ECMAScript/TypeError}}.
@@ -13569,6 +13668,11 @@ expression syntax [[!PERLRE]]) as follows:
1356913668
<td><code>=</code></td>
1357013669
<td><code class="regex"><span class="mute">/</span>-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)<span class="mute">/</span></code></td>
1357113670
</tr>
13671+
<tr>
13672+
<td id="prod-bigint"><emu-t class="regex">bigint</emu-t></td>
13673+
<td><code>=</code></td>
13674+
<td><code class="regex"><span class="mute">/</span>-?([1-9][0-9]*|0[Xx][0-9A-Fa-f]+|0[0-7]*)n<span class="mute">/</span></code></td>
13675+
</tr>
1357213676
<tr>
1357313677
<td id="prod-identifier"><emu-t class="regex">identifier</emu-t></td>
1357413678
<td><code>=</code></td>

0 commit comments

Comments
 (0)