Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 int writeCount = 0; | 107 int writeCount = 0; |
| 108 | 108 |
| 109 /// True if an inner JS function might access this variable through a | 109 /// True if an inner JS function might access this variable through a |
| 110 /// [ForeignCode] node. | 110 /// [ForeignCode] node. |
| 111 bool isCaptured = false; | 111 bool isCaptured = false; |
| 112 | 112 |
| 113 Variable(this.host, this.element) { | 113 Variable(this.host, this.element) { |
| 114 assert(host != null); | 114 assert(host != null); |
| 115 } | 115 } |
| 116 | 116 |
| 117 String toString() => element == null ? 'Variable' : element.toString(); | 117 String toString() => element == null ? 'Variable.${hashCode}' : element.toStri ng(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 /// Read the value of a variable. | 120 /// Read the value of a variable. |
| 121 class VariableUse extends Expression { | 121 class VariableUse extends Expression { |
| 122 Variable variable; | 122 Variable variable; |
| 123 | 123 |
| 124 /// Creates a use of [variable] and updates its `readCount`. | 124 /// Creates a use of [variable] and updates its `readCount`. |
| 125 VariableUse(this.variable) { | 125 VariableUse(this.variable) { |
| 126 variable.readCount++; | 126 variable.readCount++; |
| 127 } | 127 } |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 662 } | 662 } |
| 663 | 663 |
| 664 class CreateBox extends Expression { | 664 class CreateBox extends Expression { |
| 665 accept(ExpressionVisitor visitor) => visitor.visitCreateBox(this); | 665 accept(ExpressionVisitor visitor) => visitor.visitCreateBox(this); |
| 666 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitCreateBox(this, arg); | 666 accept1(ExpressionVisitor1 visitor, arg) => visitor.visitCreateBox(this, arg); |
| 667 } | 667 } |
| 668 | 668 |
| 669 class CreateInstance extends Expression { | 669 class CreateInstance extends Expression { |
| 670 ClassElement classElement; | 670 ClassElement classElement; |
| 671 List<Expression> arguments; | 671 List<Expression> arguments; |
| 672 List<Expression> typeInformation; | 672 Expression typeInformation; |
| 673 SourceInformation sourceInformation; | 673 SourceInformation sourceInformation; |
| 674 | 674 |
| 675 CreateInstance(this.classElement, this.arguments, | 675 CreateInstance(this.classElement, this.arguments, |
| 676 this.typeInformation, this.sourceInformation); | 676 this.typeInformation, this.sourceInformation); |
| 677 | 677 |
| 678 accept(ExpressionVisitor visitor) => visitor.visitCreateInstance(this); | 678 accept(ExpressionVisitor visitor) => visitor.visitCreateInstance(this); |
| 679 accept1(ExpressionVisitor1 visitor, arg) { | 679 accept1(ExpressionVisitor1 visitor, arg) { |
| 680 return visitor.visitCreateInstance(this, arg); | 680 return visitor.visitCreateInstance(this, arg); |
| 681 } | 681 } |
| 682 } | 682 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 897 @override | 897 @override |
| 898 void set next(Statement s) => throw 'UNREACHABLE'; | 898 void set next(Statement s) => throw 'UNREACHABLE'; |
| 899 } | 899 } |
| 900 | 900 |
| 901 /// Denotes the internal representation of [dartType], where all type variables | 901 /// Denotes the internal representation of [dartType], where all type variables |
| 902 /// are replaced by the values in [arguments]. | 902 /// are replaced by the values in [arguments]. |
| 903 /// (See documentation on the TypeExpression CPS node for more details.) | 903 /// (See documentation on the TypeExpression CPS node for more details.) |
| 904 class TypeExpression extends Expression { | 904 class TypeExpression extends Expression { |
| 905 final DartType dartType; | 905 final DartType dartType; |
| 906 final List<Expression> arguments; | 906 final List<Expression> arguments; |
| 907 final bool isForInstance; | |
| 907 | 908 |
| 908 TypeExpression(this.dartType, this.arguments); | 909 TypeExpression(this.dartType, this.arguments, this.isForInstance); |
| 909 | 910 |
| 910 accept(ExpressionVisitor visitor) { | 911 accept(ExpressionVisitor visitor) { |
| 911 return visitor.visitTypeExpression(this); | 912 return visitor.visitTypeExpression(this); |
| 912 } | 913 } |
| 913 | 914 |
| 914 accept1(ExpressionVisitor1 visitor, arg) { | 915 accept1(ExpressionVisitor1 visitor, arg) { |
| 915 return visitor.visitTypeExpression(this, arg); | 916 return visitor.visitTypeExpression(this, arg); |
| 916 } | 917 } |
| 917 } | 918 } |
| 918 | 919 |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1209 | 1210 |
| 1210 visitGetTypeTestProperty(GetTypeTestProperty node) { | 1211 visitGetTypeTestProperty(GetTypeTestProperty node) { |
| 1211 visitExpression(node.object); | 1212 visitExpression(node.object); |
| 1212 } | 1213 } |
| 1213 | 1214 |
| 1214 visitCreateBox(CreateBox node) { | 1215 visitCreateBox(CreateBox node) { |
| 1215 } | 1216 } |
| 1216 | 1217 |
| 1217 visitCreateInstance(CreateInstance node) { | 1218 visitCreateInstance(CreateInstance node) { |
| 1218 node.arguments.forEach(visitExpression); | 1219 node.arguments.forEach(visitExpression); |
| 1219 node.typeInformation.forEach(visitExpression); | 1220 if (node.typeInformation != null) visitExpression(node.typeInformation); |
| 1220 } | 1221 } |
| 1221 | 1222 |
| 1222 visitReifyRuntimeType(ReifyRuntimeType node) { | 1223 visitReifyRuntimeType(ReifyRuntimeType node) { |
| 1223 visitExpression(node.value); | 1224 visitExpression(node.value); |
| 1224 } | 1225 } |
| 1225 | 1226 |
| 1226 visitReadTypeVariable(ReadTypeVariable node) { | 1227 visitReadTypeVariable(ReadTypeVariable node) { |
| 1227 visitExpression(node.target); | 1228 visitExpression(node.target); |
| 1228 } | 1229 } |
| 1229 | 1230 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1450 | 1451 |
| 1451 visitGetTypeTestProperty(GetTypeTestProperty node) { | 1452 visitGetTypeTestProperty(GetTypeTestProperty node) { |
| 1452 node.object = visitExpression(node.object); | 1453 node.object = visitExpression(node.object); |
| 1453 return node; | 1454 return node; |
| 1454 } | 1455 } |
| 1455 | 1456 |
| 1456 visitCreateBox(CreateBox node) => node; | 1457 visitCreateBox(CreateBox node) => node; |
| 1457 | 1458 |
| 1458 visitCreateInstance(CreateInstance node) { | 1459 visitCreateInstance(CreateInstance node) { |
| 1459 _replaceExpressions(node.arguments); | 1460 _replaceExpressions(node.arguments); |
| 1460 _replaceExpressions(node.typeInformation); | 1461 if (node.typeInformation != null) |
| 1462 node.typeInformation = visitExpression(node.typeInformation); | |
|
asgerf
2016/01/26 10:30:01
I have been told we need {} around the body of mul
sra1
2016/01/26 22:21:08
Done.
| |
| 1461 return node; | 1463 return node; |
| 1462 } | 1464 } |
| 1463 | 1465 |
| 1464 visitReifyRuntimeType(ReifyRuntimeType node) { | 1466 visitReifyRuntimeType(ReifyRuntimeType node) { |
| 1465 node.value = visitExpression(node.value); | 1467 node.value = visitExpression(node.value); |
| 1466 return node; | 1468 return node; |
| 1467 } | 1469 } |
| 1468 | 1470 |
| 1469 visitReadTypeVariable(ReadTypeVariable node) { | 1471 visitReadTypeVariable(ReadTypeVariable node) { |
| 1470 node.target = visitExpression(node.target); | 1472 node.target = visitExpression(node.target); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1578 | 1580 |
| 1579 /// Number of uses of the current fallthrough target. | 1581 /// Number of uses of the current fallthrough target. |
| 1580 int get useCount => _stack.last.useCount; | 1582 int get useCount => _stack.last.useCount; |
| 1581 | 1583 |
| 1582 /// Indicate that a statement will fall through to the current fallthrough | 1584 /// Indicate that a statement will fall through to the current fallthrough |
| 1583 /// target. | 1585 /// target. |
| 1584 void use() { | 1586 void use() { |
| 1585 ++_stack.last.useCount; | 1587 ++_stack.last.useCount; |
| 1586 } | 1588 } |
| 1587 } | 1589 } |
| OLD | NEW |