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: pkg/compiler/lib/src/js/nodes.dart

Issue 839323003: Implementation of async-await transformation on js ast. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 5 years, 10 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 | « pkg/compiler/lib/src/js/builder.dart ('k') | pkg/compiler/lib/src/js/printer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/js/nodes.dart
diff --git a/pkg/compiler/lib/src/js/nodes.dart b/pkg/compiler/lib/src/js/nodes.dart
index e5b57f6351593fa734602e297c1558ad28d9ecd0..c4fab3746d04dd2fa685302661915a63a3cab2ce 100644
--- a/pkg/compiler/lib/src/js/nodes.dart
+++ b/pkg/compiler/lib/src/js/nodes.dart
@@ -27,6 +27,7 @@ abstract class NodeVisitor<T> {
T visitFunctionDeclaration(FunctionDeclaration node);
T visitLabeledStatement(LabeledStatement node);
T visitLiteralStatement(LiteralStatement node);
+ T visitDartYield(DartYield node);
T visitBlob(Blob node);
T visitLiteralExpression(LiteralExpression node);
@@ -169,6 +170,7 @@ class BaseVisitor<T> implements NodeVisitor<T> {
T visitComment(Comment node) => null;
T visitAwait(Await node) => visitExpression(node);
+ T visitDartYield(DartYield node) => visitStatement(node);
}
abstract class Node {
@@ -532,6 +534,24 @@ class LiteralStatement extends Statement {
LiteralStatement _clone() => new LiteralStatement(code);
}
+// Not a real javascript node, but represents the yield statement from a dart
+// program translated to javascript.
+class DartYield extends Statement {
+ final Expression expression;
+
+ final bool hasStar;
+
+ DartYield(this.expression, this.hasStar);
+
+ accept(NodeVisitor visitor) => visitor.visitDartYield(this);
+
+ void visitChildren(NodeVisitor visitor) {
+ expression.accept(visitor);
+ }
+
+ DartYield _clone() => new DartYield(expression, hasStar);
+}
+
abstract class Expression extends Node {
int get precedenceLevel;
@@ -862,7 +882,7 @@ class Fun extends Expression {
body.accept(visitor);
}
- Fun _clone() => new Fun(params, body);
+ Fun _clone() => new Fun(params, body, asyncModifier: asyncModifier);
int get precedenceLevel => CALL;
}
@@ -870,11 +890,25 @@ class Fun extends Expression {
class AsyncModifier {
final bool isAsync;
final bool isYielding;
-
- const AsyncModifier.sync() : isAsync = false, isYielding = false;
- const AsyncModifier.async() : isAsync = true, isYielding = false;
- const AsyncModifier.asyncStar() : isAsync = true, isYielding = true;
- const AsyncModifier.syncStar() : isAsync = false, isYielding = true;
+ final String description;
+
+ const AsyncModifier.sync()
+ : isAsync = false,
+ isYielding = false,
+ description = "sync";
+ const AsyncModifier.async()
+ : isAsync = true,
+ isYielding = false,
+ description = "async";
+ const AsyncModifier.asyncStar()
+ : isAsync = true,
+ isYielding = true,
+ description = "async*";
+ const AsyncModifier.syncStar()
+ : isAsync = false,
+ isYielding = true,
+ description = "sync*";
+ toString() => description;
}
class PropertyAccess extends Expression {
« no previous file with comments | « pkg/compiler/lib/src/js/builder.dart ('k') | pkg/compiler/lib/src/js/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698