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