OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, utils, extrasUtils) { | 5 (function(global, utils, extrasUtils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 }; | 439 }; |
440 | 440 |
441 // ------------------------------------------------------------------- | 441 // ------------------------------------------------------------------- |
442 // Install exported functions. | 442 // Install exported functions. |
443 | 443 |
444 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM); | 444 %AddNamedProperty(global, 'Promise', GlobalPromise, DONT_ENUM); |
445 %AddNamedProperty(GlobalPromise.prototype, toStringTagSymbol, "Promise", | 445 %AddNamedProperty(GlobalPromise.prototype, toStringTagSymbol, "Promise", |
446 DONT_ENUM | READ_ONLY); | 446 DONT_ENUM | READ_ONLY); |
447 | 447 |
448 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ | 448 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ |
449 "defer", PromiseDeferred, | |
450 "accept", PromiseResolved, | |
451 "reject", PromiseRejected, | 449 "reject", PromiseRejected, |
452 "all", PromiseAll, | 450 "all", PromiseAll, |
453 "race", PromiseRace, | 451 "race", PromiseRace, |
454 "resolve", PromiseCast | 452 "resolve", PromiseCast |
455 ]); | 453 ]); |
456 | 454 |
457 utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [ | 455 utils.InstallFunctions(GlobalPromise.prototype, DONT_ENUM, [ |
458 "chain", PromiseChain, | |
459 "then", PromiseThen, | 456 "then", PromiseThen, |
460 "catch", PromiseCatch | 457 "catch", PromiseCatch |
461 ]); | 458 ]); |
462 | 459 |
463 %InstallToContext([ | 460 %InstallToContext([ |
464 "promise_catch", PromiseCatch, | 461 "promise_catch", PromiseCatch, |
465 "promise_chain", PromiseChain, | |
466 "promise_create", PromiseCreate, | 462 "promise_create", PromiseCreate, |
467 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, | 463 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, |
468 "promise_reject", PromiseReject, | 464 "promise_reject", PromiseReject, |
469 "promise_resolve", PromiseResolve, | 465 "promise_resolve", PromiseResolve, |
470 "promise_then", PromiseThen, | 466 "promise_then", PromiseThen, |
471 ]); | 467 ]); |
472 | 468 |
473 // This allows extras to create promises quickly without building extra | 469 // This allows extras to create promises quickly without building extra |
474 // resolve/reject closures, and allows them to later resolve and reject any | 470 // resolve/reject closures, and allows them to later resolve and reject any |
475 // promise without having to hold on to those closures forever. | 471 // promise without having to hold on to those closures forever. |
476 utils.InstallFunctions(extrasUtils, 0, [ | 472 utils.InstallFunctions(extrasUtils, 0, [ |
477 "createPromise", PromiseCreate, | 473 "createPromise", PromiseCreate, |
478 "resolvePromise", PromiseResolve, | 474 "resolvePromise", PromiseResolve, |
479 "rejectPromise", PromiseReject | 475 "rejectPromise", PromiseReject |
480 ]); | 476 ]); |
481 | 477 |
| 478 // TODO(v8:4567): Allow experimental natives to remove function prototype |
| 479 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( |
| 480 fn => %FunctionRemovePrototype(fn)); |
| 481 |
| 482 utils.Export(function(to) { |
| 483 to.PromiseChain = PromiseChain; |
| 484 to.PromiseDeferred = PromiseDeferred; |
| 485 to.PromiseResolved = PromiseResolved; |
| 486 }); |
| 487 |
482 }) | 488 }) |
OLD | NEW |