| 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 '../dart2jslib.dart' hide Selector, TypedSelector; | 7 import '../dart2jslib.dart' hide Selector, TypedSelector; |
| 8 import '../dart_types.dart'; | 8 import '../dart_types.dart'; |
| 9 import '../elements/elements.dart'; | 9 import '../elements/elements.dart'; |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 } | 648 } |
| 649 }); | 649 }); |
| 650 } | 650 } |
| 651 | 651 |
| 652 void updateField(Element element, T type) { | 652 void updateField(Element element, T type) { |
| 653 fieldScope.updateField(element, type); | 653 fieldScope.updateField(element, type); |
| 654 } | 654 } |
| 655 } | 655 } |
| 656 | 656 |
| 657 abstract class InferrerVisitor | 657 abstract class InferrerVisitor |
| 658 <T, E extends MinimalInferrerEngine<T>> extends ResolvedVisitor<T> { | 658 <T, E extends MinimalInferrerEngine<T>> extends NewResolvedVisitor<T> { |
| 659 final Compiler compiler; | 659 final Compiler compiler; |
| 660 final AstElement analyzedElement; | 660 final AstElement analyzedElement; |
| 661 final TypeSystem<T> types; | 661 final TypeSystem<T> types; |
| 662 final E inferrer; | 662 final E inferrer; |
| 663 final Map<JumpTarget, List<LocalsHandler<T>>> breaksFor = | 663 final Map<JumpTarget, List<LocalsHandler<T>>> breaksFor = |
| 664 new Map<JumpTarget, List<LocalsHandler<T>>>(); | 664 new Map<JumpTarget, List<LocalsHandler<T>>>(); |
| 665 final Map<JumpTarget, List<LocalsHandler>> continuesFor = | 665 final Map<JumpTarget, List<LocalsHandler>> continuesFor = |
| 666 new Map<JumpTarget, List<LocalsHandler<T>>>(); | 666 new Map<JumpTarget, List<LocalsHandler<T>>>(); |
| 667 LocalsHandler<T> locals; | 667 LocalsHandler<T> locals; |
| 668 final List<T> cascadeReceiverStack = new List<T>(); | 668 final List<T> cascadeReceiverStack = new List<T>(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 T visitClosureSend(Send node); | 712 T visitClosureSend(Send node); |
| 713 | 713 |
| 714 T visitDynamicSend(Send node); | 714 T visitDynamicSend(Send node); |
| 715 | 715 |
| 716 T visitForIn(ForIn node); | 716 T visitForIn(ForIn node); |
| 717 | 717 |
| 718 T visitReturn(Return node); | 718 T visitReturn(Return node); |
| 719 | 719 |
| 720 T visitFunctionExpression(FunctionExpression node); | 720 T visitFunctionExpression(FunctionExpression node); |
| 721 | 721 |
| 722 T visitAssert(Send node) { | 722 T visitAssertSend(Send node) { |
| 723 if (!compiler.enableUserAssertions) { | 723 if (!compiler.enableUserAssertions) { |
| 724 return types.nullType; | 724 return types.nullType; |
| 725 } | 725 } |
| 726 // TODO(johnniwinther): Don't handle assert like a regular static call since | 726 // TODO(johnniwinther): Don't handle assert like a regular static call since |
| 727 // it break the selector name check. | 727 // it break the selector name check. |
| 728 return visitStaticSend(node); | 728 return visitStaticSend(node); |
| 729 } | 729 } |
| 730 | 730 |
| 731 T visitNode(Node node) { | 731 T visitNode(Node node) { |
| 732 return node.visitChildren(this); | 732 return node.visitChildren(this); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 | 1222 |
| 1223 T visitContinueStatement(ContinueStatement node) { | 1223 T visitContinueStatement(ContinueStatement node) { |
| 1224 JumpTarget target = elements.getTargetOf(node); | 1224 JumpTarget target = elements.getTargetOf(node); |
| 1225 locals.seenBreakOrContinue = true; | 1225 locals.seenBreakOrContinue = true; |
| 1226 // Do a deep-copy of the locals, because the code following the | 1226 // Do a deep-copy of the locals, because the code following the |
| 1227 // continue will change them. | 1227 // continue will change them. |
| 1228 continuesFor[target].add(new LocalsHandler<T>.deepCopyOf(locals)); | 1228 continuesFor[target].add(new LocalsHandler<T>.deepCopyOf(locals)); |
| 1229 return null; | 1229 return null; |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 void internalError(String reason, {Node node}) { | 1232 void internalError(Spannable node, String reason) { |
| 1233 compiler.internalError(node, reason); | 1233 compiler.internalError(node, reason); |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 T visitSwitchStatement(SwitchStatement node) { | 1236 T visitSwitchStatement(SwitchStatement node) { |
| 1237 visit(node.parenthesizedExpression); | 1237 visit(node.parenthesizedExpression); |
| 1238 | 1238 |
| 1239 setupBreaksAndContinues(elements.getTargetDefinition(node)); | 1239 setupBreaksAndContinues(elements.getTargetDefinition(node)); |
| 1240 if (Elements.switchStatementHasContinue(node, elements)) { | 1240 if (Elements.switchStatementHasContinue(node, elements)) { |
| 1241 void forEachLabeledCase(void action(JumpTarget target)) { | 1241 void forEachLabeledCase(void action(JumpTarget target)) { |
| 1242 for (SwitchCase switchCase in node.cases) { | 1242 for (SwitchCase switchCase in node.cases) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 return type; | 1301 return type; |
| 1302 } | 1302 } |
| 1303 | 1303 |
| 1304 T visitCascade(Cascade node) { | 1304 T visitCascade(Cascade node) { |
| 1305 // Ignore the result of the cascade send and return the type of the cascade | 1305 // Ignore the result of the cascade send and return the type of the cascade |
| 1306 // receiver. | 1306 // receiver. |
| 1307 visit(node.expression); | 1307 visit(node.expression); |
| 1308 return cascadeReceiverStack.removeLast(); | 1308 return cascadeReceiverStack.removeLast(); |
| 1309 } | 1309 } |
| 1310 } | 1310 } |
| OLD | NEW |