| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 return { | 54 return { |
| 55 __proto__: null, | 55 __proto__: null, |
| 56 resolve: resolve, | 56 resolve: resolve, |
| 57 reject: reject | 57 reject: reject |
| 58 }; | 58 }; |
| 59 } | 59 } |
| 60 | 60 |
| 61 | 61 |
| 62 var GlobalPromise = function Promise(resolver) { | 62 var GlobalPromise = function Promise(resolver) { |
| 63 if (resolver === promiseRawSymbol) { | 63 if (resolver === promiseRawSymbol) { |
| 64 return %NewObject(GlobalPromise, new.target); | 64 return %_NewObject(GlobalPromise, new.target); |
| 65 } | 65 } |
| 66 if (IS_UNDEFINED(new.target)) throw MakeTypeError(kNotAPromise, this); | 66 if (IS_UNDEFINED(new.target)) throw MakeTypeError(kNotAPromise, this); |
| 67 if (!IS_CALLABLE(resolver)) | 67 if (!IS_CALLABLE(resolver)) |
| 68 throw MakeTypeError(kResolverNotAFunction, resolver); | 68 throw MakeTypeError(kResolverNotAFunction, resolver); |
| 69 | 69 |
| 70 var promise = PromiseInit(%NewObject(GlobalPromise, new.target)); | 70 var promise = PromiseInit(%_NewObject(GlobalPromise, new.target)); |
| 71 var callbacks = CreateResolvingFunctions(promise); | 71 var callbacks = CreateResolvingFunctions(promise); |
| 72 | 72 |
| 73 try { | 73 try { |
| 74 %DebugPushPromise(promise, Promise); | 74 %DebugPushPromise(promise, Promise); |
| 75 resolver(callbacks.resolve, callbacks.reject); | 75 resolver(callbacks.resolve, callbacks.reject); |
| 76 } catch (e) { | 76 } catch (e) { |
| 77 %_Call(callbacks.reject, UNDEFINED, e); | 77 %_Call(callbacks.reject, UNDEFINED, e); |
| 78 } finally { | 78 } finally { |
| 79 %DebugPopPromise(); | 79 %DebugPopPromise(); |
| 80 } | 80 } |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( | 472 [PromiseChain, PromiseDeferred, PromiseResolved].forEach( |
| 473 fn => %FunctionRemovePrototype(fn)); | 473 fn => %FunctionRemovePrototype(fn)); |
| 474 | 474 |
| 475 utils.Export(function(to) { | 475 utils.Export(function(to) { |
| 476 to.PromiseChain = PromiseChain; | 476 to.PromiseChain = PromiseChain; |
| 477 to.PromiseDeferred = PromiseDeferred; | 477 to.PromiseDeferred = PromiseDeferred; |
| 478 to.PromiseResolved = PromiseResolved; | 478 to.PromiseResolved = PromiseResolved; |
| 479 }); | 479 }); |
| 480 | 480 |
| 481 }) | 481 }) |
| OLD | NEW |