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

Side by Side Diff: pkg/compiler/lib/src/tree_ir/tree_ir_nodes.dart

Issue 1253333002: dart2js cps: Support async/await by rewriting the JavaScript AST. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add issue number to status file. Created 5 years, 4 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library tree_ir_nodes; 5 library tree_ir_nodes;
6 6
7 import '../constants/values.dart' as values; 7 import '../constants/values.dart' as values;
8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType; 8 import '../dart_types.dart' show DartType, InterfaceType, TypeVariableType;
9 import '../elements/elements.dart'; 9 import '../elements/elements.dart';
10 import '../io/source_information.dart' show SourceInformation; 10 import '../io/source_information.dart' show SourceInformation;
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 888
889 accept(ExpressionVisitor visitor) { 889 accept(ExpressionVisitor visitor) {
890 return visitor.visitTypeExpression(this); 890 return visitor.visitTypeExpression(this);
891 } 891 }
892 892
893 accept1(ExpressionVisitor1 visitor, arg) { 893 accept1(ExpressionVisitor1 visitor, arg) {
894 return visitor.visitTypeExpression(this, arg); 894 return visitor.visitTypeExpression(this, arg);
895 } 895 }
896 } 896 }
897 897
898 class Await extends Expression {
899 Expression input;
900
901 Await(this.input);
902
903 accept(ExpressionVisitor visitor) {
904 return visitor.visitAwait(this);
905 }
906
907 accept1(ExpressionVisitor1 visitor, arg) {
908 return visitor.visitAwait(this, arg);
909 }
910 }
911
898 abstract class ExpressionVisitor<E> { 912 abstract class ExpressionVisitor<E> {
899 E visitExpression(Expression node) => node.accept(this); 913 E visitExpression(Expression node) => node.accept(this);
900 E visitVariableUse(VariableUse node); 914 E visitVariableUse(VariableUse node);
901 E visitAssign(Assign node); 915 E visitAssign(Assign node);
902 E visitInvokeStatic(InvokeStatic node); 916 E visitInvokeStatic(InvokeStatic node);
903 E visitInvokeMethod(InvokeMethod node); 917 E visitInvokeMethod(InvokeMethod node);
904 E visitInvokeMethodDirectly(InvokeMethodDirectly node); 918 E visitInvokeMethodDirectly(InvokeMethodDirectly node);
905 E visitInvokeConstructor(InvokeConstructor node); 919 E visitInvokeConstructor(InvokeConstructor node);
906 E visitConstant(Constant node); 920 E visitConstant(Constant node);
907 E visitThis(This node); 921 E visitThis(This node);
(...skipping 13 matching lines...) Expand all
921 E visitReifyRuntimeType(ReifyRuntimeType node); 935 E visitReifyRuntimeType(ReifyRuntimeType node);
922 E visitReadTypeVariable(ReadTypeVariable node); 936 E visitReadTypeVariable(ReadTypeVariable node);
923 E visitTypeExpression(TypeExpression node); 937 E visitTypeExpression(TypeExpression node);
924 E visitCreateInvocationMirror(CreateInvocationMirror node); 938 E visitCreateInvocationMirror(CreateInvocationMirror node);
925 E visitInterceptor(Interceptor node); 939 E visitInterceptor(Interceptor node);
926 E visitApplyBuiltinOperator(ApplyBuiltinOperator node); 940 E visitApplyBuiltinOperator(ApplyBuiltinOperator node);
927 E visitForeignExpression(ForeignExpression node); 941 E visitForeignExpression(ForeignExpression node);
928 E visitGetLength(GetLength node); 942 E visitGetLength(GetLength node);
929 E visitGetIndex(GetIndex node); 943 E visitGetIndex(GetIndex node);
930 E visitSetIndex(SetIndex node); 944 E visitSetIndex(SetIndex node);
945 E visitAwait(Await node);
931 } 946 }
932 947
933 abstract class ExpressionVisitor1<E, A> { 948 abstract class ExpressionVisitor1<E, A> {
934 E visitExpression(Expression node, A arg) => node.accept1(this, arg); 949 E visitExpression(Expression node, A arg) => node.accept1(this, arg);
935 E visitVariableUse(VariableUse node, A arg); 950 E visitVariableUse(VariableUse node, A arg);
936 E visitAssign(Assign node, A arg); 951 E visitAssign(Assign node, A arg);
937 E visitInvokeStatic(InvokeStatic node, A arg); 952 E visitInvokeStatic(InvokeStatic node, A arg);
938 E visitInvokeMethod(InvokeMethod node, A arg); 953 E visitInvokeMethod(InvokeMethod node, A arg);
939 E visitInvokeMethodDirectly(InvokeMethodDirectly node, A arg); 954 E visitInvokeMethodDirectly(InvokeMethodDirectly node, A arg);
940 E visitInvokeConstructor(InvokeConstructor node, A arg); 955 E visitInvokeConstructor(InvokeConstructor node, A arg);
(...skipping 15 matching lines...) Expand all
956 E visitReifyRuntimeType(ReifyRuntimeType node, A arg); 971 E visitReifyRuntimeType(ReifyRuntimeType node, A arg);
957 E visitReadTypeVariable(ReadTypeVariable node, A arg); 972 E visitReadTypeVariable(ReadTypeVariable node, A arg);
958 E visitTypeExpression(TypeExpression node, A arg); 973 E visitTypeExpression(TypeExpression node, A arg);
959 E visitCreateInvocationMirror(CreateInvocationMirror node, A arg); 974 E visitCreateInvocationMirror(CreateInvocationMirror node, A arg);
960 E visitInterceptor(Interceptor node, A arg); 975 E visitInterceptor(Interceptor node, A arg);
961 E visitApplyBuiltinOperator(ApplyBuiltinOperator node, A arg); 976 E visitApplyBuiltinOperator(ApplyBuiltinOperator node, A arg);
962 E visitForeignExpression(ForeignExpression node, A arg); 977 E visitForeignExpression(ForeignExpression node, A arg);
963 E visitGetLength(GetLength node, A arg); 978 E visitGetLength(GetLength node, A arg);
964 E visitGetIndex(GetIndex node, A arg); 979 E visitGetIndex(GetIndex node, A arg);
965 E visitSetIndex(SetIndex node, A arg); 980 E visitSetIndex(SetIndex node, A arg);
981 E visitAwait(Await node, A arg);
966 } 982 }
967 983
968 abstract class StatementVisitor<S> { 984 abstract class StatementVisitor<S> {
969 S visitStatement(Statement node) => node.accept(this); 985 S visitStatement(Statement node) => node.accept(this);
970 S visitLabeledStatement(LabeledStatement node); 986 S visitLabeledStatement(LabeledStatement node);
971 S visitReturn(Return node); 987 S visitReturn(Return node);
972 S visitThrow(Throw node); 988 S visitThrow(Throw node);
973 S visitRethrow(Rethrow node); 989 S visitRethrow(Rethrow node);
974 S visitBreak(Break node); 990 S visitBreak(Break node);
975 S visitContinue(Continue node); 991 S visitContinue(Continue node);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 visitGetIndex(GetIndex node) { 1205 visitGetIndex(GetIndex node) {
1190 visitExpression(node.object); 1206 visitExpression(node.object);
1191 visitExpression(node.index); 1207 visitExpression(node.index);
1192 } 1208 }
1193 1209
1194 visitSetIndex(SetIndex node) { 1210 visitSetIndex(SetIndex node) {
1195 visitExpression(node.object); 1211 visitExpression(node.object);
1196 visitExpression(node.index); 1212 visitExpression(node.index);
1197 visitExpression(node.value); 1213 visitExpression(node.value);
1198 } 1214 }
1215
1216 visitAwait(Await node) {
1217 visitExpression(node.input);
1218 }
1199 } 1219 }
1200 1220
1201 abstract class Transformer implements ExpressionVisitor<Expression>, 1221 abstract class Transformer implements ExpressionVisitor<Expression>,
1202 StatementVisitor<Statement> { 1222 StatementVisitor<Statement> {
1203 Expression visitExpression(Expression e) => e.accept(this); 1223 Expression visitExpression(Expression e) => e.accept(this);
1204 Statement visitStatement(Statement s) => s.accept(this); 1224 Statement visitStatement(Statement s) => s.accept(this);
1205 } 1225 }
1206 1226
1207 class RecursiveTransformer extends Transformer { 1227 class RecursiveTransformer extends Transformer {
1208 void visitInnerFunction(FunctionDefinition node) { 1228 void visitInnerFunction(FunctionDefinition node) {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 node.index = visitExpression(node.index); 1451 node.index = visitExpression(node.index);
1432 return node; 1452 return node;
1433 } 1453 }
1434 1454
1435 visitSetIndex(SetIndex node) { 1455 visitSetIndex(SetIndex node) {
1436 node.object = visitExpression(node.object); 1456 node.object = visitExpression(node.object);
1437 node.index = visitExpression(node.index); 1457 node.index = visitExpression(node.index);
1438 node.value = visitExpression(node.value); 1458 node.value = visitExpression(node.value);
1439 return node; 1459 return node;
1440 } 1460 }
1461
1462 visitAwait(Await node) {
1463 node.input = visitExpression(node.input);
1464 return node;
1465 }
1441 } 1466 }
1442 1467
1443 class FallthroughTarget { 1468 class FallthroughTarget {
1444 final Statement target; 1469 final Statement target;
1445 int useCount = 0; 1470 int useCount = 0;
1446 1471
1447 FallthroughTarget(this.target); 1472 FallthroughTarget(this.target);
1448 } 1473 }
1449 1474
1450 /// A stack machine for tracking fallthrough while traversing the Tree IR. 1475 /// A stack machine for tracking fallthrough while traversing the Tree IR.
(...skipping 17 matching lines...) Expand all
1468 1493
1469 /// Number of uses of the current fallthrough target. 1494 /// Number of uses of the current fallthrough target.
1470 int get useCount => _stack.last.useCount; 1495 int get useCount => _stack.last.useCount;
1471 1496
1472 /// Indicate that a statement will fall through to the current fallthrough 1497 /// Indicate that a statement will fall through to the current fallthrough
1473 /// target. 1498 /// target.
1474 void use() { 1499 void use() {
1475 ++_stack.last.useCount; 1500 ++_stack.last.useCount;
1476 } 1501 }
1477 } 1502 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698