Skip to content

Commit 37ff443

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. For good measure, symbol is added as well (it appears to have been missing). 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 4e32b14 commit 37ff443

File tree

1 file changed

+106
-4
lines changed

1 file changed

+106
-4
lines changed

index.bs

Lines changed: 106 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>
@@ -1591,7 +1600,8 @@ constant declaration gives the value of the constant, which can be
15911600
one of the two boolean literal tokens (<emu-t>true</emu-t>
15921601
and <emu-t>false</emu-t>),
15931602
the <emu-t>null</emu-t> token, an
1594-
<emu-t class="regex"><a href="#prod-integer">integer</a></emu-t> token,
1603+
<emu-t class="regex"><a href="#prod-integer">integer</a></emu-t> token, a
1604+
<emu-t class="regex"><a href="#prod-bigint">bigint</a></emu-t> token,
15951605
a <emu-t class="regex"><a href="#prod-float">float</a></emu-t> token,
15961606
or one of the three special floating point constant values
15971607
(<emu-t>-Infinity</emu-t>, <emu-t>Infinity</emu-t> and <emu-t>NaN</emu-t>).
@@ -1733,6 +1743,7 @@ The following extended attributes are applicable to constants:
17331743
BooleanLiteral
17341744
FloatLiteral
17351745
integer
1746+
bigint
17361747
"null"
17371748
</pre>
17381749

@@ -3467,6 +3478,9 @@ the following algorithm returns <i>true</i>.
34673478
</div></th>
34683479
<th><div>
34693480
<span>numeric types</span>
3481+
</div></th>
3482+
<th><div>
3483+
<span>bigint</span>
34703484
</div></th>
34713485
<th><div>
34723486
<span>string types</span>
@@ -3501,6 +3515,7 @@ the following algorithm returns <i>true</i>.
35013515
<td>●</td>
35023516
<td>●</td>
35033517
<td>●</td>
3518+
<td>●</td>
35043519
</tr>
35053520
<tr>
35063521
<th>numeric types</th>
@@ -3513,11 +3528,26 @@ the following algorithm returns <i>true</i>.
35133528
<td>●</td>
35143529
<td>●</td>
35153530
<td>●</td>
3531+
<td>●</td>
3532+
</tr>
3533+
<tr>
3534+
<th>bigint</th>
3535+
<td class="belowdiagonal"></td>
3536+
<td class="belowdiagonal"></td>
3537+
<td></td>
3538+
<td>●</td>
3539+
<td>●</td>
3540+
<td>●</td>
3541+
<td>●</td>
3542+
<td>●</td>
3543+
<td>●</td>
3544+
<td>●</td>
35163545
</tr>
35173546
<tr>
35183547
<th>string types</th>
35193548
<td class="belowdiagonal"></td>
35203549
<td class="belowdiagonal"></td>
3550+
<td class="belowdiagonal"></td>
35213551
<td></td>
35223552
<td>●</td>
35233553
<td>●</td>
@@ -3531,6 +3561,7 @@ the following algorithm returns <i>true</i>.
35313561
<td class="belowdiagonal"></td>
35323562
<td class="belowdiagonal"></td>
35333563
<td class="belowdiagonal"></td>
3564+
<td class="belowdiagonal"></td>
35343565
<td></td>
35353566
<td>●</td>
35363567
<td></td>
@@ -3544,6 +3575,7 @@ the following algorithm returns <i>true</i>.
35443575
<td class="belowdiagonal"></td>
35453576
<td class="belowdiagonal"></td>
35463577
<td class="belowdiagonal"></td>
3578+
<td class="belowdiagonal"></td>
35473579
<td></td>
35483580
<td>●</td>
35493581
<td>●</td>
@@ -3557,6 +3589,7 @@ the following algorithm returns <i>true</i>.
35573589
<td class="belowdiagonal"></td>
35583590
<td class="belowdiagonal"></td>
35593591
<td class="belowdiagonal"></td>
3592+
<td class="belowdiagonal"></td>
35603593
<td>(a)</td>
35613594
<td>●</td>
35623595
<td>●</td>
@@ -3570,6 +3603,7 @@ the following algorithm returns <i>true</i>.
35703603
<td class="belowdiagonal"></td>
35713604
<td class="belowdiagonal"></td>
35723605
<td class="belowdiagonal"></td>
3606+
<td class="belowdiagonal"></td>
35733607
<td></td>
35743608
<td></td>
35753609
<td>●</td>
@@ -3583,6 +3617,7 @@ the following algorithm returns <i>true</i>.
35833617
<td class="belowdiagonal"></td>
35843618
<td class="belowdiagonal"></td>
35853619
<td class="belowdiagonal"></td>
3620+
<td class="belowdiagonal"></td>
35863621
<td></td>
35873622
<td>●</td>
35883623
</tr>
@@ -3596,6 +3631,7 @@ the following algorithm returns <i>true</i>.
35963631
<td class="belowdiagonal"></td>
35973632
<td class="belowdiagonal"></td>
35983633
<td class="belowdiagonal"></td>
3634+
<td class="belowdiagonal"></td>
35993635
<td></td>
36003636
</tr>
36013637
</table>
@@ -5355,7 +5391,7 @@ the [=integer types=],
53555391
{{unrestricted double}}.
53565392

