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/expressions.dart'; | 7 import '../constants/expressions.dart'; |
8 import '../constants/values.dart' as values; | 8 import '../constants/values.dart' as values; |
9 import '../dart_types.dart' show DartType, GenericType, InterfaceType, TypeVaria
bleType; | 9 import '../dart_types.dart' show DartType, GenericType, InterfaceType, TypeVaria
bleType; |
10 import '../elements/elements.dart'; | 10 import '../elements/elements.dart'; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 final List<LiteralMapEntry> entries; | 323 final List<LiteralMapEntry> entries; |
324 | 324 |
325 LiteralMap(this.type, this.entries); | 325 LiteralMap(this.type, this.entries); |
326 | 326 |
327 accept(ExpressionVisitor visitor) => visitor.visitLiteralMap(this); | 327 accept(ExpressionVisitor visitor) => visitor.visitLiteralMap(this); |
328 accept1(ExpressionVisitor1 visitor, arg) { | 328 accept1(ExpressionVisitor1 visitor, arg) { |
329 return visitor.visitLiteralMap(this, arg); | 329 return visitor.visitLiteralMap(this, arg); |
330 } | 330 } |
331 } | 331 } |
332 | 332 |
| 333 /// Given the interceptor for a value, test the value against a type. |
333 class TypeOperator extends Expression { | 334 class TypeOperator extends Expression { |
334 Expression value; | 335 Expression receiver; |
335 final DartType type; | 336 final DartType type; |
336 final List<Expression> typeArguments; | |
337 final bool isTypeTest; | 337 final bool isTypeTest; |
338 | 338 |
339 TypeOperator(this.value, this.type, this.typeArguments, | 339 TypeOperator(this.receiver, this.type, {bool this.isTypeTest}); |
340 {bool this.isTypeTest}); | |
341 | 340 |
342 accept(ExpressionVisitor visitor) => visitor.visitTypeOperator(this); | 341 accept(ExpressionVisitor visitor) => visitor.visitTypeOperator(this); |
343 accept1(ExpressionVisitor1 visitor, arg) { | 342 accept1(ExpressionVisitor1 visitor, arg) { |
344 return visitor.visitTypeOperator(this, arg); | 343 return visitor.visitTypeOperator(this, arg); |
345 } | 344 } |
346 | 345 |
347 String get operator => isTypeTest ? 'is' : 'as'; | 346 String get operator => isTypeTest ? 'is' : 'as'; |
348 } | 347 } |
349 | 348 |
350 /// A conditional expression. | 349 /// A conditional expression. |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 } | 1150 } |
1152 | 1151 |
1153 visitLiteralMap(LiteralMap node) { | 1152 visitLiteralMap(LiteralMap node) { |
1154 node.entries.forEach((LiteralMapEntry entry) { | 1153 node.entries.forEach((LiteralMapEntry entry) { |
1155 visitExpression(entry.key); | 1154 visitExpression(entry.key); |
1156 visitExpression(entry.value); | 1155 visitExpression(entry.value); |
1157 }); | 1156 }); |
1158 } | 1157 } |
1159 | 1158 |
1160 visitTypeOperator(TypeOperator node) { | 1159 visitTypeOperator(TypeOperator node) { |
1161 visitExpression(node.value); | 1160 visitExpression(node.receiver); |
1162 node.typeArguments.forEach(visitExpression); | |
1163 } | 1161 } |
1164 | 1162 |
1165 visitFunctionExpression(FunctionExpression node) { | 1163 visitFunctionExpression(FunctionExpression node) { |
1166 visitInnerFunction(node.definition); | 1164 visitInnerFunction(node.definition); |
1167 } | 1165 } |
1168 | 1166 |
1169 visitLabeledStatement(LabeledStatement node) { | 1167 visitLabeledStatement(LabeledStatement node) { |
1170 visitStatement(node.body); | 1168 visitStatement(node.body); |
1171 visitStatement(node.next); | 1169 visitStatement(node.next); |
1172 } | 1170 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 | 1342 |
1345 visitLiteralMap(LiteralMap node) { | 1343 visitLiteralMap(LiteralMap node) { |
1346 node.entries.forEach((LiteralMapEntry entry) { | 1344 node.entries.forEach((LiteralMapEntry entry) { |
1347 entry.key = visitExpression(entry.key); | 1345 entry.key = visitExpression(entry.key); |
1348 entry.value = visitExpression(entry.value); | 1346 entry.value = visitExpression(entry.value); |
1349 }); | 1347 }); |
1350 return node; | 1348 return node; |
1351 } | 1349 } |
1352 | 1350 |
1353 visitTypeOperator(TypeOperator node) { | 1351 visitTypeOperator(TypeOperator node) { |
1354 node.value = visitExpression(node.value); | 1352 node.receiver = visitExpression(node.receiver); |
1355 _replaceExpressions(node.typeArguments); | |
1356 return node; | 1353 return node; |
1357 } | 1354 } |
1358 | 1355 |
1359 visitFunctionExpression(FunctionExpression node) { | 1356 visitFunctionExpression(FunctionExpression node) { |
1360 visitInnerFunction(node.definition); | 1357 visitInnerFunction(node.definition); |
1361 return node; | 1358 return node; |
1362 } | 1359 } |
1363 | 1360 |
1364 visitLabeledStatement(LabeledStatement node) { | 1361 visitLabeledStatement(LabeledStatement node) { |
1365 node.body = visitStatement(node.body); | 1362 node.body = visitStatement(node.body); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 visitTypeExpression(TypeExpression node) { | 1455 visitTypeExpression(TypeExpression node) { |
1459 _replaceExpressions(node.arguments); | 1456 _replaceExpressions(node.arguments); |
1460 return node; | 1457 return node; |
1461 } | 1458 } |
1462 | 1459 |
1463 visitCreateInvocationMirror(CreateInvocationMirror node) { | 1460 visitCreateInvocationMirror(CreateInvocationMirror node) { |
1464 _replaceExpressions(node.arguments); | 1461 _replaceExpressions(node.arguments); |
1465 return node; | 1462 return node; |
1466 } | 1463 } |
1467 } | 1464 } |
OLD | NEW |