Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: src/promise.js

Issue 210853003: Revert "Ship promises and weak collections" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/promise.js
diff --git a/src/promise.js b/src/promise.js
index 63f5629c9adbfdea074f34bb1a7e10ad90234108..23e51259a36c43849002990ea2b3ebbb3c5c0105 100644
--- a/src/promise.js
+++ b/src/promise.js
@@ -34,19 +34,7 @@
// var $WeakMap = global.WeakMap
-var $Promise = function Promise(resolver) {
- if (resolver === promiseRaw) return;
- if (!%_IsConstructCall()) throw MakeTypeError('not_a_promise', [this]);
- if (typeof resolver !== 'function')
- throw MakeTypeError('resolver_not_a_function', [resolver]);
- var promise = PromiseInit(this);
- try {
- resolver(function(x) { PromiseResolve(promise, x) },
- function(r) { PromiseReject(promise, r) });
- } catch (e) {
- PromiseReject(promise, e);
- }
-}
+var $Promise = Promise;
//-------------------------------------------------------------------
@@ -64,6 +52,20 @@ function IsPromise(x) {
return IS_SPEC_OBJECT(x) && %HasLocalProperty(x, promiseStatus);
}
+function Promise(resolver) {
+ if (resolver === promiseRaw) return;
+ if (!%_IsConstructCall()) throw MakeTypeError('not_a_promise', [this]);
+ if (typeof resolver !== 'function')
+ throw MakeTypeError('resolver_not_a_function', [resolver]);
+ var promise = PromiseInit(this);
+ try {
+ resolver(function(x) { PromiseResolve(promise, x) },
+ function(r) { PromiseReject(promise, r) });
+ } catch (e) {
+ PromiseReject(promise, e);
+ }
+}
+
function PromiseSet(promise, status, value, onResolve, onReject) {
SET_PRIVATE(promise, promiseStatus, status);
SET_PRIVATE(promise, promiseValue, value);
@@ -97,7 +99,7 @@ function PromiseReject(promise, r) {
function PromiseNopResolver() {}
function PromiseCreate() {
- return new $Promise(PromiseNopResolver)
+ return new Promise(PromiseNopResolver)
}
@@ -106,7 +108,7 @@ function PromiseCreate() {
function PromiseDeferred() {
if (this === $Promise) {
// Optimized case, avoid extra closure.
- var promise = PromiseInit(new $Promise(promiseRaw));
+ var promise = PromiseInit(new Promise(promiseRaw));
return {
promise: promise,
resolve: function(x) { PromiseResolve(promise, x) },
@@ -125,7 +127,7 @@ function PromiseDeferred() {
function PromiseResolved(x) {
if (this === $Promise) {
// Optimized case, avoid extra closure.
- return PromiseSet(new $Promise(promiseRaw), +1, x);
+ return PromiseSet(new Promise(promiseRaw), +1, x);
} else {
return new this(function(resolve, reject) { resolve(x) });
}
@@ -134,7 +136,7 @@ function PromiseResolved(x) {
function PromiseRejected(r) {
if (this === $Promise) {
// Optimized case, avoid extra closure.
- return PromiseSet(new $Promise(promiseRaw), -1, r);
+ return PromiseSet(new Promise(promiseRaw), -1, r);
} else {
return new this(function(resolve, reject) { reject(r) });
}
@@ -304,8 +306,9 @@ function PromiseOne(values) {
//-------------------------------------------------------------------
function SetUpPromise() {
- %CheckIsBootstrapping();
- %SetProperty(global, "Promise", $Promise, NONE);
+ %CheckIsBootstrapping()
+ var global_receiver = %GlobalReceiver(global);
+ global_receiver.Promise = $Promise;
InstallFunctions($Promise, DONT_ENUM, [
"defer", PromiseDeferred,
"accept", PromiseResolved,
« no previous file with comments | « src/flag-definitions.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698