OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of resolution; | 5 part of resolution; |
6 | 6 |
7 abstract class TreeElements { | 7 abstract class TreeElements { |
8 Element get currentElement; | 8 Element get currentElement; |
9 Set<Node> get superUses; | 9 Set<Node> get superUses; |
10 | 10 |
(...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2720 ElementKind.VARIABLE); | 2720 ElementKind.VARIABLE); |
2721 // Ensure that we set the type of the [VariableListElement] since it depends | 2721 // Ensure that we set the type of the [VariableListElement] since it depends |
2722 // on the current scope. If the current scope is a [MethodScope] or | 2722 // on the current scope. If the current scope is a [MethodScope] or |
2723 // [BlockScope] it will not be available for the | 2723 // [BlockScope] it will not be available for the |
2724 // [VariableListElement.computeType] method. | 2724 // [VariableListElement.computeType] method. |
2725 if (node.type != null) { | 2725 if (node.type != null) { |
2726 visitor.variables.type = resolveTypeAnnotation(node.type); | 2726 visitor.variables.type = resolveTypeAnnotation(node.type); |
2727 } else { | 2727 } else { |
2728 visitor.variables.type = compiler.types.dynamicType; | 2728 visitor.variables.type = compiler.types.dynamicType; |
2729 } | 2729 } |
| 2730 |
| 2731 Modifiers modifiers = node.modifiers; |
| 2732 void reportExtraModifier(String modifier) { |
| 2733 Node modifierNode; |
| 2734 for (var nodes = modifiers.nodes; !nodes.isEmpty; nodes = nodes.tail) { |
| 2735 if (modifier == nodes.head.asIdentifier().source.stringValue) { |
| 2736 modifierNode = nodes.head; |
| 2737 break; |
| 2738 } |
| 2739 } |
| 2740 assert(modifierNode != null); |
| 2741 compiler.reportError(modifierNode, MessageKind.EXTRANEOUS_MODIFIER, |
| 2742 {'modifier': modifier}); |
| 2743 } |
| 2744 if (modifiers.isFinal() && (modifiers.isConst() || modifiers.isVar())) { |
| 2745 reportExtraModifier('final'); |
| 2746 } |
| 2747 if (modifiers.isVar() && (modifiers.isConst() || node.type != null)) { |
| 2748 reportExtraModifier('var'); |
| 2749 } |
| 2750 |
2730 visitor.visit(node.definitions); | 2751 visitor.visit(node.definitions); |
2731 } | 2752 } |
2732 | 2753 |
2733 visitWhile(While node) { | 2754 visitWhile(While node) { |
2734 visit(node.condition); | 2755 visit(node.condition); |
2735 visitLoopBodyIn(node, node.body, new BlockScope(scope)); | 2756 visitLoopBodyIn(node, node.body, new BlockScope(scope)); |
2736 } | 2757 } |
2737 | 2758 |
2738 visitParenthesizedExpression(ParenthesizedExpression node) { | 2759 visitParenthesizedExpression(ParenthesizedExpression node) { |
2739 bool oldSendIsMemberAccess = sendIsMemberAccess; | 2760 bool oldSendIsMemberAccess = sendIsMemberAccess; |
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4346 return e; | 4367 return e; |
4347 } | 4368 } |
4348 | 4369 |
4349 /// Assumed to be called by [resolveRedirectingFactory]. | 4370 /// Assumed to be called by [resolveRedirectingFactory]. |
4350 Element visitReturn(Return node) { | 4371 Element visitReturn(Return node) { |
4351 Node expression = node.expression; | 4372 Node expression = node.expression; |
4352 return finishConstructorReference(visit(expression), | 4373 return finishConstructorReference(visit(expression), |
4353 expression, expression); | 4374 expression, expression); |
4354 } | 4375 } |
4355 } | 4376 } |
OLD | NEW |