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

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

Issue 1507313006: dart2js cps: Add instruction for null checks. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix true/false misdocumentation about condition and do not emit call Created 5 years 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 939 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 950
951 accept(StatementVisitor visitor) { 951 accept(StatementVisitor visitor) {
952 return visitor.visitYield(this); 952 return visitor.visitYield(this);
953 } 953 }
954 954
955 accept1(StatementVisitor1 visitor, arg) { 955 accept1(StatementVisitor1 visitor, arg) {
956 return visitor.visitYield(this, arg); 956 return visitor.visitYield(this, arg);
957 } 957 }
958 } 958 }
959 959
960 class NullCheck extends Statement {
961 Expression condition;
962 Expression value;
963 Selector selector;
964 Statement next;
965 SourceInformation sourceInformation;
966
967 NullCheck({this.condition, this.value, this.selector, this.next,
968 this.sourceInformation});
969
970 accept(StatementVisitor visitor) {
971 return visitor.visitNullCheck(this);
972 }
973
974 accept1(StatementVisitor1 visitor, arg) {
975 return visitor.visitNullCheck(this, arg);
976 }
977 }
978
960 abstract class ExpressionVisitor<E> { 979 abstract class ExpressionVisitor<E> {
961 E visitExpression(Expression node) => node.accept(this); 980 E visitExpression(Expression node) => node.accept(this);
962 E visitVariableUse(VariableUse node); 981 E visitVariableUse(VariableUse node);
963 E visitAssign(Assign node); 982 E visitAssign(Assign node);
964 E visitInvokeStatic(InvokeStatic node); 983 E visitInvokeStatic(InvokeStatic node);
965 E visitInvokeMethod(InvokeMethod node); 984 E visitInvokeMethod(InvokeMethod node);
966 E visitInvokeMethodDirectly(InvokeMethodDirectly node); 985 E visitInvokeMethodDirectly(InvokeMethodDirectly node);
967 E visitInvokeConstructor(InvokeConstructor node); 986 E visitInvokeConstructor(InvokeConstructor node);
968 E visitConstant(Constant node); 987 E visitConstant(Constant node);
969 E visitThis(This node); 988 E visitThis(This node);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 S visitBreak(Break node); 1059 S visitBreak(Break node);
1041 S visitContinue(Continue node); 1060 S visitContinue(Continue node);
1042 S visitIf(If node); 1061 S visitIf(If node);
1043 S visitWhileTrue(WhileTrue node); 1062 S visitWhileTrue(WhileTrue node);
1044 S visitFor(For node); 1063 S visitFor(For node);
1045 S visitExpressionStatement(ExpressionStatement node); 1064 S visitExpressionStatement(ExpressionStatement node);
1046 S visitTry(Try node); 1065 S visitTry(Try node);
1047 S visitUnreachable(Unreachable node); 1066 S visitUnreachable(Unreachable node);
1048 S visitForeignStatement(ForeignStatement node); 1067 S visitForeignStatement(ForeignStatement node);
1049 S visitYield(Yield node); 1068 S visitYield(Yield node);
1069 S visitNullCheck(NullCheck node);
1050 } 1070 }
1051 1071
1052 abstract class StatementVisitor1<S, A> { 1072 abstract class StatementVisitor1<S, A> {
1053 S visitStatement(Statement node, A arg) => node.accept1(this, arg); 1073 S visitStatement(Statement node, A arg) => node.accept1(this, arg);
1054 S visitLabeledStatement(LabeledStatement node, A arg); 1074 S visitLabeledStatement(LabeledStatement node, A arg);
1055 S visitReturn(Return node, A arg); 1075 S visitReturn(Return node, A arg);
1056 S visitThrow(Throw node, A arg); 1076 S visitThrow(Throw node, A arg);
1057 S visitRethrow(Rethrow node, A arg); 1077 S visitRethrow(Rethrow node, A arg);
1058 S visitBreak(Break node, A arg); 1078 S visitBreak(Break node, A arg);
1059 S visitContinue(Continue node, A arg); 1079 S visitContinue(Continue node, A arg);
1060 S visitIf(If node, A arg); 1080 S visitIf(If node, A arg);
1061 S visitWhileTrue(WhileTrue node, A arg); 1081 S visitWhileTrue(WhileTrue node, A arg);
1062 S visitFor(For node, A arg); 1082 S visitFor(For node, A arg);
1063 S visitExpressionStatement(ExpressionStatement node, A arg); 1083 S visitExpressionStatement(ExpressionStatement node, A arg);
1064 S visitTry(Try node, A arg); 1084 S visitTry(Try node, A arg);
1065 S visitUnreachable(Unreachable node, A arg); 1085 S visitUnreachable(Unreachable node, A arg);
1066 S visitForeignStatement(ForeignStatement node, A arg); 1086 S visitForeignStatement(ForeignStatement node, A arg);
1067 S visitYield(Yield node, A arg); 1087 S visitYield(Yield node, A arg);
1088 S visitNullCheck(NullCheck node, A arg);
1068 } 1089 }
1069 1090
1070 abstract class RecursiveVisitor implements StatementVisitor, ExpressionVisitor { 1091 abstract class RecursiveVisitor implements StatementVisitor, ExpressionVisitor {
1071 visitExpression(Expression e) => e.accept(this); 1092 visitExpression(Expression e) => e.accept(this);
1072 visitStatement(Statement s) => s.accept(this); 1093 visitStatement(Statement s) => s.accept(this);
1073 1094
1074 visitVariable(Variable variable) {} 1095 visitVariable(Variable variable) {}
1075 1096
1076 visitVariableUse(VariableUse node) { 1097 visitVariableUse(VariableUse node) {
1077 visitVariable(node.variable); 1098 visitVariable(node.variable);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 } 1291 }
1271 1292
1272 visitAwait(Await node) { 1293 visitAwait(Await node) {
1273 visitExpression(node.input); 1294 visitExpression(node.input);
1274 } 1295 }
1275 1296
1276 visitYield(Yield node) { 1297 visitYield(Yield node) {
1277 visitExpression(node.input); 1298 visitExpression(node.input);
1278 visitStatement(node.next); 1299 visitStatement(node.next);
1279 } 1300 }
1301
1302 visitNullCheck(NullCheck node) {
1303 if (node.condition != null) visitExpression(node.condition);
1304 visitExpression(node.value);
1305 visitStatement(node.next);
1306 }
1280 } 1307 }
1281 1308
1282 abstract class Transformer implements ExpressionVisitor<Expression>, 1309 abstract class Transformer implements ExpressionVisitor<Expression>,
1283 StatementVisitor<Statement> { 1310 StatementVisitor<Statement> {
1284 Expression visitExpression(Expression e) => e.accept(this); 1311 Expression visitExpression(Expression e) => e.accept(this);
1285 Statement visitStatement(Statement s) => s.accept(this); 1312 Statement visitStatement(Statement s) => s.accept(this);
1286 } 1313 }
1287 1314
1288 class RecursiveTransformer extends Transformer { 1315 class RecursiveTransformer extends Transformer {
1289 void _replaceExpressions(List<Expression> list) { 1316 void _replaceExpressions(List<Expression> list) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 visitAwait(Await node) { 1554 visitAwait(Await node) {
1528 node.input = visitExpression(node.input); 1555 node.input = visitExpression(node.input);
1529 return node; 1556 return node;
1530 } 1557 }
1531 1558
1532 visitYield(Yield node) { 1559 visitYield(Yield node) {
1533 node.input = visitExpression(node.input); 1560 node.input = visitExpression(node.input);
1534 node.next = visitStatement(node.next); 1561 node.next = visitStatement(node.next);
1535 return node; 1562 return node;
1536 } 1563 }
1564
1565 visitNullCheck(NullCheck node) {
1566 if (node.condition != null) {
1567 node.condition = visitExpression(node.condition);
1568 }
1569 node.value = visitExpression(node.value);
1570 node.next = visitStatement(node.next);
1571 return node;
1572 }
1537 } 1573 }
1538 1574
1539 class FallthroughTarget { 1575 class FallthroughTarget {
1540 final Statement target; 1576 final Statement target;
1541 int useCount = 0; 1577 int useCount = 0;
1542 1578
1543 FallthroughTarget(this.target); 1579 FallthroughTarget(this.target);
1544 } 1580 }
1545 1581
1546 /// A stack machine for tracking fallthrough while traversing the Tree IR. 1582 /// A stack machine for tracking fallthrough while traversing the Tree IR.
(...skipping 17 matching lines...) Expand all
1564 1600
1565 /// Number of uses of the current fallthrough target. 1601 /// Number of uses of the current fallthrough target.
1566 int get useCount => _stack.last.useCount; 1602 int get useCount => _stack.last.useCount;
1567 1603
1568 /// Indicate that a statement will fall through to the current fallthrough 1604 /// Indicate that a statement will fall through to the current fallthrough
1569 /// target. 1605 /// target.
1570 void use() { 1606 void use() {
1571 ++_stack.last.useCount; 1607 ++_stack.last.useCount;
1572 } 1608 }
1573 } 1609 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart ('k') | pkg/compiler/lib/src/tree_ir/tree_ir_tracer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698