| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 inferrer_visitor; | 5 library inferrer_visitor; |
| 6 | 6 |
| 7 import 'dart:collection' show | 7 import 'dart:collection' show |
| 8 IterableMixin; | 8 IterableMixin; |
| 9 | 9 |
| 10 import '../common.dart'; | 10 import '../common.dart'; |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 } else { | 459 } else { |
| 460 if (captured.containsKey(local)) { | 460 if (captured.containsKey(local)) { |
| 461 inferrer.recordCapturedLocalRead(local); | 461 inferrer.recordCapturedLocalRead(local); |
| 462 } | 462 } |
| 463 return locals[local]; | 463 return locals[local]; |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 | 466 |
| 467 void update(LocalElement local, T type, Node node) { | 467 void update(LocalElement local, T type, Node node) { |
| 468 assert(type != null); | 468 assert(type != null); |
| 469 if (compiler.trustTypeAnnotations || compiler.enableTypeAssertions) { | 469 if (compiler.options.trustTypeAnnotations || |
| 470 compiler.options.enableTypeAssertions) { |
| 470 type = types.narrowType(type, local.type); | 471 type = types.narrowType(type, local.type); |
| 471 } | 472 } |
| 472 updateLocal() { | 473 updateLocal() { |
| 473 T currentType = locals[local]; | 474 T currentType = locals[local]; |
| 474 | 475 |
| 475 SendSet send = node != null ? node.asSendSet() : null; | 476 SendSet send = node != null ? node.asSendSet() : null; |
| 476 if (send != null && send.isIfNullAssignment && currentType != null) { | 477 if (send != null && send.isIfNullAssignment && currentType != null) { |
| 477 // If-null assignments may return either the new or the original value | 478 // If-null assignments may return either the new or the original value |
| 478 // narrowed to non-null. | 479 // narrowed to non-null. |
| 479 type = types.addPhiInput( | 480 type = types.addPhiInput( |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 | 773 |
| 773 @override | 774 @override |
| 774 T apply(Node node, _) => visit(node); | 775 T apply(Node node, _) => visit(node); |
| 775 | 776 |
| 776 T handleSendSet(SendSet node); | 777 T handleSendSet(SendSet node); |
| 777 | 778 |
| 778 T handleDynamicInvoke(Send node); | 779 T handleDynamicInvoke(Send node); |
| 779 | 780 |
| 780 T visitAssert(Assert node) { | 781 T visitAssert(Assert node) { |
| 781 // Avoid pollution from assert statement unless enabled. | 782 // Avoid pollution from assert statement unless enabled. |
| 782 if (compiler.enableUserAssertions) { | 783 if (compiler.options.enableUserAssertions) { |
| 783 super.visitAssert(node); | 784 super.visitAssert(node); |
| 784 } | 785 } |
| 785 return null; | 786 return null; |
| 786 } | 787 } |
| 787 | 788 |
| 788 T visitAsyncForIn(AsyncForIn node); | 789 T visitAsyncForIn(AsyncForIn node); |
| 789 | 790 |
| 790 T visitSyncForIn(SyncForIn node); | 791 T visitSyncForIn(SyncForIn node); |
| 791 | 792 |
| 792 T visitReturn(Return node); | 793 T visitReturn(Return node); |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 return type; | 1553 return type; |
| 1553 } | 1554 } |
| 1554 | 1555 |
| 1555 T visitCascade(Cascade node) { | 1556 T visitCascade(Cascade node) { |
| 1556 // Ignore the result of the cascade send and return the type of the cascade | 1557 // Ignore the result of the cascade send and return the type of the cascade |
| 1557 // receiver. | 1558 // receiver. |
| 1558 visit(node.expression); | 1559 visit(node.expression); |
| 1559 return cascadeReceiverStack.removeLast(); | 1560 return cascadeReceiverStack.removeLast(); |
| 1560 } | 1561 } |
| 1561 } | 1562 } |
| OLD | NEW |