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

Side by Side 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: fix remaining brokenness in throw resuming Created 4 years, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 (function(global, utils, extrasUtils) {
6
7 "use strict";
8
9 %CheckIsBootstrapping();
10
11 // -------------------------------------------------------------------
12 // Imports
13
14 var Normal;
15 var Throw;
16 var PromiseReject;
17 var PromiseResolve;
18 var PromiseThen;
19
20 utils.Import(function(from) {
21 Normal = from.AsyncFunctionNext;
22 Throw = from.AsyncFunctionThrow;
23 PromiseReject = from.PromiseCreateRejected;
24 PromiseResolve = from.PromiseCreateResolved;
25 PromiseThen = from.PromiseThen;
26 });
27
28
29 function Resume(generator, sentValue, resumeFunc) {
30 try {
31 var result = resumeFunc(generator, sentValue);
32 if (result.done) return PromiseResolve(result.value);
33 } catch (error) {
34 return PromiseReject(error);
35 }
36
37 return %_Call(PromiseThen, PromiseResolve(result.value),
38 function(value) { return Resume(generator, value, Normal); },
39 function(error) { return Resume(generator, error, Throw); });
40 }
41
42 function Start(generator) {
43 return Resume(generator, UNDEFINED, Normal);
44 }
45
46 %InstallToContext([ "async_function_start", Start ]);
47
48 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698