Skip to content

Commit 7cfcc0e

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. 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 2b1a990 commit 7cfcc0e

File tree

1 file changed

+87
-1
lines changed

1 file changed

+87
-1
lines changed

index.bs

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,21 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
158158
text: NewTarget; url: sec-built-in-function-objects
159159
text: Number Type; url: sec-ecmascript-language-types-number-type
160160
text: JSON.stringify; url: sec-json.stringify
161+
urlPrefix: https://tc39.github.io/proposal-bigint/; spec: BIGINT
162+
text: ToBigInt; url: #sec-to-bigint; type: abstract-op
163+
text: BigInt; url: #sec-ecmascript-language-types-bigint-type; type: dfn
161164
</pre>
162165

163166
<pre class=biblio>
164167
{
165168
"GEOMETRY": {
166169
"aliasOf": "GEOMETRY-1"
170+
},
171+
"BIGINT": {
172+
"href": "https://tc39.github.io/proposal-bigint/",
173+
"title": "BigInt Specification",
174+
"publisher": "TC39",
175+
"status": "Stage 3 proposal"
167176
}
168177
}
169178
</pre>
@@ -3010,6 +3019,9 @@ the following algorithm returns <i>true</i>.
30103019
</div></th>
30113020
<th><div>
30123021
<span>numeric types</span>
3022+
</div></th>
3023+
<th><div>
3024+
<span>bigint</span>
30133025
</div></th>
30143026
<th><div>
30153027
<span>string types</span>
@@ -3044,6 +3056,7 @@ the following algorithm returns <i>true</i>.
30443056
<td>●</td>
30453057
<td>●</td>
30463058
<td>●</td>
3059+
<td>●</td>
30473060
</tr>
30483061
<tr>
30493062
<th>numeric types</th>
@@ -3056,11 +3069,26 @@ the following algorithm returns <i>true</i>.
30563069
<td>●</td>
30573070
<td>●</td>
30583071
<td>●</td>
3072+
<td>●</td>
3073+
</tr>
3074+
<tr>
3075+
<th>bigint</th>
3076+
<td class="belowdiagonal"></td>
3077+
<td class="belowdiagonal"></td>
3078+
<td></td>
3079+
<td>●</td>
3080+
<td>●</td>
3081+
<td>●</td>
3082+
<td>●</td>
3083+
<td>●</td>
3084+
<td>●</td>
3085+
<td>●</td>
30593086
</tr>
30603087
<tr>
30613088
<th>string types</th>
30623089
<td class="belowdiagonal"></td>
30633090
<td class="belowdiagonal"></td>
3091+
<td class="belowdiagonal"></td>
30643092
<td></td>
30653093
<td>●</td>
30663094
<td>●</td>
@@ -3074,6 +3102,7 @@ the following algorithm returns <i>true</i>.
30743102
<td class="belowdiagonal"></td>
30753103
<td class="belowdiagonal"></td>
30763104
<td class="belowdiagonal"></td>
3105+
<td class="belowdiagonal"></td>
30773106
<td></td>
30783107
<td>●</td>
30793108
<td></td>
@@ -3087,6 +3116,7 @@ the following algorithm returns <i>true</i>.
30873116
<td class="belowdiagonal"></td>
30883117
<td class="belowdiagonal"></td>
30893118
<td class="belowdiagonal"></td>
3119+
<td class="belowdiagonal"></td>
30903120
<td></td>
30913121
<td>●</td>
30923122
<td>●</td>
@@ -3100,6 +3130,7 @@ the following algorithm returns <i>true</i>.
31003130
<td class="belowdiagonal"></td>
31013131
<td class="belowdiagonal"></td>
31023132
<td class="belowdiagonal"></td>
3133+
<td class="belowdiagonal"></td>
31033134
<td>(a)</td>
31043135
<td>●</td>
31053136
<td>●</td>
@@ -3113,6 +3144,7 @@ the following algorithm returns <i>true</i>.
31133144
<td class="belowdiagonal"></td>
31143145
<td class="belowdiagonal"></td>
31153146
<td class="belowdiagonal"></td>
3147+
<td class="belowdiagonal"></td>
31163148
<td></td>
31173149
<td></td>
31183150
<td>●</td>
@@ -3126,6 +3158,7 @@ the following algorithm returns <i>true</i>.
31263158
<td class="belowdiagonal"></td>
31273159
<td class="belowdiagonal"></td>
31283160
<td class="belowdiagonal"></td>
3161+
<td class="belowdiagonal"></td>
31293162
<td></td>
31303163
<td>●</td>
31313164
</tr>
@@ -3139,6 +3172,7 @@ the following algorithm returns <i>true</i>.
31393172
<td class="belowdiagonal"></td>
31403173
<td class="belowdiagonal"></td>
31413174
<td class="belowdiagonal"></td>
3175+
<td class="belowdiagonal"></td>
31423176
<td></td>
31433177
</tr>
31443178
</table>
@@ -4783,7 +4817,7 @@ the [=integer types=],
47834817
{{unrestricted double}}.
47844818

