| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library rasta.kernel_visitor; | 5 library rasta.kernel_visitor; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' as ir; | 7 import 'package:kernel/ast.dart' as ir; |
| 8 | 8 |
| 9 import 'package:kernel/accessors.dart' show | 9 import 'package:kernel/accessors.dart' show |
| 10 Accessor, | 10 Accessor, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 final Map<JumpTarget, ir.LabeledStatement> breakTargets = | 217 final Map<JumpTarget, ir.LabeledStatement> breakTargets = |
| 218 <JumpTarget, ir.LabeledStatement>{}; | 218 <JumpTarget, ir.LabeledStatement>{}; |
| 219 | 219 |
| 220 final Map<LocalElement, ir.VariableDeclaration> locals = | 220 final Map<LocalElement, ir.VariableDeclaration> locals = |
| 221 <LocalElement, ir.VariableDeclaration>{}; | 221 <LocalElement, ir.VariableDeclaration>{}; |
| 222 | 222 |
| 223 final Map<CascadeReceiver, ir.VariableGet> cascadeReceivers = | 223 final Map<CascadeReceiver, ir.VariableGet> cascadeReceivers = |
| 224 <CascadeReceiver, ir.VariableGet>{}; | 224 <CascadeReceiver, ir.VariableGet>{}; |
| 225 | 225 |
| 226 bool isVoidContext = false; |
| 227 |
| 226 KernelVisitor(this.currentElement, this.elements, this.kernel); | 228 KernelVisitor(this.currentElement, this.elements, this.kernel); |
| 227 | 229 |
| 228 KernelVisitor get sendVisitor => this; | 230 KernelVisitor get sendVisitor => this; |
| 229 | 231 |
| 230 KernelVisitor get declVisitor => this; | 232 KernelVisitor get declVisitor => this; |
| 231 | 233 |
| 232 ir.TreeNode visitForValue(Expression node) => node?.accept(this); | 234 ir.TreeNode visitForValue(Expression node) { |
| 235 bool wasVoidContext = isVoidContext; |
| 236 isVoidContext = false; |
| 237 try { |
| 238 return node?.accept(this); |
| 239 } finally { |
| 240 isVoidContext = wasVoidContext; |
| 241 } |
| 242 } |
| 243 |
| 244 ir.TreeNode visitForEffect(Expression node) { |
| 245 bool wasVoidContext = isVoidContext; |
| 246 isVoidContext = true; |
| 247 try { |
| 248 return node?.accept(this); |
| 249 } finally { |
| 250 isVoidContext = wasVoidContext; |
| 251 } |
| 252 } |
| 253 |
| 254 ir.TreeNode visitWithCurrentContext(Expression node) => node?.accept(this); |
| 233 | 255 |
| 234 withCurrentElement(AstElement element, f()) { | 256 withCurrentElement(AstElement element, f()) { |
| 235 assert(element.library == kernel.compiler.currentElement.library); | 257 assert(element.library == kernel.compiler.currentElement.library); |
| 236 Element previousElement = currentElement; | 258 Element previousElement = currentElement; |
| 237 currentElement = element; | 259 currentElement = element; |
| 238 try { | 260 try { |
| 239 return f(); | 261 return f(); |
| 240 } finally { | 262 } finally { |
| 241 currentElement = previousElement; | 263 currentElement = previousElement; |
| 242 } | 264 } |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 // [receiver]. Each [CascadeReceiver] has a getter for [receiverVariable] | 661 // [receiver]. Each [CascadeReceiver] has a getter for [receiverVariable] |
| 640 // in [cascadeReceivers]. | 662 // in [cascadeReceivers]. |
| 641 | 663 |
| 642 receiverVariable.initializer = visitForValue(receiver.expression); | 664 receiverVariable.initializer = visitForValue(receiver.expression); |
| 643 receiverVariable.initializer.parent = receiverVariable; | 665 receiverVariable.initializer.parent = receiverVariable; |
| 644 | 666 |
| 645 ir.Expression result = new ir.VariableGet(receiverVariable); // rcv. | 667 ir.Expression result = new ir.VariableGet(receiverVariable); // rcv. |
| 646 for (Cascade cascade in cascades) { | 668 for (Cascade cascade in cascades) { |
| 647 // When evaluating `cascade.expression`, we stop the recursion at | 669 // When evaluating `cascade.expression`, we stop the recursion at |
| 648 // [visitCascadeReceiver] and instead returns an [ir.VariableGet]. | 670 // [visitCascadeReceiver] and instead returns an [ir.VariableGet]. |
| 671 // TODO(ahe): Use visitForEffect here? |
| 649 ir.Expression value = visitForValue(cascade.expression); | 672 ir.Expression value = visitForValue(cascade.expression); |
| 650 result = new ir.Let(makeOrReuseVariable(value), result); | 673 result = new ir.Let(makeOrReuseVariable(value), result); |
| 651 } | 674 } |
| 652 | 675 |
| 653 assert(startLength == cascadeReceivers.length); | 676 assert(startLength == cascadeReceivers.length); |
| 654 return new ir.Let(receiverVariable, result); | 677 return new ir.Let(receiverVariable, result); |
| 655 } | 678 } |
| 656 | 679 |
| 657 @override | 680 @override |
| 658 ir.VariableGet visitCascadeReceiver(CascadeReceiver node) { | 681 ir.VariableGet visitCascadeReceiver(CascadeReceiver node) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 673 ir.DartType guard = computeType(node.type); | 696 ir.DartType guard = computeType(node.type); |
| 674 return new ir.Catch( | 697 return new ir.Catch( |
| 675 exception, buildStatementInBlock(node.block), guard: guard, | 698 exception, buildStatementInBlock(node.block), guard: guard, |
| 676 stackTrace: trace); | 699 stackTrace: trace); |
| 677 } | 700 } |
| 678 | 701 |
| 679 @override | 702 @override |
| 680 ir.ConditionalExpression visitConditional(Conditional node) { | 703 ir.ConditionalExpression visitConditional(Conditional node) { |
| 681 return new ir.ConditionalExpression( | 704 return new ir.ConditionalExpression( |
| 682 visitForValue(node.condition), | 705 visitForValue(node.condition), |
| 683 visitForValue(node.thenExpression), | 706 visitWithCurrentContext(node.thenExpression), |
| 684 visitForValue(node.elseExpression)); | 707 visitWithCurrentContext(node.elseExpression)); |
| 685 } | 708 } |
| 686 | 709 |
| 687 @override | 710 @override |
| 688 ir.Statement visitContinueStatement(ContinueStatement node) { | 711 ir.Statement visitContinueStatement(ContinueStatement node) { |
| 689 JumpTarget target = elements.getTargetOf(node); | 712 JumpTarget target = elements.getTargetOf(node); |
| 690 if (target == null) { | 713 if (target == null) { |
| 691 // This is a continue in an invalid position. | 714 // This is a continue in an invalid position. |
| 692 return new ir.InvalidStatement(); | 715 return new ir.InvalidStatement(); |
| 693 } | 716 } |
| 694 ir.SwitchCase switchCase = getContinueSwitchTarget(target); | 717 ir.SwitchCase switchCase = getContinueSwitchTarget(target); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 719 return new ir.EmptyStatement(); | 742 return new ir.EmptyStatement(); |
| 720 } | 743 } |
| 721 | 744 |
| 722 @override | 745 @override |
| 723 ir.Throw visitEnum(Enum node) { | 746 ir.Throw visitEnum(Enum node) { |
| 724 return buildUnsupported(node, "Enum"); | 747 return buildUnsupported(node, "Enum"); |
| 725 } | 748 } |
| 726 | 749 |
| 727 @override | 750 @override |
| 728 ir.ExpressionStatement visitExpressionStatement(ExpressionStatement node) { | 751 ir.ExpressionStatement visitExpressionStatement(ExpressionStatement node) { |
| 729 return new ir.ExpressionStatement(visitForValue(node.expression)); | 752 return new ir.ExpressionStatement(visitForEffect(node.expression)); |
| 730 } | 753 } |
| 731 | 754 |
| 732 @override | 755 @override |
| 733 ir.Statement visitFor(For node) { | 756 ir.Statement visitFor(For node) { |
| 734 VariableDefinitions initializers = | 757 VariableDefinitions initializers = |
| 735 node.initializer?.asVariableDefinitions(); | 758 node.initializer?.asVariableDefinitions(); |
| 736 ir.Expression initializer; | 759 ir.Expression initializer; |
| 737 List<ir.VariableDeclaration> variables; | 760 List<ir.VariableDeclaration> variables; |
| 738 if (initializers != null) { | 761 if (initializers != null) { |
| 739 ir.Block block = buildStatementInBlock(initializers, forceBlock: true); | 762 ir.Block block = buildStatementInBlock(initializers, forceBlock: true); |
| 740 variables = new List<ir.VariableDeclaration>.from(block.statements); | 763 variables = new List<ir.VariableDeclaration>.from(block.statements); |
| 741 } else { | 764 } else { |
| 742 if (node.initializer != null) { | 765 if (node.initializer != null) { |
| 743 initializer = visitForValue(node.initializer); | 766 initializer = visitForValue(node.initializer); |
| 744 } | 767 } |
| 745 variables = const <ir.VariableDeclaration>[]; | 768 variables = const <ir.VariableDeclaration>[]; |
| 746 } | 769 } |
| 747 ir.Expression condition = visitForValue(node.condition); | 770 ir.Expression condition = visitForValue(node.condition); |
| 748 List<ir.Expression> updates = <ir.Expression>[]; | 771 List<ir.Expression> updates = <ir.Expression>[]; |
| 749 for (Expression update in node.update) { | 772 for (Expression update in node.update) { |
| 750 updates.add(visitForValue(update)); | 773 updates.add(visitForEffect(update)); |
| 751 } | 774 } |
| 752 | 775 |
| 753 JumpTarget jumpTarget = elements.getTargetDefinition(node); | 776 JumpTarget jumpTarget = elements.getTargetDefinition(node); |
| 754 ir.Statement body = buildContinueTarget( | 777 ir.Statement body = buildContinueTarget( |
| 755 buildStatementInBlock(node.body), node, jumpTarget); | 778 buildStatementInBlock(node.body), node, jumpTarget); |
| 756 ir.ForStatement forStatement = new ir.ForStatement( | 779 ir.ForStatement forStatement = new ir.ForStatement( |
| 757 variables, condition, updates, body); | 780 variables, condition, updates, body); |
| 758 ir.Statement result = buildBreakTarget(forStatement, node, jumpTarget); | 781 ir.Statement result = buildBreakTarget(forStatement, node, jumpTarget); |
| 759 if (initializer != null) { | 782 if (initializer != null) { |
| 760 result = new ir.Block(<ir.Statement>[ | 783 result = new ir.Block(<ir.Statement>[ |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 node.name.source, visitForValue(node.expression)); | 915 node.name.source, visitForValue(node.expression)); |
| 893 } | 916 } |
| 894 | 917 |
| 895 @override | 918 @override |
| 896 ir.Throw visitOperator(Operator node) { | 919 ir.Throw visitOperator(Operator node) { |
| 897 return buildUnsupported(node, "Operator"); | 920 return buildUnsupported(node, "Operator"); |
| 898 } | 921 } |
| 899 | 922 |
| 900 @override | 923 @override |
| 901 ir.Expression visitParenthesizedExpression(ParenthesizedExpression node) { | 924 ir.Expression visitParenthesizedExpression(ParenthesizedExpression node) { |
| 902 return visitForValue(node.expression); | 925 return visitWithCurrentContext(node.expression); |
| 903 } | 926 } |
| 904 | 927 |
| 905 @override | 928 @override |
| 906 ir.Throw visitRedirectingFactoryBody(RedirectingFactoryBody node) { | 929 ir.Throw visitRedirectingFactoryBody(RedirectingFactoryBody node) { |
| 907 return buildUnsupported(node, "RedirectingFactoryBody"); | 930 return buildUnsupported(node, "RedirectingFactoryBody"); |
| 908 } | 931 } |
| 909 | 932 |
| 910 @override | 933 @override |
| 911 ir.ExpressionStatement visitRethrow(Rethrow node) { | 934 ir.ExpressionStatement visitRethrow(Rethrow node) { |
| 912 return new ir.ExpressionStatement(new ir.Rethrow()); | 935 return new ir.ExpressionStatement(new ir.Rethrow()); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 Send node, | 1158 Send node, |
| 1136 ConstantExpression constant, | 1159 ConstantExpression constant, |
| 1137 NodeList arguments, | 1160 NodeList arguments, |
| 1138 CallStructure callStructure, | 1161 CallStructure callStructure, |
| 1139 _) { | 1162 _) { |
| 1140 return buildCall(buildTypeLiteral(constant), callStructure, arguments); | 1163 return buildCall(buildTypeLiteral(constant), callStructure, arguments); |
| 1141 } | 1164 } |
| 1142 | 1165 |
| 1143 ir.Expression buildTypeLiteralSet(TypeConstantExpression constant, Node rhs) { | 1166 ir.Expression buildTypeLiteralSet(TypeConstantExpression constant, Node rhs) { |
| 1144 return new ReadOnlyAccessor(buildTypeLiteral(constant)) | 1167 return new ReadOnlyAccessor(buildTypeLiteral(constant)) |
| 1145 .buildAssignment(visitForValue(rhs)); | 1168 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 1146 } | 1169 } |
| 1147 | 1170 |
| 1148 @override | 1171 @override |
| 1149 ir.Expression visitClassTypeLiteralSet( | 1172 ir.Expression visitClassTypeLiteralSet( |
| 1150 SendSet node, | 1173 SendSet node, |
| 1151 ConstantExpression constant, | 1174 ConstantExpression constant, |
| 1152 Node rhs, | 1175 Node rhs, |
| 1153 _) { | 1176 _) { |
| 1154 return buildTypeLiteralSet(constant, rhs); | 1177 return buildTypeLiteralSet(constant, rhs); |
| 1155 } | 1178 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1168 @override | 1191 @override |
| 1169 ir.Expression visitCompoundIndexSet( | 1192 ir.Expression visitCompoundIndexSet( |
| 1170 SendSet node, | 1193 SendSet node, |
| 1171 Node receiver, | 1194 Node receiver, |
| 1172 Node index, | 1195 Node index, |
| 1173 AssignmentOperator operator, | 1196 AssignmentOperator operator, |
| 1174 Node rhs, | 1197 Node rhs, |
| 1175 _) { | 1198 _) { |
| 1176 return buildIndexAccessor(receiver, index).buildCompoundAssignment( | 1199 return buildIndexAccessor(receiver, index).buildCompoundAssignment( |
| 1177 kernel.irName(operator.selectorName, currentElement), | 1200 kernel.irName(operator.selectorName, currentElement), |
| 1178 visitForValue(rhs)); | 1201 visitForValue(rhs), voidContext: isVoidContext); |
| 1179 } | 1202 } |
| 1180 | 1203 |
| 1181 @override | 1204 @override |
| 1182 ir.Expression visitConstConstructorInvoke( | 1205 ir.Expression visitConstConstructorInvoke( |
| 1183 NewExpression node, | 1206 NewExpression node, |
| 1184 ConstructedConstantExpression constant, | 1207 ConstructedConstantExpression constant, |
| 1185 _) { | 1208 _) { |
| 1186 return buildConstConstructorInvoke(node); | 1209 return buildConstConstructorInvoke(node); |
| 1187 } | 1210 } |
| 1188 | 1211 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 ir.Expression handleDynamicSetIfNulls( | 1285 ir.Expression handleDynamicSetIfNulls( |
| 1263 Send node, | 1286 Send node, |
| 1264 Node receiver, | 1287 Node receiver, |
| 1265 Name name, | 1288 Name name, |
| 1266 Node rhs, | 1289 Node rhs, |
| 1267 _) { | 1290 _) { |
| 1268 ir.Name irName = kernel.nameToIrName(name); | 1291 ir.Name irName = kernel.nameToIrName(name); |
| 1269 Accessor accessor = (receiver == null) | 1292 Accessor accessor = (receiver == null) |
| 1270 ? new ThisPropertyAccessor(irName) | 1293 ? new ThisPropertyAccessor(irName) |
| 1271 : PropertyAccessor.make(visitForValue(receiver), irName); | 1294 : PropertyAccessor.make(visitForValue(receiver), irName); |
| 1272 return accessor.buildNullAwareAssignment(visitForValue(rhs)); | 1295 return accessor.buildNullAwareAssignment( |
| 1296 visitForValue(rhs), voidContext: isVoidContext); |
| 1273 } | 1297 } |
| 1274 | 1298 |
| 1275 @override | 1299 @override |
| 1276 ir.TypeLiteral visitDynamicTypeLiteralGet( | 1300 ir.TypeLiteral visitDynamicTypeLiteralGet( |
| 1277 Send node, | 1301 Send node, |
| 1278 ConstantExpression constant, | 1302 ConstantExpression constant, |
| 1279 _) { | 1303 _) { |
| 1280 return buildTypeLiteral(constant); | 1304 return buildTypeLiteral(constant); |
| 1281 } | 1305 } |
| 1282 | 1306 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1351 _) { | 1375 _) { |
| 1352 if (kernel.isSyntheticError(field)) { | 1376 if (kernel.isSyntheticError(field)) { |
| 1353 return new ir.InvalidInitializer(); | 1377 return new ir.InvalidInitializer(); |
| 1354 } else { | 1378 } else { |
| 1355 return new ir.FieldInitializer( | 1379 return new ir.FieldInitializer( |
| 1356 kernel.fieldToIr(field), visitForValue(expression)); | 1380 kernel.fieldToIr(field), visitForValue(expression)); |
| 1357 } | 1381 } |
| 1358 } | 1382 } |
| 1359 | 1383 |
| 1360 ir.Expression buildStaticFieldSet(FieldElement field, Node rhs) { | 1384 ir.Expression buildStaticFieldSet(FieldElement field, Node rhs) { |
| 1361 return buildStaticAccessor(field).buildAssignment(visitForValue(rhs)); | 1385 return buildStaticAccessor(field) |
| 1386 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 1362 } | 1387 } |
| 1363 | 1388 |
| 1364 @override | 1389 @override |
| 1365 ir.Expression handleFinalStaticFieldSet( | 1390 ir.Expression handleFinalStaticFieldSet( |
| 1366 SendSet node, | 1391 SendSet node, |
| 1367 FieldElement field, | 1392 FieldElement field, |
| 1368 Node rhs, | 1393 Node rhs, |
| 1369 _) { | 1394 _) { |
| 1370 return buildStaticFieldSet(field, rhs); | 1395 return buildStaticFieldSet(field, rhs); |
| 1371 } | 1396 } |
| 1372 | 1397 |
| 1373 @override | 1398 @override |
| 1374 ir.Expression visitFinalSuperFieldSet( | 1399 ir.Expression visitFinalSuperFieldSet( |
| 1375 SendSet node, FieldElement field, Node rhs, _) { | 1400 SendSet node, FieldElement field, Node rhs, _) { |
| 1376 return buildSuperPropertyAccessor(field) | 1401 return buildSuperPropertyAccessor(field) |
| 1377 .buildAssignment(visitForValue(rhs)); | 1402 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 1378 } | 1403 } |
| 1379 | 1404 |
| 1380 void addFieldsWithInitializers( | 1405 void addFieldsWithInitializers( |
| 1381 ConstructorElement constructor, | 1406 ConstructorElement constructor, |
| 1382 List<ir.Initializer> initializers) { | 1407 List<ir.Initializer> initializers) { |
| 1383 constructor.enclosingClass.forEachInstanceField((_, FieldElement element) { | 1408 constructor.enclosingClass.forEachInstanceField((_, FieldElement element) { |
| 1384 // Convert the element into the corresponding IR field before asking | 1409 // Convert the element into the corresponding IR field before asking |
| 1385 // if the initializer exists. This is necessary to ensure that the | 1410 // if the initializer exists. This is necessary to ensure that the |
| 1386 // element has been analyzed before looking at its initializer. | 1411 // element has been analyzed before looking at its initializer. |
| 1387 ir.Field field = kernel.fieldToIr(element); | 1412 ir.Field field = kernel.fieldToIr(element); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1550 } | 1575 } |
| 1551 | 1576 |
| 1552 @override | 1577 @override |
| 1553 ir.Expression visitIfNotNullDynamicPropertySet( | 1578 ir.Expression visitIfNotNullDynamicPropertySet( |
| 1554 SendSet node, | 1579 SendSet node, |
| 1555 Node receiver, | 1580 Node receiver, |
| 1556 Name name, | 1581 Name name, |
| 1557 Node rhs, | 1582 Node rhs, |
| 1558 _) { | 1583 _) { |
| 1559 return buildNullAwarePropertyAccessor(receiver, name).buildAssignment( | 1584 return buildNullAwarePropertyAccessor(receiver, name).buildAssignment( |
| 1560 visitForValue(rhs)); | 1585 visitForValue(rhs), voidContext: isVoidContext); |
| 1561 } | 1586 } |
| 1562 | 1587 |
| 1563 @override | 1588 @override |
| 1564 ir.Throw visitIfNotNullDynamicPropertySetIfNull( | 1589 ir.Throw visitIfNotNullDynamicPropertySetIfNull( |
| 1565 Send node, | 1590 Send node, |
| 1566 Node receiver, | 1591 Node receiver, |
| 1567 Name name, | 1592 Name name, |
| 1568 Node rhs, | 1593 Node rhs, |
| 1569 _) { | 1594 _) { |
| 1570 return buildNullAwarePropertyAccessor(receiver, name) | 1595 return buildNullAwarePropertyAccessor(receiver, name) |
| 1571 .buildNullAwareAssignment(visitForValue(rhs)); | 1596 .buildNullAwareAssignment( |
| 1597 visitForValue(rhs), voidContext: isVoidContext); |
| 1572 } | 1598 } |
| 1573 | 1599 |
| 1574 ir.LogicalExpression buildLogicalExpression( | 1600 ir.LogicalExpression buildLogicalExpression( |
| 1575 Node left, | 1601 Node left, |
| 1576 Operator operator, | 1602 Operator operator, |
| 1577 Node right) { | 1603 Node right) { |
| 1578 return new ir.LogicalExpression( | 1604 return new ir.LogicalExpression( |
| 1579 visitForValue(left), operator.source, visitForValue(right)); | 1605 visitForValue(left), operator.source, visitForValue(right)); |
| 1580 } | 1606 } |
| 1581 | 1607 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1605 | 1631 |
| 1606 @override | 1632 @override |
| 1607 ir.Expression visitIndex(Send node, Node receiver, Node index, _) { | 1633 ir.Expression visitIndex(Send node, Node receiver, Node index, _) { |
| 1608 return buildIndexAccessor(receiver, index).buildSimpleRead(); | 1634 return buildIndexAccessor(receiver, index).buildSimpleRead(); |
| 1609 } | 1635 } |
| 1610 | 1636 |
| 1611 ir.Expression buildIndexPostfix( | 1637 ir.Expression buildIndexPostfix( |
| 1612 Accessor accessor, | 1638 Accessor accessor, |
| 1613 IncDecOperator operator) { | 1639 IncDecOperator operator) { |
| 1614 ir.Name name = kernel.irName(operator.selectorName, currentElement); | 1640 ir.Name name = kernel.irName(operator.selectorName, currentElement); |
| 1615 return accessor.buildPostfixIncrement(name); | 1641 return accessor.buildPostfixIncrement(name, voidContext: isVoidContext); |
| 1616 } | 1642 } |
| 1617 | 1643 |
| 1618 @override | 1644 @override |
| 1619 ir.Expression visitIndexPostfix( | 1645 ir.Expression visitIndexPostfix( |
| 1620 Send node, | 1646 Send node, |
| 1621 Node receiver, | 1647 Node receiver, |
| 1622 Node index, | 1648 Node index, |
| 1623 IncDecOperator operator, | 1649 IncDecOperator operator, |
| 1624 _) { | 1650 _) { |
| 1625 return buildIndexPostfix(buildIndexAccessor(receiver, index), operator); | 1651 return buildIndexPostfix(buildIndexAccessor(receiver, index), operator); |
| 1626 } | 1652 } |
| 1627 | 1653 |
| 1628 ir.Expression buildIndexPrefix(Accessor accessor, IncDecOperator operator) { | 1654 ir.Expression buildIndexPrefix(Accessor accessor, IncDecOperator operator) { |
| 1629 ir.Name name = kernel.irName(operator.selectorName, currentElement); | 1655 ir.Name name = kernel.irName(operator.selectorName, currentElement); |
| 1630 return accessor.buildPrefixIncrement(name); | 1656 return accessor.buildPrefixIncrement(name, voidContext: isVoidContext); |
| 1631 } | 1657 } |
| 1632 | 1658 |
| 1633 | 1659 |
| 1634 @override | 1660 @override |
| 1635 ir.Expression visitIndexPrefix( | 1661 ir.Expression visitIndexPrefix( |
| 1636 Send node, | 1662 Send node, |
| 1637 Node receiver, | 1663 Node receiver, |
| 1638 Node index, | 1664 Node index, |
| 1639 IncDecOperator operator, | 1665 IncDecOperator operator, |
| 1640 _) { | 1666 _) { |
| 1641 return buildIndexPrefix(buildIndexAccessor(receiver, index), operator); | 1667 return buildIndexPrefix(buildIndexAccessor(receiver, index), operator); |
| 1642 } | 1668 } |
| 1643 | 1669 |
| 1644 @override | 1670 @override |
| 1645 ir.Expression visitIndexSet( | 1671 ir.Expression visitIndexSet( |
| 1646 SendSet node, Node receiver, Node index, Node rhs, _) { | 1672 SendSet node, Node receiver, Node index, Node rhs, _) { |
| 1647 return buildIndexAccessor(receiver, index) | 1673 return buildIndexAccessor(receiver, index) |
| 1648 .buildAssignment(visitForValue(rhs)); | 1674 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 1649 } | 1675 } |
| 1650 | 1676 |
| 1651 ir.Initializer buildInitializingFormal(InitializingFormalElement parameter) { | 1677 ir.Initializer buildInitializingFormal(InitializingFormalElement parameter) { |
| 1652 FieldElement field = parameter.fieldElement; | 1678 FieldElement field = parameter.fieldElement; |
| 1653 if (kernel.isSyntheticError(field)) { | 1679 if (kernel.isSyntheticError(field)) { |
| 1654 return new ir.InvalidInitializer(); | 1680 return new ir.InvalidInitializer(); |
| 1655 } else { | 1681 } else { |
| 1656 return new ir.FieldInitializer( | 1682 return new ir.FieldInitializer( |
| 1657 kernel.fieldToIr(field), buildLocalGet(parameter)); | 1683 kernel.fieldToIr(field), buildLocalGet(parameter)); |
| 1658 } | 1684 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1776 | 1802 |
| 1777 @override | 1803 @override |
| 1778 ir.VariableGet handleLocalGet(Send node, LocalElement element, _) { | 1804 ir.VariableGet handleLocalGet(Send node, LocalElement element, _) { |
| 1779 return buildLocalGet(element); | 1805 return buildLocalGet(element); |
| 1780 } | 1806 } |
| 1781 | 1807 |
| 1782 ir.Expression buildCompound(Accessor accessor, CompoundRhs rhs) { | 1808 ir.Expression buildCompound(Accessor accessor, CompoundRhs rhs) { |
| 1783 ir.Name name = kernel.irName(rhs.operator.selectorName, currentElement); | 1809 ir.Name name = kernel.irName(rhs.operator.selectorName, currentElement); |
| 1784 switch (rhs.kind) { | 1810 switch (rhs.kind) { |
| 1785 case CompoundKind.POSTFIX: | 1811 case CompoundKind.POSTFIX: |
| 1786 return accessor.buildPostfixIncrement(name); | 1812 return accessor.buildPostfixIncrement(name, voidContext: isVoidContext); |
| 1787 | 1813 |
| 1788 case CompoundKind.PREFIX: | 1814 case CompoundKind.PREFIX: |
| 1789 return accessor.buildPrefixIncrement(name); | 1815 return accessor.buildPrefixIncrement(name, voidContext: isVoidContext); |
| 1790 | 1816 |
| 1791 case CompoundKind.ASSIGNMENT: | 1817 case CompoundKind.ASSIGNMENT: |
| 1792 return accessor.buildCompoundAssignment(name, visitForValue(rhs.rhs)); | 1818 return accessor.buildCompoundAssignment( |
| 1819 name, visitForValue(rhs.rhs), voidContext: isVoidContext); |
| 1793 } | 1820 } |
| 1794 } | 1821 } |
| 1795 | 1822 |
| 1796 @override | 1823 @override |
| 1797 ir.Expression handleLocalCompounds( | 1824 ir.Expression handleLocalCompounds( |
| 1798 SendSet node, | 1825 SendSet node, |
| 1799 LocalElement local, | 1826 LocalElement local, |
| 1800 CompoundRhs rhs, | 1827 CompoundRhs rhs, |
| 1801 _, | 1828 _, |
| 1802 {bool isSetterValid}) { | 1829 {bool isSetterValid}) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1905 } | 1932 } |
| 1906 | 1933 |
| 1907 @override | 1934 @override |
| 1908 ir.Expression handleLocalSetIfNulls( | 1935 ir.Expression handleLocalSetIfNulls( |
| 1909 SendSet node, | 1936 SendSet node, |
| 1910 LocalElement local, | 1937 LocalElement local, |
| 1911 Node rhs, | 1938 Node rhs, |
| 1912 _, | 1939 _, |
| 1913 {bool isSetterValid}) { | 1940 {bool isSetterValid}) { |
| 1914 return new VariableAccessor(getLocal(local)) | 1941 return new VariableAccessor(getLocal(local)) |
| 1915 .buildNullAwareAssignment(visitForValue(rhs)); | 1942 .buildNullAwareAssignment( |
| 1943 visitForValue(rhs), voidContext: isVoidContext); |
| 1916 } | 1944 } |
| 1917 | 1945 |
| 1918 @override | 1946 @override |
| 1919 IrFunction visitRedirectingFactoryConstructorDeclaration( | 1947 IrFunction visitRedirectingFactoryConstructorDeclaration( |
| 1920 FunctionExpression node, | 1948 FunctionExpression node, |
| 1921 ConstructorElement constructor, | 1949 ConstructorElement constructor, |
| 1922 NodeList parameters, | 1950 NodeList parameters, |
| 1923 DartType redirectionType, // TODO(ahe): Should be InterfaceType. | 1951 DartType redirectionType, // TODO(ahe): Should be InterfaceType. |
| 1924 ConstructorElement redirectionTarget, | 1952 ConstructorElement redirectionTarget, |
| 1925 _) { | 1953 _) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2044 Element getter, | 2072 Element getter, |
| 2045 CompoundGetter getterKind, | 2073 CompoundGetter getterKind, |
| 2046 Element setter, | 2074 Element setter, |
| 2047 CompoundSetter setterKind, | 2075 CompoundSetter setterKind, |
| 2048 Node rhs, | 2076 Node rhs, |
| 2049 _) { | 2077 _) { |
| 2050 if (setterKind == CompoundSetter.INVALID) { | 2078 if (setterKind == CompoundSetter.INVALID) { |
| 2051 setter = null; | 2079 setter = null; |
| 2052 } | 2080 } |
| 2053 return buildStaticAccessor(getter, setter) | 2081 return buildStaticAccessor(getter, setter) |
| 2054 .buildNullAwareAssignment(visitForValue(rhs)); | 2082 .buildNullAwareAssignment( |
| 2083 visitForValue(rhs), voidContext: isVoidContext); |
| 2055 } | 2084 } |
| 2056 | 2085 |
| 2057 ir.VariableDeclaration getLocal(LocalElement local) { | 2086 ir.VariableDeclaration getLocal(LocalElement local) { |
| 2058 return locals.putIfAbsent(local, () { | 2087 return locals.putIfAbsent(local, () { |
| 2059 return new ir.VariableDeclaration( | 2088 return new ir.VariableDeclaration( |
| 2060 local.name, initializer: null, type: typeToIrHack(local.type), | 2089 local.name, initializer: null, type: typeToIrHack(local.type), |
| 2061 isFinal: local.isFinal, isConst: local.isConst); | 2090 isFinal: local.isFinal, isConst: local.isConst); |
| 2062 }); | 2091 }); |
| 2063 } | 2092 } |
| 2064 | 2093 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 _) { | 2234 _) { |
| 2206 return buildStaticInvoke(function, arguments, isConst: false); | 2235 return buildStaticInvoke(function, arguments, isConst: false); |
| 2207 } | 2236 } |
| 2208 | 2237 |
| 2209 @override | 2238 @override |
| 2210 ir.Expression handleStaticFunctionSet( | 2239 ir.Expression handleStaticFunctionSet( |
| 2211 Send node, | 2240 Send node, |
| 2212 MethodElement function, | 2241 MethodElement function, |
| 2213 Node rhs, | 2242 Node rhs, |
| 2214 _) { | 2243 _) { |
| 2215 return buildStaticAccessor(function).buildAssignment(visitForValue(rhs)); | 2244 return buildStaticAccessor(function) |
| 2245 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2216 } | 2246 } |
| 2217 | 2247 |
| 2218 @override | 2248 @override |
| 2219 IrFunction visitStaticGetterDeclaration( | 2249 IrFunction visitStaticGetterDeclaration( |
| 2220 FunctionExpression node, | 2250 FunctionExpression node, |
| 2221 MethodElement getter, | 2251 MethodElement getter, |
| 2222 Node body, | 2252 Node body, |
| 2223 _) { | 2253 _) { |
| 2224 return buildIrFunction(ir.ProcedureKind.Getter, getter, body); | 2254 return buildIrFunction(ir.ProcedureKind.Getter, getter, body); |
| 2225 } | 2255 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2247 } | 2277 } |
| 2248 return buildCall(buildStaticGet(getter), callStructure, arguments); | 2278 return buildCall(buildStaticGet(getter), callStructure, arguments); |
| 2249 } | 2279 } |
| 2250 | 2280 |
| 2251 @override | 2281 @override |
| 2252 ir.Expression handleStaticGetterSet( | 2282 ir.Expression handleStaticGetterSet( |
| 2253 SendSet node, | 2283 SendSet node, |
| 2254 FunctionElement getter, | 2284 FunctionElement getter, |
| 2255 Node rhs, | 2285 Node rhs, |
| 2256 _) { | 2286 _) { |
| 2257 return buildStaticAccessor(getter).buildAssignment(visitForValue(rhs)); | 2287 return buildStaticAccessor(getter) |
| 2288 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2258 } | 2289 } |
| 2259 | 2290 |
| 2260 @override | 2291 @override |
| 2261 IrFunction visitStaticSetterDeclaration( | 2292 IrFunction visitStaticSetterDeclaration( |
| 2262 FunctionExpression node, | 2293 FunctionExpression node, |
| 2263 MethodElement setter, | 2294 MethodElement setter, |
| 2264 NodeList parameters, | 2295 NodeList parameters, |
| 2265 Node body, | 2296 Node body, |
| 2266 _) { | 2297 _) { |
| 2267 return buildIrFunction(ir.ProcedureKind.Setter, setter, body); | 2298 return buildIrFunction(ir.ProcedureKind.Setter, setter, body); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2281 _) { | 2312 _) { |
| 2282 return buildCall( | 2313 return buildCall( |
| 2283 buildStaticAccessor(null, setter).buildSimpleRead(), | 2314 buildStaticAccessor(null, setter).buildSimpleRead(), |
| 2284 callStructure, arguments); | 2315 callStructure, arguments); |
| 2285 } | 2316 } |
| 2286 | 2317 |
| 2287 @override | 2318 @override |
| 2288 ir.Expression handleStaticSetterSet( | 2319 ir.Expression handleStaticSetterSet( |
| 2289 SendSet node, FunctionElement setter, Node rhs, _) { | 2320 SendSet node, FunctionElement setter, Node rhs, _) { |
| 2290 return buildStaticAccessor(null, setter) | 2321 return buildStaticAccessor(null, setter) |
| 2291 .buildAssignment(visitForValue(rhs)); | 2322 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2292 } | 2323 } |
| 2293 | 2324 |
| 2294 @override | 2325 @override |
| 2295 ir.Expression visitStringFromEnvironmentConstructorInvoke( | 2326 ir.Expression visitStringFromEnvironmentConstructorInvoke( |
| 2296 NewExpression node, | 2327 NewExpression node, |
| 2297 StringFromEnvironmentConstantExpression constant, | 2328 StringFromEnvironmentConstantExpression constant, |
| 2298 _) { | 2329 _) { |
| 2299 return buildConstConstructorInvoke(node); | 2330 return buildConstConstructorInvoke(node); |
| 2300 } | 2331 } |
| 2301 | 2332 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2316 SendSet node, | 2347 SendSet node, |
| 2317 MethodElement getter, | 2348 MethodElement getter, |
| 2318 MethodElement setter, | 2349 MethodElement setter, |
| 2319 Node index, | 2350 Node index, |
| 2320 AssignmentOperator operator, | 2351 AssignmentOperator operator, |
| 2321 Node rhs, | 2352 Node rhs, |
| 2322 _) { | 2353 _) { |
| 2323 return | 2354 return |
| 2324 buildSuperIndexAccessor(index, getter, setter).buildCompoundAssignment( | 2355 buildSuperIndexAccessor(index, getter, setter).buildCompoundAssignment( |
| 2325 kernel.irName(operator.selectorName, currentElement), | 2356 kernel.irName(operator.selectorName, currentElement), |
| 2326 visitForValue(rhs)); | 2357 visitForValue(rhs), voidContext: isVoidContext); |
| 2327 } | 2358 } |
| 2328 | 2359 |
| 2329 @override | 2360 @override |
| 2330 ir.Initializer visitSuperConstructorInvoke( | 2361 ir.Initializer visitSuperConstructorInvoke( |
| 2331 Send node, | 2362 Send node, |
| 2332 ConstructorElement superConstructor, | 2363 ConstructorElement superConstructor, |
| 2333 InterfaceType type, | 2364 InterfaceType type, |
| 2334 NodeList arguments, | 2365 NodeList arguments, |
| 2335 CallStructure callStructure, | 2366 CallStructure callStructure, |
| 2336 _) { | 2367 _) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2425 _) { | 2456 _) { |
| 2426 return buildCall( | 2457 return buildCall( |
| 2427 buildSuperPropertyAccessor(field).buildSimpleRead(), | 2458 buildSuperPropertyAccessor(field).buildSimpleRead(), |
| 2428 callStructure, arguments); | 2459 callStructure, arguments); |
| 2429 } | 2460 } |
| 2430 | 2461 |
| 2431 @override | 2462 @override |
| 2432 ir.Expression visitSuperFieldSet( | 2463 ir.Expression visitSuperFieldSet( |
| 2433 SendSet node, FieldElement field, Node rhs, _) { | 2464 SendSet node, FieldElement field, Node rhs, _) { |
| 2434 return buildSuperPropertyAccessor(field) | 2465 return buildSuperPropertyAccessor(field) |
| 2435 .buildAssignment(visitForValue(rhs)); | 2466 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2436 } | 2467 } |
| 2437 | 2468 |
| 2438 Accessor buildSuperPropertyAccessor(Element getter, [Element setter]) { | 2469 Accessor buildSuperPropertyAccessor(Element getter, [Element setter]) { |
| 2439 if (setter == null && getter.isField && !getter.isFinal && | 2470 if (setter == null && getter.isField && !getter.isFinal && |
| 2440 !getter.isConst) { | 2471 !getter.isConst) { |
| 2441 setter = getter; | 2472 setter = getter; |
| 2442 } | 2473 } |
| 2443 return new SuperPropertyAccessor( | 2474 return new SuperPropertyAccessor( |
| 2444 (getter == null) ? null : kernel.elementToIr(getter), | 2475 (getter == null) ? null : kernel.elementToIr(getter), |
| 2445 (setter == null) ? null : kernel.elementToIr(setter)); | 2476 (setter == null) ? null : kernel.elementToIr(setter)); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 2476 _) { | 2507 _) { |
| 2477 return buildCall( | 2508 return buildCall( |
| 2478 buildSuperPropertyAccessor(getter).buildSimpleRead(), | 2509 buildSuperPropertyAccessor(getter).buildSimpleRead(), |
| 2479 callStructure, arguments); | 2510 callStructure, arguments); |
| 2480 } | 2511 } |
| 2481 | 2512 |
| 2482 @override | 2513 @override |
| 2483 ir.Expression visitSuperGetterSet( | 2514 ir.Expression visitSuperGetterSet( |
| 2484 SendSet node, FunctionElement getter, Node rhs, _) { | 2515 SendSet node, FunctionElement getter, Node rhs, _) { |
| 2485 return buildSuperPropertyAccessor(getter) | 2516 return buildSuperPropertyAccessor(getter) |
| 2486 .buildAssignment(visitForValue(rhs)); | 2517 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2487 } | 2518 } |
| 2488 | 2519 |
| 2489 @override | 2520 @override |
| 2490 ir.Expression handleSuperSetIfNulls( | 2521 ir.Expression handleSuperSetIfNulls( |
| 2491 SendSet node, | 2522 SendSet node, |
| 2492 Element getter, | 2523 Element getter, |
| 2493 CompoundGetter getterKind, | 2524 CompoundGetter getterKind, |
| 2494 Element setter, | 2525 Element setter, |
| 2495 CompoundSetter setterKind, | 2526 CompoundSetter setterKind, |
| 2496 Node rhs, | 2527 Node rhs, |
| 2497 _) { | 2528 _) { |
| 2498 if (setterKind == CompoundSetter.INVALID) { | 2529 if (setterKind == CompoundSetter.INVALID) { |
| 2499 setter = null; | 2530 setter = null; |
| 2500 } | 2531 } |
| 2501 return buildSuperPropertyAccessor(getter, setter) | 2532 return buildSuperPropertyAccessor(getter, setter) |
| 2502 .buildNullAwareAssignment(visitForValue(rhs)); | 2533 .buildNullAwareAssignment( |
| 2534 visitForValue(rhs), voidContext: isVoidContext); |
| 2503 } | 2535 } |
| 2504 | 2536 |
| 2505 @override | 2537 @override |
| 2506 ir.SuperMethodInvocation visitSuperIndex( | 2538 ir.SuperMethodInvocation visitSuperIndex( |
| 2507 Send node, FunctionElement function, Node index, _) { | 2539 Send node, FunctionElement function, Node index, _) { |
| 2508 return buildSuperIndexAccessor(index, function).buildSimpleRead(); | 2540 return buildSuperIndexAccessor(index, function).buildSimpleRead(); |
| 2509 } | 2541 } |
| 2510 | 2542 |
| 2511 @override | 2543 @override |
| 2512 ir.Expression visitSuperIndexPostfix( | 2544 ir.Expression visitSuperIndexPostfix( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2535 } | 2567 } |
| 2536 | 2568 |
| 2537 @override | 2569 @override |
| 2538 ir.Expression visitSuperIndexSet( | 2570 ir.Expression visitSuperIndexSet( |
| 2539 SendSet node, | 2571 SendSet node, |
| 2540 FunctionElement function, | 2572 FunctionElement function, |
| 2541 Node index, | 2573 Node index, |
| 2542 Node rhs, | 2574 Node rhs, |
| 2543 _) { | 2575 _) { |
| 2544 return buildSuperIndexAccessor(index, null, function) | 2576 return buildSuperIndexAccessor(index, null, function) |
| 2545 .buildAssignment(visitForValue(rhs)); | 2577 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2546 } | 2578 } |
| 2547 | 2579 |
| 2548 @override | 2580 @override |
| 2549 ir.Expression visitSuperMethodGet(Send node, MethodElement method, _) { | 2581 ir.Expression visitSuperMethodGet(Send node, MethodElement method, _) { |
| 2550 return buildSuperPropertyAccessor(method).buildSimpleRead(); | 2582 return buildSuperPropertyAccessor(method).buildSimpleRead(); |
| 2551 } | 2583 } |
| 2552 | 2584 |
| 2553 ir.SuperMethodInvocation buildSuperMethodInvoke( | 2585 ir.SuperMethodInvocation buildSuperMethodInvoke( |
| 2554 MethodElement method, | 2586 MethodElement method, |
| 2555 NodeList arguments) { | 2587 NodeList arguments) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2574 NodeList arguments, | 2606 NodeList arguments, |
| 2575 CallStructure callStructure, | 2607 CallStructure callStructure, |
| 2576 _) { | 2608 _) { |
| 2577 return buildSuperMethodInvoke(method, arguments); | 2609 return buildSuperMethodInvoke(method, arguments); |
| 2578 } | 2610 } |
| 2579 | 2611 |
| 2580 @override | 2612 @override |
| 2581 ir.Expression visitSuperMethodSet( | 2613 ir.Expression visitSuperMethodSet( |
| 2582 Send node, MethodElement method, Node rhs, _) { | 2614 Send node, MethodElement method, Node rhs, _) { |
| 2583 return buildSuperPropertyAccessor(method) | 2615 return buildSuperPropertyAccessor(method) |
| 2584 .buildAssignment(visitForValue(rhs)); | 2616 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2585 } | 2617 } |
| 2586 | 2618 |
| 2587 @override | 2619 @override |
| 2588 ir.Not visitSuperNotEquals( | 2620 ir.Not visitSuperNotEquals( |
| 2589 Send node, | 2621 Send node, |
| 2590 FunctionElement function, | 2622 FunctionElement function, |
| 2591 Node argument, | 2623 Node argument, |
| 2592 _) { | 2624 _) { |
| 2593 return new ir.Not(buildSuperEquals(function, argument)); | 2625 return new ir.Not(buildSuperEquals(function, argument)); |
| 2594 } | 2626 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2610 _) { | 2642 _) { |
| 2611 return buildCall( | 2643 return buildCall( |
| 2612 buildSuperPropertyAccessor(null, setter).buildSimpleRead(), | 2644 buildSuperPropertyAccessor(null, setter).buildSimpleRead(), |
| 2613 callStructure, arguments); | 2645 callStructure, arguments); |
| 2614 } | 2646 } |
| 2615 | 2647 |
| 2616 @override | 2648 @override |
| 2617 ir.Expression visitSuperSetterSet( | 2649 ir.Expression visitSuperSetterSet( |
| 2618 SendSet node, FunctionElement setter, Node rhs, _) { | 2650 SendSet node, FunctionElement setter, Node rhs, _) { |
| 2619 return buildSuperPropertyAccessor(null, setter) | 2651 return buildSuperPropertyAccessor(null, setter) |
| 2620 .buildAssignment(visitForValue(rhs)); | 2652 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2621 } | 2653 } |
| 2622 | 2654 |
| 2623 @override | 2655 @override |
| 2624 ir.SuperMethodInvocation visitSuperUnary( | 2656 ir.SuperMethodInvocation visitSuperUnary( |
| 2625 Send node, | 2657 Send node, |
| 2626 UnaryOperator operator, | 2658 UnaryOperator operator, |
| 2627 FunctionElement function, | 2659 FunctionElement function, |
| 2628 _) { | 2660 _) { |
| 2629 return new ir.SuperMethodInvocation( | 2661 return new ir.SuperMethodInvocation( |
| 2630 kernel.functionToIr(function), new ir.Arguments.empty()); | 2662 kernel.functionToIr(function), new ir.Arguments.empty()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2673 Send node, | 2705 Send node, |
| 2674 NodeList arguments, | 2706 NodeList arguments, |
| 2675 Selector selector, | 2707 Selector selector, |
| 2676 _) { | 2708 _) { |
| 2677 return buildInvokeSelector( | 2709 return buildInvokeSelector( |
| 2678 new ir.ThisExpression(), selector, buildArguments(arguments)); | 2710 new ir.ThisExpression(), selector, buildArguments(arguments)); |
| 2679 } | 2711 } |
| 2680 | 2712 |
| 2681 @override | 2713 @override |
| 2682 ir.Expression visitThisPropertySet(SendSet node, Name name, Node rhs, _) { | 2714 ir.Expression visitThisPropertySet(SendSet node, Name name, Node rhs, _) { |
| 2683 return buildThisPropertyAccessor(name).buildAssignment(visitForValue(rhs)); | 2715 return buildThisPropertyAccessor(name) |
| 2716 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2684 } | 2717 } |
| 2685 | 2718 |
| 2686 @override | 2719 @override |
| 2687 ir.Throw visitTopLevelConstantDeclaration( | 2720 ir.Throw visitTopLevelConstantDeclaration( |
| 2688 VariableDefinitions node, | 2721 VariableDefinitions node, |
| 2689 Node definition, | 2722 Node definition, |
| 2690 FieldElement field, | 2723 FieldElement field, |
| 2691 ConstantExpression constant, | 2724 ConstantExpression constant, |
| 2692 _) { | 2725 _) { |
| 2693 return buildUnsupported(node, "TopLevelConstantDeclaration"); | 2726 return buildUnsupported(node, "TopLevelConstantDeclaration"); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2765 return buildCall(buildTypeVariable(element), callStructure, arguments); | 2798 return buildCall(buildTypeVariable(element), callStructure, arguments); |
| 2766 } | 2799 } |
| 2767 | 2800 |
| 2768 @override | 2801 @override |
| 2769 ir.Expression visitTypeVariableTypeLiteralSet( | 2802 ir.Expression visitTypeVariableTypeLiteralSet( |
| 2770 SendSet node, | 2803 SendSet node, |
| 2771 TypeVariableElement element, | 2804 TypeVariableElement element, |
| 2772 Node rhs, | 2805 Node rhs, |
| 2773 _) { | 2806 _) { |
| 2774 return new ReadOnlyAccessor(buildTypeVariable(element)) | 2807 return new ReadOnlyAccessor(buildTypeVariable(element)) |
| 2775 .buildAssignment(visitForValue(rhs)); | 2808 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); |
| 2776 } | 2809 } |
| 2777 | 2810 |
| 2778 @override | 2811 @override |
| 2779 ir.Expression visitTypeVariableTypeLiteralSetIfNull( | 2812 ir.Expression visitTypeVariableTypeLiteralSetIfNull( |
| 2780 Send node, | 2813 Send node, |
| 2781 TypeVariableElement element, | 2814 TypeVariableElement element, |
| 2782 Node rhs, | 2815 Node rhs, |
| 2783 _) { | 2816 _) { |
| 2784 return new ReadOnlyAccessor(buildTypeVariable(element)) | 2817 return new ReadOnlyAccessor(buildTypeVariable(element)) |
| 2785 .buildNullAwareAssignment(visitForValue(rhs)); | 2818 .buildNullAwareAssignment( |
| 2819 visitForValue(rhs), voidContext: isVoidContext); |
| 2786 } | 2820 } |
| 2787 | 2821 |
| 2788 @override | 2822 @override |
| 2789 ir.TypeLiteral visitTypedefTypeLiteralGet( | 2823 ir.TypeLiteral visitTypedefTypeLiteralGet( |
| 2790 Send node, | 2824 Send node, |
| 2791 ConstantExpression constant, | 2825 ConstantExpression constant, |
| 2792 _) { | 2826 _) { |
| 2793 return buildTypeLiteral(constant); | 2827 return buildTypeLiteral(constant); |
| 2794 } | 2828 } |
| 2795 | 2829 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2846 @override | 2880 @override |
| 2847 ir.Throw visitForIn(ForIn node) { | 2881 ir.Throw visitForIn(ForIn node) { |
| 2848 return internalError( | 2882 return internalError( |
| 2849 node, "Should have been caught by visitAsyncForIn or visitSyncForIn"); | 2883 node, "Should have been caught by visitAsyncForIn or visitSyncForIn"); |
| 2850 } | 2884 } |
| 2851 | 2885 |
| 2852 @override | 2886 @override |
| 2853 ir.Expression visitIndexSetIfNull( | 2887 ir.Expression visitIndexSetIfNull( |
| 2854 SendSet node, Node receiver, Node index, Node rhs, _) { | 2888 SendSet node, Node receiver, Node index, Node rhs, _) { |
| 2855 return buildIndexAccessor(receiver, index) | 2889 return buildIndexAccessor(receiver, index) |
| 2856 .buildNullAwareAssignment(visitForValue(rhs)); | 2890 .buildNullAwareAssignment( |
| 2891 visitForValue(rhs), voidContext: isVoidContext); |
| 2857 } | 2892 } |
| 2858 | 2893 |
| 2859 @override | 2894 @override |
| 2860 ir.Expression visitSuperIndexSetIfNull( | 2895 ir.Expression visitSuperIndexSetIfNull( |
| 2861 SendSet node, | 2896 SendSet node, |
| 2862 MethodElement getter, | 2897 MethodElement getter, |
| 2863 MethodElement setter, | 2898 MethodElement setter, |
| 2864 Node index, | 2899 Node index, |
| 2865 Node rhs, _) { | 2900 Node rhs, _) { |
| 2866 return buildSuperIndexAccessor(index, getter, setter) | 2901 return buildSuperIndexAccessor(index, getter, setter) |
| 2867 .buildNullAwareAssignment(visitForValue(rhs)); | 2902 .buildNullAwareAssignment( |
| 2903 visitForValue(rhs), voidContext: isVoidContext); |
| 2868 } | 2904 } |
| 2869 | 2905 |
| 2870 @override | 2906 @override |
| 2871 ir.Node visitVariableDefinitions(VariableDefinitions definitions) { | 2907 ir.Node visitVariableDefinitions(VariableDefinitions definitions) { |
| 2872 // TODO(ahe): This method is copied from [SemanticDeclarationResolvedMixin] | 2908 // TODO(ahe): This method is copied from [SemanticDeclarationResolvedMixin] |
| 2873 // and modified. Perhaps we can find a way to avoid code duplication. | 2909 // and modified. Perhaps we can find a way to avoid code duplication. |
| 2874 List<ir.VariableDeclaration> variables = <ir.VariableDeclaration>[]; | 2910 List<ir.VariableDeclaration> variables = <ir.VariableDeclaration>[]; |
| 2875 computeVariableStructures(definitions, | 2911 computeVariableStructures(definitions, |
| 2876 (Node node, VariableStructure structure) { | 2912 (Node node, VariableStructure structure) { |
| 2877 if (structure == null) { | 2913 if (structure == null) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2966 : this(null, true, node, initializers); | 3002 : this(null, true, node, initializers); |
| 2967 | 3003 |
| 2968 accept(ir.Visitor v) => throw "unsupported"; | 3004 accept(ir.Visitor v) => throw "unsupported"; |
| 2969 | 3005 |
| 2970 visitChildren(ir.Visitor v) => throw "unsupported"; | 3006 visitChildren(ir.Visitor v) => throw "unsupported"; |
| 2971 | 3007 |
| 2972 String toString() { | 3008 String toString() { |
| 2973 return "IrFunction($kind, $isConstructor, $node, $initializers)"; | 3009 return "IrFunction($kind, $isConstructor, $node, $initializers)"; |
| 2974 } | 3010 } |
| 2975 } | 3011 } |
| OLD | NEW |