| 1 |
// GENERATED, DO NOT EDIT |
| 2 |
// file: isConstructor.js |
| 3 |
// Copyright (C) 2017 André Bargull. All rights reserved. |
| 4 |
// This code is governed by the BSD license found in the LICENSE file. |
| 5 |
|
| 6 |
/*--- |
| 7 |
description: | |
| 8 |
Test if a given function is a constructor function. |
| 9 |
defines: [isConstructor] |
| 10 |
features: [Reflect.construct] |
| 11 |
---*/ |
| 12 |
|
| 13 |
function isConstructor(f) { |
| 14 |
if (typeof f !== "function") { |
| 15 |
throw new Test262Error("isConstructor invoked with a non-function value"); |
| 16 |
} |
| 17 |
|
| 18 |
try { |
| 19 |
Reflect.construct(function(){}, [], f); |
| 20 |
} catch (e) { |
| 21 |
return false; |
| 22 |
} |
| 23 |
return true; |
| 24 |
} |
| 25 |
|
| 26 |
// file: wellKnownIntrinsicObjects.js |
| 27 |
// Copyright (C) 2018 the V8 project authors. All rights reserved. |
| 28 |
// This code is governed by the BSD license found in the LICENSE file. |
| 29 |
/*--- |
| 30 |
description: | |
| 31 |
An Array of all representable Well-Known Intrinsic Objects |
| 32 |
defines: [WellKnownIntrinsicObjects, getWellKnownIntrinsicObject] |
| 33 |
---*/ |
| 34 |
|
| 35 |
const WellKnownIntrinsicObjects = [ |
| 36 |
{ |
| 37 |
name: '%AggregateError%', |
| 38 |
source: 'AggregateError', |
| 39 |
}, |
| 40 |
{ |
| 41 |
name: '%Array%', |
| 42 |
source: 'Array', |
| 43 |
}, |
| 44 |
{ |
| 45 |
name: '%ArrayBuffer%', |
| 46 |
source: 'ArrayBuffer', |
| 47 |
}, |
| 48 |
{ |
| 49 |
name: '%ArrayIteratorPrototype%', |
| 50 |
source: 'Object.getPrototypeOf([][Symbol.iterator]())', |
| 51 |
}, |
| 52 |
{ |
| 53 |
// Not currently accessible to ECMAScript user code |
| 54 |
name: '%AsyncFromSyncIteratorPrototype%', |
| 55 |
source: '', |
| 56 |
}, |
| 57 |
{ |
| 58 |
name: '%AsyncFunction%', |
| 59 |
source: '(async function() {}).constructor', |
| 60 |
}, |
| 61 |
{ |
| 62 |
name: '%AsyncGeneratorFunction%', |
| 63 |
source: '(async function* () {}).constructor', |
| 64 |
}, |
| 65 |
{ |
| 66 |
name: '%AsyncGeneratorPrototype%', |
| 67 |
source: 'Object.getPrototypeOf(async function* () {}).prototype', |
| 68 |
}, |
| 69 |
{ |
| 70 |
name: '%AsyncIteratorPrototype%', |
| 71 |
source: '((async function * () {})())[Symbol.asyncIterator]()', |
| 72 |
}, |
| 73 |
{ |
| 74 |
name: '%Atomics%', |
| 75 |
source: 'Atomics', |
| 76 |
}, |
| 77 |
{ |
| 78 |
name: '%BigInt%', |
| 79 |
source: 'BigInt', |
| 80 |
}, |
| 81 |
{ |
| 82 |
name: '%BigInt64Array%', |
| 83 |
source: 'BigInt64Array', |
| 84 |
}, |
| 85 |
{ |
| 86 |
name: '%BigUint64Array%', |
| 87 |
source: 'BigUint64Array', |
| 88 |
}, |
| 89 |
{ |
| 90 |
name: '%Boolean%', |
| 91 |
source: 'Boolean', |
| 92 |
}, |
| 93 |
{ |
| 94 |
name: '%DataView%', |
| 95 |
source: 'DataView', |
| 96 |
}, |
| 97 |
{ |
| 98 |
name: '%Date%', |
| 99 |
source: 'Date', |
| 100 |
}, |
| 101 |
{ |
| 102 |
name: '%decodeURI%', |
| 103 |
source: 'decodeURI', |
| 104 |
}, |
| 105 |
{ |
| 106 |
name: '%decodeURIComponent%', |
| 107 |
source: 'decodeURIComponent', |
| 108 |
}, |
| 109 |
{ |
| 110 |
name: '%encodeURI%', |
| 111 |
source: 'encodeURI', |
| 112 |
}, |
| 113 |
{ |
| 114 |
name: '%encodeURIComponent%', |
| 115 |
source: 'encodeURIComponent', |
| 116 |
}, |
| 117 |
{ |
| 118 |
name: '%Error%', |
| 119 |
source: 'Error', |
| 120 |
}, |
| 121 |
{ |
| 122 |
name: '%eval%', |
| 123 |
source: 'eval', |
| 124 |
}, |
| 125 |
{ |
| 126 |
name: '%EvalError%', |
| 127 |
source: 'EvalError', |
| 128 |
}, |
| 129 |
{ |
| 130 |
name: '%FinalizationRegistry%', |
| 131 |
source: 'FinalizationRegistry', |
| 132 |
}, |
| 133 |
{ |
| 134 |
name: '%Float32Array%', |
| 135 |
source: 'Float32Array', |
| 136 |
}, |
| 137 |
{ |
| 138 |
name: '%Float64Array%', |
| 139 |
source: 'Float64Array', |
| 140 |
}, |
| 141 |
{ |
| 142 |
// Not currently accessible to ECMAScript user code |
| 143 |
name: '%ForInIteratorPrototype%', |
| 144 |
source: '', |
| 145 |
}, |
| 146 |
{ |
| 147 |
name: '%Function%', |
| 148 |
source: 'Function', |
| 149 |
}, |
| 150 |
{ |
| 151 |
name: '%GeneratorFunction%', |
| 152 |
source: '(function* () {}).constructor', |
| 153 |
}, |
| 154 |
{ |
| 155 |
name: '%GeneratorPrototype%', |
| 156 |
source: 'Object.getPrototypeOf(function * () {}).prototype', |
| 157 |
}, |
| 158 |
{ |
| 159 |
name: '%Int8Array%', |
| 160 |
source: 'Int8Array', |
| 161 |
}, |
| 162 |
{ |
| 163 |
name: '%Int16Array%', |
| 164 |
source: 'Int16Array', |
| 165 |
}, |
| 166 |
{ |
| 167 |
name: '%Int32Array%', |
| 168 |
source: 'Int32Array', |
| 169 |
}, |
| 170 |
{ |
| 171 |
name: '%isFinite%', |
| 172 |
source: 'isFinite', |
| 173 |
}, |
| 174 |
{ |
| 175 |
name: '%isNaN%', |
| 176 |
source: 'isNaN', |
| 177 |
}, |
| 178 |
{ |
| 179 |
name: '%Iterator%', |
| 180 |
source: 'typeof Iterator !== "undefined" ? Iterator : Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())).constructor', |
| 181 |
}, |
| 182 |
{ |
| 183 |
name: '%IteratorHelperPrototype%', |
| 184 |
source: 'Object.getPrototypeOf(Iterator.from([]).drop(0))', |
| 185 |
}, |
| 186 |
{ |
| 187 |
name: '%JSON%', |
| 188 |
source: 'JSON', |
| 189 |
}, |
| 190 |
{ |
| 191 |
name: '%Map%', |
| 192 |
source: 'Map', |
| 193 |
}, |
| 194 |
{ |
| 195 |
name: '%MapIteratorPrototype%', |
| 196 |
source: 'Object.getPrototypeOf(new Map()[Symbol.iterator]())', |
| 197 |
}, |
| 198 |
{ |
| 199 |
name: '%Math%', |
| 200 |
source: 'Math', |
| 201 |
}, |
| 202 |
{ |
| 203 |
name: '%Number%', |
| 204 |
source: 'Number', |
| 205 |
}, |
| 206 |
{ |
| 207 |
name: '%Object%', |
| 208 |
source: 'Object', |
| 209 |
}, |
| 210 |
{ |
| 211 |
name: '%parseFloat%', |
| 212 |
source: 'parseFloat', |
| 213 |
}, |
| 214 |
{ |
| 215 |
name: '%parseInt%', |
| 216 |
source: 'parseInt', |
| 217 |
}, |
| 218 |
{ |
| 219 |
name: '%Promise%', |
| 220 |
source: 'Promise', |
| 221 |
}, |
| 222 |
{ |
| 223 |
name: '%Proxy%', |
| 224 |
source: 'Proxy', |
| 225 |
}, |
| 226 |
{ |
| 227 |
name: '%RangeError%', |
| 228 |
source: 'RangeError', |
| 229 |
}, |
| 230 |
{ |
| 231 |
name: '%ReferenceError%', |
| 232 |
source: 'ReferenceError', |
| 233 |
}, |
| 234 |
{ |
| 235 |
name: '%Reflect%', |
| 236 |
source: 'Reflect', |
| 237 |
}, |
| 238 |
{ |
| 239 |
name: '%RegExp%', |
| 240 |
source: 'RegExp', |
| 241 |
}, |
| 242 |
{ |
| 243 |
name: '%RegExpStringIteratorPrototype%', |
| 244 |
source: 'RegExp.prototype[Symbol.matchAll]("")', |
| 245 |
}, |
| 246 |
{ |
| 247 |
name: '%Set%', |
| 248 |
source: 'Set', |
| 249 |
}, |
| 250 |
{ |
| 251 |
name: '%SetIteratorPrototype%', |
| 252 |
source: 'Object.getPrototypeOf(new Set()[Symbol.iterator]())', |
| 253 |
}, |
| 254 |
{ |
| 255 |
name: '%SharedArrayBuffer%', |
| 256 |
source: 'SharedArrayBuffer', |
| 257 |
}, |
| 258 |
{ |
| 259 |
name: '%String%', |
| 260 |
source: 'String', |
| 261 |
}, |
| 262 |
{ |
| 263 |
name: '%StringIteratorPrototype%', |
| 264 |
source: 'Object.getPrototypeOf(new String()[Symbol.iterator]())', |
| 265 |
}, |
| 266 |
{ |
| 267 |
name: '%Symbol%', |
| 268 |
source: 'Symbol', |
| 269 |
}, |
| 270 |
{ |
| 271 |
name: '%SyntaxError%', |
| 272 |
source: 'SyntaxError', |
| 273 |
}, |
| 274 |
{ |
| 275 |
name: '%ThrowTypeError%', |
| 276 |
source: '(function() { "use strict"; return Object.getOwnPropertyDescriptor(arguments, "callee").get })()', |
| 277 |
}, |
| 278 |
{ |
| 279 |
name: '%TypedArray%', |
| 280 |
source: 'Object.getPrototypeOf(Uint8Array)', |
| 281 |
}, |
| 282 |
{ |
| 283 |
name: '%TypeError%', |
| 284 |
source: 'TypeError', |
| 285 |
}, |
| 286 |
{ |
| 287 |
name: '%Uint8Array%', |
| 288 |
source: 'Uint8Array', |
| 289 |
}, |
| 290 |
{ |
| 291 |
name: '%Uint8ClampedArray%', |
| 292 |
source: 'Uint8ClampedArray', |
| 293 |
}, |
| 294 |
{ |
| 295 |
name: '%Uint16Array%', |
| 296 |
source: 'Uint16Array', |
| 297 |
}, |
| 298 |
{ |
| 299 |
name: '%Uint32Array%', |
| 300 |
source: 'Uint32Array', |
| 301 |
}, |
| 302 |
{ |
| 303 |
name: '%URIError%', |
| 304 |
source: 'URIError', |
| 305 |
}, |
| 306 |
{ |
| 307 |
name: '%WeakMap%', |
| 308 |
source: 'WeakMap', |
| 309 |
}, |
| 310 |
{ |
| 311 |
name: '%WeakRef%', |
| 312 |
source: 'WeakRef', |
| 313 |
}, |
| 314 |
{ |
| 315 |
name: '%WeakSet%', |
| 316 |
source: 'WeakSet', |
| 317 |
}, |
| 318 |
{ |
| 319 |
name: '%WrapForValidIteratorPrototype%', |
| 320 |
source: 'Object.getPrototypeOf(Iterator.from({ [Symbol.iterator](){ return {}; } }))', |
| 321 |
}, |
| 322 |
]; |
| 323 |
|
| 324 |
WellKnownIntrinsicObjects.forEach((wkio) => { |
| 325 |
var actual; |
| 326 |
|
| 327 |
try { |
| 328 |
actual = new Function("return " + wkio.source)(); |
| 329 |
} catch (exception) { |
| 330 |
// Nothing to do here. |
| 331 |
} |
| 332 |
|
| 333 |
wkio.value = actual; |
| 334 |
}); |
| 335 |
|
| 336 |
/** |
| 337 |
* Returns a well-known intrinsic object, if the implementation provides it. |
| 338 |
* Otherwise, throws. |
| 339 |
* @param {string} key - the specification's name for the intrinsic, for example |
| 340 |
* "%Array%" |
| 341 |
* @returns {object} the well-known intrinsic object. |
| 342 |
*/ |
| 343 |
function getWellKnownIntrinsicObject(key) { |
| 344 |
for (var ix = 0; ix < WellKnownIntrinsicObjects.length; ix++) { |
| 345 |
if (WellKnownIntrinsicObjects[ix].name === key) { |
| 346 |
var value = WellKnownIntrinsicObjects[ix].value; |
| 347 |
if (value !== undefined) |
| 348 |
return value; |
| 349 |
throw new Test262Error('this implementation could not obtain ' + key); |
| 350 |
} |
| 351 |
} |
| 352 |
throw new Test262Error('unknown well-known intrinsic ' + key); |
| 353 |
} |