47854819
The <dfn id="dfn-primitive-type" export>primitive types</dfn> are
4786-
{{boolean}} and the [=numeric types=].
4820+
{{boolean}}, {{bigint}} and the [=numeric types=].
47874821

47884822
The <dfn id="dfn-string-type" export>string types</dfn> are
47894823
{{DOMString}}, all [=enumeration types=],
@@ -4892,6 +4926,7 @@ type.
48924926
"boolean"
48934927
"byte"
48944928
"octet"
4929+
"bigint"
48954930
</pre>
48964931

48974932
<pre class="grammar" id="prod-UnrestrictedFloatType">
@@ -5007,6 +5042,18 @@ The [=type name=] of the
50075042
{{octet}} type is “Octet”.
50085043

50095044

5045+
<h4 id="idl-bigint" interface>bigint</h4>
5046+
5047+
The {{bigint}} type is an arbitrary integer, unrestricted in range.
5048+
5049+
{{bigint}} constant values in IDL are
5050+
represented with <emu-t class="regex"><a href="#prod-bigint">bigint</a></emu-t>
5051+
tokens.
5052+
5053+
The [=type name=] of the
5054+
{{bigint}} type is “BigInt”.
5055+
5056+
50105057
<h4 oldids="dom-short" id="idl-short" interface>short</h4>
50115058

50125059
The {{short}} type is a signed integer
@@ -6290,6 +6337,9 @@ ECMAScript value type.
62906337
1. If <a abstract-op>Type</a>(|V|) is Number, then
62916338
return the result of <a href="#es-to-unrestricted-double">converting</a> |V|
62926339
to an {{unrestricted double}}.
6340+
1. If <a abstract-op>Type</a>(|V|) is [=BigInt=], then
6341+
return the result of <a href="#es-to-bigint">converting</a> |V|
6342+
to an {{bigint}}.
62936343
1. If <a abstract-op>Type</a>(|V|) is String, then
62946344
return the result of <a href="#es-DOMString">converting</a> |V|
62956345
to a {{DOMString}}.
@@ -6720,6 +6770,27 @@ value when its bit pattern is interpreted as an unsigned 64 bit integer.
67206770
{{unrestricted double}} value.
67216771
</div>
67226772

6773+
<h4 id="es-bigint">bigint</h4>
6774+
6775+
<div id="es-to-bigint" algorithm="convert an ECMAScript value to a bigint">
6776+
6777+
An ECMAScript value |V| is [=converted to an IDL value|converted=]
6778+
to an IDL {{bigint}} value by running the following algorithm:
6779+
6780+
1. Let |x| be [=?=] <a abstract-op>ToBigInt</a>(|V|).
6781+
1. Return the IDL {{bigint}} value that represents the same numeric
6782+
value as |x|.
6783+
</div>
6784+
6785+
<div id="bigint-to-es" algorithm="convert a bigint to an ECMAScript value">
6786+
6787+
The result of [=converted to an ECMAScript value|converting=]
6788+
an IDL {{bigint}} value to an ECMAScript value is a [=BigInt=]:
6789+
6790+
1. Return the [=BigInt=] value that represents the same numeric value
6791+
as the IDL {{bigint}} value.
6792+
</div>
6793+
67236794

67246795
<h4 id="es-DOMString">DOMString</h4>
67256796

@@ -9957,6 +10028,16 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]
995710028

995810029
then remove from |S| all other entries.
995910030

10031+
1. Otherwise: if <a abstract-op>Type</a>(|V|) is [=BigInt=]
10032+
and there is an entry in |S| that has one of the following types at position |i| of its type list,
10033+
* {{bigint}}
10034+
* a [=nullable type|nullable=] {{bigint}}
10035+
* an [=annotated type=] whose [=annotated types/inner type=] is one of the above types
10036+
* a [=union type=], [=nullable type|nullable=] union type, or [=annotated type|annotated=] union type
10037+
that has one of the above types in its [=flattened member types=]
10038+
10039+
then remove from |S| all other entries.
10040+
996010041
1. Otherwise: if there is an entry in |S| that has one of the following types at position |i| of its type list,
996110042
* a [=string type=]
996210043
* a [=nullable type|nullable=] version of any of the above types
@@ -13046,6 +13127,11 @@ expression syntax [[!PERLRE]]) as follows:
1304613127
<td><code>=</code></td>
1304713128
<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>
1304813129
</tr>
13130+
<tr>
13131+
<td id="prod-bigint"><emu-t class="regex">bigint</emu-t></td>
13132+
<td><code>=</code></td>
13133+
<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>
13134+
</tr>
1304913135
<tr>
1305013136
<td id="prod-identifier"><emu-t class="regex">identifier</emu-t></td>
1305113137
<td><code>=</code></td>

0 commit comments

Comments
 (0)