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) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if (!IsPromise(x) && IS_SPEC_OBJECT(x)) { | 81 if (!IsPromise(x) && IS_SPEC_OBJECT(x)) { |
82 var then; | 82 var then; |
83 try { | 83 try { |
84 then = x.then; | 84 then = x.then; |
85 } catch(r) { | 85 } catch(r) { |
86 return %_CallFunction(constructor, r, PromiseRejected); | 86 return %_CallFunction(constructor, r, PromiseRejected); |
87 } | 87 } |
88 if (IS_CALLABLE(then)) { | 88 if (IS_CALLABLE(then)) { |
89 var deferred = %_CallFunction(constructor, PromiseDeferred); | 89 var deferred = %_CallFunction(constructor, PromiseDeferred); |
90 try { | 90 try { |
91 %_CallFunction(x, deferred.resolve, deferred.reject, then); | 91 %_Call(then, x, deferred.resolve, deferred.reject); |
92 } catch(r) { | 92 } catch(r) { |
93 deferred.reject(r); | 93 deferred.reject(r); |
94 } | 94 } |
95 return deferred.promise; | 95 return deferred.promise; |
96 } | 96 } |
97 } | 97 } |
98 return x; | 98 return x; |
99 } | 99 } |
100 | 100 |
101 function PromiseHandle(value, handler, deferred) { | 101 function PromiseHandle(value, handler, deferred) { |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 "promise_catch", PromiseCatch, | 382 "promise_catch", PromiseCatch, |
383 "promise_chain", PromiseChain, | 383 "promise_chain", PromiseChain, |
384 "promise_create", PromiseCreate, | 384 "promise_create", PromiseCreate, |
385 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, | 385 "promise_has_user_defined_reject_handler", PromiseHasUserDefinedRejectHandler, |
386 "promise_reject", PromiseReject, | 386 "promise_reject", PromiseReject, |
387 "promise_resolve", PromiseResolve, | 387 "promise_resolve", PromiseResolve, |
388 "promise_then", PromiseThen, | 388 "promise_then", PromiseThen, |
389 ]); | 389 ]); |
390 | 390 |
391 }) | 391 }) |
OLD | NEW |