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

Unified Diff: src/js/harmony-async-await.js

Issue 1895603002: [esnext] prototype runtime implementation for async functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@AsyncFunction
Patch Set: properly rebase Created 4 years, 7 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
Index: src/js/harmony-async-await.js
diff --git a/src/js/harmony-async-await.js b/src/js/harmony-async-await.js
new file mode 100644
index 0000000000000000000000000000000000000000..1a7910ff4951729eff6ca8d93f59619ff1c7047b
--- /dev/null
+++ b/src/js/harmony-async-await.js
@@ -0,0 +1,37 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function(global, utils, extrasUtils) {
+
+"use strict";
+
+%CheckIsBootstrapping();
+
+// -------------------------------------------------------------------
+// Imports
+
+var AsyncFunctionNext;
+var AsyncFunctionThrow;
+var PromiseReject;
+var PromiseResolve;
+var PromiseThen;
+
+utils.Import(function(from) {
+ AsyncFunctionNext = from.AsyncFunctionNext;
+ AsyncFunctionThrow = from.AsyncFunctionThrow;
+ PromiseReject = from.PromiseCreateRejected;
+ PromiseResolve = from.PromiseCreateResolved;
+ PromiseThen = from.PromiseThen;
+});
+
+function AsyncFunctionAwait(generator, value) {
Dan Ehrenberg 2016/05/04 22:52:36 I like this way of defining the function. We may w
+ return %_Call(
+ PromiseThen, PromiseResolve(value),
+ function(value) { return %_Call(AsyncFunctionNext, generator, value); },
+ function(error) { return %_Call(AsyncFunctionThrow, generator, error); });
+}
+
+%InstallToContext([ "async_function_await", AsyncFunctionAwait ]);
+
+})

Powered by Google App Engine
This is Rietveld 408576698