@@ -21,7 +21,7 @@ public class JavaScriptEnvironment: ComponentBase {
2121 // TODO: use it in all places where it can be used.
2222 public static let typedArrayConstructors = [
2323 " Uint8Array " , " Int8Array " , " Uint16Array " , " Int16Array " ,
24- " Uint32Array " , " Int32Array " , " Float32Array " , " Float64Array " ,
24+ " Uint32Array " , " Int32Array " , " Float16Array " , " Float32Array " , " Float64Array " ,
2525 " Uint8ClampedArray " , " BigInt64Array " , " BigUint64Array " ,
2626 ]
2727
@@ -345,7 +345,7 @@ public class JavaScriptEnvironment: ComponentBase {
345345 registerObjectGroup ( . jsFinalizationRegistrys)
346346 registerObjectGroup ( . jsArrayBuffers)
347347 registerObjectGroup ( . jsSharedArrayBuffers)
348- for variant in [ " Uint8Array " , " Int8Array " , " Uint16Array " , " Int16Array " , " Uint32Array " , " Int32Array " , " Float32Array " , " Float64Array " , " Uint8ClampedArray " , " BigInt64Array " , " BigUint64Array " ] {
348+ for variant in [ " Uint8Array " , " Int8Array " , " Uint16Array " , " Int16Array " , " Uint32Array " , " Int32Array " , " Float16Array " , " Float32Array " , " Float64Array " , " Uint8ClampedArray " , " BigInt64Array " , " BigUint64Array " ] {
349349 registerObjectGroup ( . jsTypedArrays( variant) )
350350 }
351351 registerObjectGroup ( . jsUint8ArrayConstructor)
@@ -581,7 +581,7 @@ public class JavaScriptEnvironment: ComponentBase {
581581 registerBuiltin ( " ArrayBuffer " , ofType: . jsArrayBufferConstructor)
582582 registerBuiltin ( " SharedArrayBuffer " , ofType: . jsSharedArrayBufferConstructor)
583583 // Uint8Array handled below.
584- for variant in [ " Int8Array " , " Uint16Array " , " Int16Array " , " Uint32Array " , " Int32Array " , " Float32Array " , " Float64Array " , " Uint8ClampedArray " , " BigInt64Array " , " BigUint64Array " ] {
584+ for variant in [ " Int8Array " , " Uint16Array " , " Int16Array " , " Uint32Array " , " Int32Array " , " Float16Array " , " Float32Array " , " Float64Array " , " Uint8ClampedArray " , " BigInt64Array " , " BigUint64Array " ] {
585585 registerBuiltin ( variant, ofType: . jsTypedArrayConstructor( variant) )
586586 }
587587 registerBuiltin ( " Uint8Array " , ofType: . jsUint8ArrayConstructor)
@@ -1069,7 +1069,7 @@ public extension ILType {
10691069 static let jsSharedArrayBuffer = ILType . object ( ofGroup: " SharedArrayBuffer " , withProperties: [ " byteLength " , " maxByteLength " , " growable " ] , withMethods: [ " grow " , " slice " ] )
10701070
10711071 /// Type of a JavaScript DataView object.
1072- static let jsDataView = ILType . object ( ofGroup: " DataView " , withProperties: [ " buffer " , " byteLength " , " byteOffset " ] , withMethods: [ " getInt8 " , " getUint8 " , " getInt16 " , " getUint16 " , " getInt32 " , " getUint32 " , " getFloat32 " , " getFloat64 " , " getBigInt64 " , " setInt8 " , " setUint8 " , " setInt16 " , " setUint16 " , " setInt32 " , " setUint32 " , " setFloat32 " , " setFloat64 " , " setBigInt64 " ] )
1072+ static let jsDataView = ILType . object ( ofGroup: " DataView " , withProperties: [ " buffer " , " byteLength " , " byteOffset " ] , withMethods: [ " getInt8 " , " getUint8 " , " getInt16 " , " getUint16 " , " getInt32 " , " getUint32 " , " getFloat16 " , " getFloat32 " , " getFloat64 " , " getBigInt64 " , " setInt8 " , " setUint8 " , " setInt16 " , " setUint16 " , " setInt32 " , " setUint32 " , " setFloat16 " , " setFloat32 " , " setFloat64 " , " setBigInt64 " ] )
10731073
10741074 /// Type of a JavaScript TypedArray object of the given variant.
10751075 static func jsTypedArray( _ variant: String ) -> ILType {
@@ -1090,7 +1090,7 @@ public extension ILType {
10901090 static let jsObjectConstructor = . functionAndConstructor( [ . jsAnything... ] => . object( ) ) + . object( ofGroup: " ObjectConstructor " , withProperties: [ " prototype " ] , withMethods: [ " assign " , " fromEntries " , " getOwnPropertyDescriptor " , " getOwnPropertyDescriptors " , " getOwnPropertyNames " , " getOwnPropertySymbols " , " is " , " preventExtensions " , " seal " , " create " , " defineProperties " , " defineProperty " , " freeze " , " getPrototypeOf " , " setPrototypeOf " , " isExtensible " , " isFrozen " , " isSealed " , " keys " , " entries " , " values " ] )
10911091
10921092 /// Type of the JavaScript Array constructor builtin.
1093- static let jsArrayConstructor = . functionAndConstructor( [ . integer] => . jsArray) + . object( ofGroup: " ArrayConstructor " , withProperties: [ " prototype " ] , withMethods: [ " from " , " of " , " isArray " ] )
1093+ static let jsArrayConstructor = . functionAndConstructor( [ . integer] => . jsArray) + . object( ofGroup: " ArrayConstructor " , withProperties: [ " prototype " ] , withMethods: [ " from " , " fromAsync " , " of " , " isArray " ] )
10941094
10951095 /// Type of the JavaScript Function constructor builtin.
10961096 static let jsFunctionConstructor = ILType . constructor ( [ . string] => . jsFunction( Signature . forUnknownFunction) )
@@ -1111,7 +1111,7 @@ public extension ILType {
11111111 static let jsBigIntConstructor = ILType . function ( [ . number] => . bigint) + . object( ofGroup: " BigIntConstructor " , withProperties: [ " prototype " ] , withMethods: [ " asIntN " , " asUintN " ] )
11121112
11131113 /// Type of the JavaScript RegExp constructor builtin.
1114- static let jsRegExpConstructor = ILType . jsFunction ( [ . string] => . jsRegExp)
1114+ static let jsRegExpConstructor = ILType . jsFunction ( [ . string] => . jsRegExp) + . object ( ofGroup : " RegExpConstructor " , withProperties : [ ] , withMethods : [ " escape " ] )
11151115
11161116 /// Type of a JavaScript Error object of the given variant.
11171117 static func jsError( _ variant: String ) -> ILType {
@@ -1120,6 +1120,7 @@ public extension ILType {
11201120
11211121 /// Type of the JavaScript Error constructor builtin
11221122 static func jsErrorConstructor( _ variant: String ) -> ILType {
1123+ // TODO: Add `Error.isError()`
11231124 return . functionAndConstructor( [ . opt( . string) ] => . jsError( variant) )
11241125 }
11251126
@@ -1142,7 +1143,7 @@ public extension ILType {
11421143 static let jsDataViewConstructor = ILType . constructor ( [ . plain( . jsArrayBuffer) , . opt( . integer) , . opt( . integer) ] => . jsDataView)
11431144
11441145 /// Type of the JavaScript Promise constructor builtin.
1145- static let jsPromiseConstructor = ILType . constructor ( [ . function( ) ] => . jsPromise) + . object( ofGroup: " PromiseConstructor " , withProperties: [ " prototype " ] , withMethods: [ " resolve " , " reject " , " all " , " any " , " race " , " allSettled " ] )
1146+ static let jsPromiseConstructor = ILType . constructor ( [ . function( ) ] => . jsPromise) + . object( ofGroup: " PromiseConstructor " , withProperties: [ " prototype " ] , withMethods: [ " resolve " , " reject " , " all " , " any " , " race " , " allSettled " , " try " ] )
11461147
11471148 /// Type of the JavaScript Proxy constructor builtin.
11481149 static let jsProxyConstructor = ILType . constructor ( [ . object( ) , . object( ) ] => . jsAnything)
@@ -1166,7 +1167,7 @@ public extension ILType {
11661167 static let jsFinalizationRegistryConstructor = ILType . constructor ( [ . function( ) ] => . jsFinalizationRegistry)
11671168
11681169 /// Type of the JavaScript Math constructor builtin.
1169- static let jsMathObject = ILType . object ( ofGroup: " Math " , withProperties: [ " E " , " PI " ] , withMethods: [ " abs " , " acos " , " acosh " , " asin " , " asinh " , " atan " , " atanh " , " atan2 " , " ceil " , " cbrt " , " expm1 " , " clz32 " , " cos " , " cosh " , " exp " , " floor " , " fround " , " hypot " , " imul " , " log " , " log1p " , " log2 " , " log10 " , " max " , " min " , " pow " , " random " , " round " , " sign " , " sin " , " sinh " , " sqrt " , " tan " , " tanh " , " trunc " ] )
1170+ static let jsMathObject = ILType . object ( ofGroup: " Math " , withProperties: [ " E " , " PI " ] , withMethods: [ " abs " , " acos " , " acosh " , " asin " , " asinh " , " atan " , " atanh " , " atan2 " , " ceil " , " cbrt " , " expm1 " , " clz32 " , " cos " , " cosh " , " exp " , " floor " , " fround " , " f16round " , " hypot " , " imul " , " log " , " log1p " , " log2 " , " log10 " , " max " , " min " , " pow " , " random " , " round " , " sign " , " sin " , " sinh " , " sqrt " , " sumPrecise " , " tan " , " tanh " , " trunc " ] )
11701171
11711172 /// Type of the JavaScript Date object
11721173 static let jsDate = ILType . object ( ofGroup: " Date " , withMethods: [ " toISOString " , " toDateString " , " toTimeString " , " toLocaleString " , " getTime " , " getFullYear " , " getUTCFullYear " , " getMonth " , " getUTCMonth " , " getDate " , " getUTCDate " , " getDay " , " getUTCDay " , " getHours " , " getUTCHours " , " getMinutes " , " getUTCMinutes " , " getSeconds " , " getUTCSeconds " , " getMilliseconds " , " getUTCMilliseconds " , " getTimezoneOffset " , " getYear " , " setTime " , " setMilliseconds " , " setUTCMilliseconds " , " setSeconds " , " setUTCSeconds " , " setMinutes " , " setUTCMinutes " , " setHours " , " setUTCHours " , " setDate " , " setUTCDate " , " setMonth " , " setUTCMonth " , " setFullYear " , " setUTCFullYear " , " setYear " , " toJSON " , " toUTCString " , " toGMTString " , " toTemporalInstant " ] )
@@ -1773,6 +1774,7 @@ public extension ObjectGroup {
17731774 " getUint16 " : [ . integer] => . integer,
17741775 " getInt32 " : [ . integer] => . integer,
17751776 " getUint32 " : [ . integer] => . integer,
1777+ " getFloat16 " : [ . integer] => . float,
17761778 " getFloat32 " : [ . integer] => . float,
17771779 " getFloat64 " : [ . integer] => . float,
17781780 " getBigInt64 " : [ . integer] => . bigint,
@@ -1782,6 +1784,7 @@ public extension ObjectGroup {
17821784 " setUint16 " : [ . integer, . integer] => . undefined,
17831785 " setInt32 " : [ . integer, . integer] => . undefined,
17841786 " setUint32 " : [ . integer, . integer] => . undefined,
1787+ " setFloat16 " : [ . integer, . float] => . undefined,
17851788 " setFloat32 " : [ . integer, . float] => . undefined,
17861789 " setFloat64 " : [ . integer, . float] => . undefined,
17871790 " setBigInt64 " : [ . integer, . bigint] => . undefined,
@@ -1805,6 +1808,7 @@ public extension ObjectGroup {
18051808 " any " : [ . jsPromise... ] => . jsPromise,
18061809 " race " : [ . jsPromise... ] => . jsPromise,
18071810 " allSettled " : [ . jsPromise... ] => . jsPromise,
1811+ " try " : [ . function( ) , . jsAnything... ] => . jsPromise,
18081812 ]
18091813 )
18101814
@@ -1922,9 +1926,10 @@ public extension ObjectGroup {
19221926 " prototype " : . jsArray,
19231927 ] ,
19241928 methods: [
1925- " from " : [ . jsAnything, . opt( . function( ) ) , . opt( . object( ) ) ] => . jsArray,
1926- " isArray " : [ . jsAnything] => . boolean,
1927- " of " : [ . jsAnything... ] => . jsArray,
1929+ " from " : [ . jsAnything, . opt( . function( ) ) , . opt( . object( ) ) ] => . jsArray,
1930+ " fromAsync " : [ . jsAnything, . opt( . function( ) ) , . opt( . object( ) ) ] => . jsPromise,
1931+ " isArray " : [ . jsAnything] => . boolean,
1932+ " of " : [ . jsAnything... ] => . jsArray,
19281933 ]
19291934 )
19301935
@@ -2013,6 +2018,19 @@ public extension ObjectGroup {
20132018 ]
20142019 )
20152020
2021+ /// Object group modelling the JavaScript RegExp constructor builtin
2022+ static let jsRegExpConstructor = ObjectGroup (
2023+ name: " RegExpConstructor " ,
2024+ constructorPath: " RegExp " ,
2025+ instanceType: . jsRegExpConstructor,
2026+ properties: [
2027+ " prototype " : . object( )
2028+ ] ,
2029+ methods: [
2030+ " escape " : [ . string] => . jsString,
2031+ ]
2032+ )
2033+
20162034 /// Object group modelling the JavaScript Boolean constructor builtin
20172035 static let jsBooleanConstructor = ObjectGroup (
20182036 name: " BooleanConstructor " ,
@@ -2058,41 +2076,43 @@ public extension ObjectGroup {
20582076 " PI " : . number
20592077 ] ,
20602078 methods: [
2061- " abs " : [ . jsAnything] => . number,
2062- " acos " : [ . jsAnything] => . number,
2063- " acosh " : [ . jsAnything] => . number,
2064- " asin " : [ . jsAnything] => . number,
2065- " asinh " : [ . jsAnything] => . number,
2066- " atan " : [ . jsAnything] => . number,
2067- " atanh " : [ . jsAnything] => . number,
2068- " atan2 " : [ . jsAnything, . jsAnything] => . number,
2069- " cbrt " : [ . jsAnything] => . number,
2070- " ceil " : [ . jsAnything] => . number,
2071- " clz32 " : [ . jsAnything] => . number,
2072- " cos " : [ . jsAnything] => . number,
2073- " cosh " : [ . jsAnything] => . number,
2074- " exp " : [ . jsAnything] => . number,
2075- " expm1 " : [ . jsAnything] => . number,
2076- " floor " : [ . jsAnything] => . number,
2077- " fround " : [ . jsAnything] => . number,
2078- " hypot " : [ . jsAnything... ] => . number,
2079- " imul " : [ . jsAnything, . jsAnything] => . integer,
2080- " log " : [ . jsAnything] => . number,
2081- " log1p " : [ . jsAnything] => . number,
2082- " log10 " : [ . jsAnything] => . number,
2083- " log2 " : [ . jsAnything] => . number,
2084- " max " : [ . jsAnything... ] => . jsAnything,
2085- " min " : [ . jsAnything... ] => . jsAnything,
2086- " pow " : [ . jsAnything, . jsAnything] => . number,
2087- " random " : [ ] => . number,
2088- " round " : [ . jsAnything] => . number,
2089- " sign " : [ . jsAnything] => . number,
2090- " sin " : [ . jsAnything] => . number,
2091- " sinh " : [ . jsAnything] => . number,
2092- " sqrt " : [ . jsAnything] => . number,
2093- " tan " : [ . jsAnything] => . number,
2094- " tanh " : [ . jsAnything] => . number,
2095- " trunc " : [ . jsAnything] => . number,
2079+ " abs " : [ . jsAnything] => . number,
2080+ " acos " : [ . jsAnything] => . number,
2081+ " acosh " : [ . jsAnything] => . number,
2082+ " asin " : [ . jsAnything] => . number,
2083+ " asinh " : [ . jsAnything] => . number,
2084+ " atan " : [ . jsAnything] => . number,
2085+ " atanh " : [ . jsAnything] => . number,
2086+ " atan2 " : [ . jsAnything, . jsAnything] => . number,
2087+ " cbrt " : [ . jsAnything] => . number,
2088+ " ceil " : [ . jsAnything] => . number,
2089+ " clz32 " : [ . jsAnything] => . number,
2090+ " cos " : [ . jsAnything] => . number,
2091+ " cosh " : [ . jsAnything] => . number,
2092+ " exp " : [ . jsAnything] => . number,
2093+ " expm1 " : [ . jsAnything] => . number,
2094+ " floor " : [ . jsAnything] => . number,
2095+ " fround " : [ . jsAnything] => . number,
2096+ " f16round " : [ . jsAnything] => . number,
2097+ " hypot " : [ . jsAnything... ] => . number,
2098+ " imul " : [ . jsAnything, . jsAnything] => . integer,
2099+ " log " : [ . jsAnything] => . number,
2100+ " log1p " : [ . jsAnything] => . number,
2101+ " log10 " : [ . jsAnything] => . number,
2102+ " log2 " : [ . jsAnything] => . number,
2103+ " max " : [ . jsAnything... ] => . jsAnything,
2104+ " min " : [ . jsAnything... ] => . jsAnything,
2105+ " pow " : [ . jsAnything, . jsAnything] => . number,
2106+ " random " : [ ] => . number,
2107+ " round " : [ . jsAnything] => . number,
2108+ " sign " : [ . jsAnything] => . number,
2109+ " sin " : [ . jsAnything] => . number,
2110+ " sinh " : [ . jsAnything] => . number,
2111+ " sqrt " : [ . jsAnything] => . number,
2112+ " sumPrecise " : [ . jsAnything] => . number,
2113+ " tan " : [ . jsAnything] => . number,
2114+ " tanh " : [ . jsAnything] => . number,
2115+ " trunc " : [ . jsAnything] => . number,
20962116 ]
20972117 )
20982118
0 commit comments