Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 AsyncFunctionNext; | |
| 15 var AsyncFunctionThrow; | |
| 16 var PromiseReject; | |
| 17 var PromiseResolve; | |
| 18 var PromiseThen; | |
| 19 | |
| 20 utils.Import(function(from) { | |
| 21 AsyncFunctionNext = from.AsyncFunctionNext; | |
| 22 AsyncFunctionThrow = from.AsyncFunctionThrow; | |
| 23 PromiseReject = from.PromiseCreateRejected; | |
| 24 PromiseResolve = from.PromiseCreateResolved; | |
| 25 PromiseThen = from.PromiseThen; | |
| 26 }); | |
| 27 | |
| 28 function AsyncFunctionAwait(generator, value) { | |
|
Dan Ehrenberg
2016/05/04 22:52:36
I like this way of defining the function. We may w
| |
| 29 return %_Call( | |
| 30 PromiseThen, PromiseResolve(value), | |
| 31 function(value) { return %_Call(AsyncFunctionNext, generator, value); }, | |
| 32 function(error) { return %_Call(AsyncFunctionThrow, generator, error); }); | |
| 33 } | |
| 34 | |
| 35 %InstallToContext([ "async_function_await", AsyncFunctionAwait ]); | |
| 36 | |
| 37 }) | |
| OLD | NEW |