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 |
11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
12 // Imports | 12 // Imports |
13 | 13 |
14 var InternalArray = utils.InternalArray; | 14 var InternalArray = utils.InternalArray; |
15 var promiseHandledBySymbol = | 15 var promiseHandledBySymbol = |
16 utils.ImportNow("promise_handled_by_symbol"); | 16 utils.ImportNow("promise_handled_by_symbol"); |
17 var promiseForwardingHandlerSymbol = | 17 var promiseForwardingHandlerSymbol = |
18 utils.ImportNow("promise_forwarding_handler_symbol"); | 18 utils.ImportNow("promise_forwarding_handler_symbol"); |
19 var GlobalPromise = global.Promise; | 19 var GlobalPromise = global.Promise; |
20 | 20 |
21 // ------------------------------------------------------------------- | 21 // ------------------------------------------------------------------- |
22 | |
23 // Core functionality. | |
24 | |
25 function PromiseIdResolveHandler(x) { return x; } | |
26 function PromiseIdRejectHandler(r) { %_ReThrow(r); } | |
27 SET_PRIVATE(PromiseIdRejectHandler, promiseForwardingHandlerSymbol, true); | |
28 | |
29 // ------------------------------------------------------------------- | |
30 // Define exported functions. | 22 // Define exported functions. |
31 | 23 |
32 // Combinators. | 24 // Combinators. |
33 | 25 |
34 // ES#sec-promise.all | 26 // ES#sec-promise.all |
35 // Promise.all ( iterable ) | 27 // Promise.all ( iterable ) |
36 function PromiseAll(iterable) { | 28 function PromiseAll(iterable) { |
37 if (!IS_RECEIVER(this)) { | 29 if (!IS_RECEIVER(this)) { |
38 throw %make_type_error(kCalledOnNonObject, "Promise.all"); | 30 throw %make_type_error(kCalledOnNonObject, "Promise.all"); |
39 } | 31 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 122 } |
131 | 123 |
132 // ------------------------------------------------------------------- | 124 // ------------------------------------------------------------------- |
133 // Install exported functions. | 125 // Install exported functions. |
134 | 126 |
135 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ | 127 utils.InstallFunctions(GlobalPromise, DONT_ENUM, [ |
136 "all", PromiseAll, | 128 "all", PromiseAll, |
137 "race", PromiseRace, | 129 "race", PromiseRace, |
138 ]); | 130 ]); |
139 | 131 |
140 %InstallToContext([ | |
141 "promise_id_resolve_handler", PromiseIdResolveHandler, | |
142 "promise_id_reject_handler", PromiseIdRejectHandler | |
143 ]); | |
144 | |
145 }) | 132 }) |
OLD | NEW |