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 MakeTypeError; |
15 var promiseCombinedDeferredSymbol = | 16 var promiseCombinedDeferredSymbol = |
16 utils.ImportNow("promise_combined_deferred_symbol"); | 17 utils.ImportNow("promise_combined_deferred_symbol"); |
17 var promiseHasHandlerSymbol = | 18 var promiseHasHandlerSymbol = |
18 utils.ImportNow("promise_has_handler_symbol"); | 19 utils.ImportNow("promise_has_handler_symbol"); |
19 var promiseOnRejectSymbol = utils.ImportNow("promise_on_reject_symbol"); | 20 var promiseOnRejectSymbol = utils.ImportNow("promise_on_reject_symbol"); |
20 var promiseOnResolveSymbol = | 21 var promiseOnResolveSymbol = |
21 utils.ImportNow("promise_on_resolve_symbol"); | 22 utils.ImportNow("promise_on_resolve_symbol"); |
22 var promiseRawSymbol = utils.ImportNow("promise_raw_symbol"); | 23 var promiseRawSymbol = utils.ImportNow("promise_raw_symbol"); |
23 var promiseStatusSymbol = utils.ImportNow("promise_status_symbol"); | 24 var promiseStatusSymbol = utils.ImportNow("promise_status_symbol"); |
24 var promiseValueSymbol = utils.ImportNow("promise_value_symbol"); | 25 var promiseValueSymbol = utils.ImportNow("promise_value_symbol"); |
25 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); | 26 var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol"); |
26 | 27 |
| 28 utils.Import(function(from) { |
| 29 MakeTypeError = from.MakeTypeError; |
| 30 }); |
| 31 |
27 // ------------------------------------------------------------------- | 32 // ------------------------------------------------------------------- |
28 | 33 |
29 // Status values: 0 = pending, +1 = resolved, -1 = rejected | 34 // Status values: 0 = pending, +1 = resolved, -1 = rejected |
30 var lastMicrotaskId = 0; | 35 var lastMicrotaskId = 0; |
31 | 36 |
32 var GlobalPromise = function Promise(resolver) { | 37 var GlobalPromise = function Promise(resolver) { |
33 if (resolver === promiseRawSymbol) return; | 38 if (resolver === promiseRawSymbol) return; |
34 if (!%_IsConstructCall()) throw MakeTypeError(kNotAPromise, this); | 39 if (!%_IsConstructCall()) throw MakeTypeError(kNotAPromise, this); |
35 if (!IS_CALLABLE(resolver)) | 40 if (!IS_CALLABLE(resolver)) |
36 throw MakeTypeError(kResolverNotAFunction, resolver); | 41 throw MakeTypeError(kResolverNotAFunction, resolver); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 // This allows extras to create promises quickly without building extra | 408 // This allows extras to create promises quickly without building extra |
404 // resolve/reject closures, and allows them to later resolve and reject any | 409 // resolve/reject closures, and allows them to later resolve and reject any |
405 // promise without having to hold on to those closures forever. | 410 // promise without having to hold on to those closures forever. |
406 utils.InstallFunctions(extrasUtils, 0, [ | 411 utils.InstallFunctions(extrasUtils, 0, [ |
407 "createPromise", PromiseCreate, | 412 "createPromise", PromiseCreate, |
408 "resolvePromise", PromiseResolve, | 413 "resolvePromise", PromiseResolve, |
409 "rejectPromise", PromiseReject | 414 "rejectPromise", PromiseReject |
410 ]); | 415 ]); |
411 | 416 |
412 }) | 417 }) |
OLD | NEW |