53575393
The <dfn id="dfn-primitive-type" export>primitive types</dfn> are
5358-
{{boolean}} and the [=numeric types=].
5394+
{{boolean}}, {{bigint}} and the [=numeric types=].
53595395

53605396
The <dfn id="dfn-string-type" export>string types</dfn> are
53615397
{{DOMString}}, all [=enumeration types=],
@@ -5463,6 +5499,7 @@ type.
54635499
"boolean"
54645500
"byte"
54655501
"octet"
5502+
"bigint"
54665503
</pre>
54675504

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

55805617

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

55835632
The {{short}} type is a signed integer
@@ -6864,6 +6913,9 @@ ECMAScript value type.
68646913
1. If <a abstract-op>Type</a>(|V|) is Number, then
68656914
return the result of <a href="#es-to-unrestricted-double">converting</a> |V|
68666915
to an {{unrestricted double}}.
6916+
1. If <a abstract-op>Type</a>(|V|) is [=BigInt=], then
6917+
return the result of <a href="#es-to-bigint">converting</a> |V|
6918+
to an {{bigint}}.
68676919
1. If <a abstract-op>Type</a>(|V|) is String, then
68686920
return the result of <a href="#es-DOMString">converting</a> |V|
68696921
to a {{DOMString}}.
@@ -7294,6 +7346,27 @@ value when its bit pattern is interpreted as an unsigned 64 bit integer.
72947346
{{unrestricted double}} value.
72957347
</div>
72967348

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

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

@@ -7988,23 +8061,37 @@ that correspond to the union’s [=member types=].
79888061
1. If |types| includes {{object}}, then return the IDL value
79898062
that is a reference to the object |V|.
79908063
1. If <a abstract-op>Type</a>(|V|) is Boolean, then:
7991-
1. If |types| includes a {{boolean}},
8064+
1. If |types| includes {{boolean}},
79928065
then return the result of [=converted to an IDL value|converting=]
79938066
|V| to {{boolean}}.
79948067
1. If <a abstract-op>Type</a>(|V|) is Number, then:
79958068
1. If |types| includes a [=numeric type=],
79968069
then return the result of [=converted to an IDL value|converting=]
79978070
|V| to that [=numeric type=].
8071+
1. If <a abstract-op>Type</a>(|V|) is Symbol, then:
8072+
1. If |types| includes {{symbol}},
8073+
then return the result of [=converted to an IDL value|converting=]
8074+
|V| to {{symbol}}
8075+
1. If <a abstract-op>Type</a>(|V|) is [=BigInt=], then:
8076+
1. If |types| includes {{bigint}},
8077+
then return the result of [=converted to an IDL value|converting=]
8078+
|V| to {{bigint}}
79988079
1. If |types| includes a [=string type=],
79998080
then return the result of
80008081
[=converted to an IDL value|converting=]
80018082
|V| to that type.
80028083
1. If |types| includes a [=numeric type=],
80038084
then return the result of [=converted to an IDL value|converting=]
80048085
|V| to that [=numeric type=].
8005-
1. If |types| includes a {{boolean}},
8086+
1. If |types| includes {{boolean}},
80068087
then return the result of [=converted to an IDL value|converting=]
80078088
|V| to {{boolean}}.
8089+
1. If |types| includes {{symbol}},
8090+
then return the result of [=converted to an IDL value|converting=]
8091+
|V| to {{symbol}}.
8092+
1. If |types| includes a {{bigint}},
8093+
then return the result of [=converted to an IDL value|converting=]
8094+
|V| to {{bigint}}.
80088095
1. [=ECMAScript/Throw=] a {{ECMAScript/TypeError}}.
80098096
</div>
80108097

@@ -10592,6 +10679,16 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
1059210679

1059310680
then remove from |S| all other entries.
1059410681

10682+
1. Otherwise: if <a abstract-op>Type</a>(|V|) is [=BigInt=]
10683+
and there is an entry in |S| that has one of the following types at position |i| of its type list,
10684+
* {{bigint}}
10685+
* a [=nullable type|nullable=] {{bigint}}
10686+
* an [=annotated type=] whose [=annotated types/inner type=] is one of the above types
10687+
* a [=union type=], [=nullable type|nullable=] union type, or [=annotated type|annotated=] union type
10688+
that has one of the above types in its [=flattened member types=]
10689+
10690+
then remove from |S| all other entries.
10691+
1059510692
1. Otherwise: if there is an entry in |S| that has one of the following types at position |i| of its type list,
1059610693
* a [=string type=]
1059710694
* a [=nullable type|nullable=] version of any of the above types
@@ -13568,6 +13665,11 @@ expression syntax [[!PERLRE]]) as follows:
1356813665
<td><code>=</code></td>
1356913666
<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>
1357013667
</tr>
13668+
<tr>
13669+
<td id="prod-bigint"><emu-t class="regex">bigint</emu-t></td>
13670+
<td><code>=</code></td>
13671+
<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>
13672+
</tr>
1357113673
<tr>
1357213674
<td id="prod-identifier"><emu-t class="regex">identifier</emu-t></td>
1357313675
<td><code>=</code></td>

0 commit comments

Comments
 (0)