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.optimization.statement_rewriter; | 5 library tree_ir.optimization.statement_rewriter; |
6 | 6 |
7 import 'optimization.dart' show Pass; | 7 import 'optimization.dart' show Pass; |
8 import '../tree_ir_nodes.dart'; | 8 import '../tree_ir_nodes.dart'; |
9 import '../../io/source_information.dart'; | 9 import '../../io/source_information.dart'; |
10 | 10 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 // Impure expressions cannot be propagated across the method lookup, | 484 // Impure expressions cannot be propagated across the method lookup, |
485 // because it throws when the receiver is null. | 485 // because it throws when the receiver is null. |
486 inEmptyEnvironment(() { | 486 inEmptyEnvironment(() { |
487 _rewriteList(node.arguments); | 487 _rewriteList(node.arguments); |
488 }); | 488 }); |
489 node.receiver = visitExpression(node.receiver); | 489 node.receiver = visitExpression(node.receiver); |
490 } | 490 } |
491 return node; | 491 return node; |
492 } | 492 } |
493 | 493 |
| 494 Expression visitApplyBuiltinMethod(ApplyBuiltinMethod node) { |
| 495 if (node.receiverIsNotNull) { |
| 496 _rewriteList(node.arguments); |
| 497 node.receiver = visitExpression(node.receiver); |
| 498 } else { |
| 499 // Impure expressions cannot be propagated across the method lookup, |
| 500 // because it throws when the receiver is null. |
| 501 inEmptyEnvironment(() { |
| 502 _rewriteList(node.arguments); |
| 503 }); |
| 504 node.receiver = visitExpression(node.receiver); |
| 505 } |
| 506 return node; |
| 507 } |
| 508 |
494 Expression visitInvokeMethodDirectly(InvokeMethodDirectly node) { | 509 Expression visitInvokeMethodDirectly(InvokeMethodDirectly node) { |
495 _rewriteList(node.arguments); | 510 _rewriteList(node.arguments); |
496 node.receiver = visitExpression(node.receiver); | 511 node.receiver = visitExpression(node.receiver); |
497 return node; | 512 return node; |
498 } | 513 } |
499 | 514 |
500 Expression visitInvokeConstructor(InvokeConstructor node) { | 515 Expression visitInvokeConstructor(InvokeConstructor node) { |
501 _rewriteList(node.arguments); | 516 _rewriteList(node.arguments); |
502 return node; | 517 return node; |
503 } | 518 } |
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1202 VariableUseVisitor(this.callback); | 1217 VariableUseVisitor(this.callback); |
1203 | 1218 |
1204 visitVariableUse(VariableUse use) => callback(use); | 1219 visitVariableUse(VariableUse use) => callback(use); |
1205 | 1220 |
1206 visitInnerFunction(FunctionDefinition node) {} | 1221 visitInnerFunction(FunctionDefinition node) {} |
1207 | 1222 |
1208 static void visit(Expression node, VariableUseCallback callback) { | 1223 static void visit(Expression node, VariableUseCallback callback) { |
1209 new VariableUseVisitor(callback).visitExpression(node); | 1224 new VariableUseVisitor(callback).visitExpression(node); |
1210 } | 1225 } |
1211 } | 1226 } |
OLD | NEW |