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 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 namedParameters, | 955 namedParameters, |
956 namedParameterTypes); | 956 namedParameterTypes); |
957 } | 957 } |
958 | 958 |
959 void resolveMetadataAnnotation(PartialMetadataAnnotation annotation) { | 959 void resolveMetadataAnnotation(PartialMetadataAnnotation annotation) { |
960 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() { | 960 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() { |
961 assert(annotation.resolutionState == STATE_NOT_STARTED); | 961 assert(annotation.resolutionState == STATE_NOT_STARTED); |
962 annotation.resolutionState = STATE_STARTED; | 962 annotation.resolutionState = STATE_STARTED; |
963 | 963 |
964 Node node = annotation.parseNode(compiler); | 964 Node node = annotation.parseNode(compiler); |
965 ResolverVisitor visitor = | 965 Element annotatedElement = annotation.annotatedElement; |
966 visitorFor(annotation.annotatedElement.enclosingElement); | 966 Element context = annotatedElement.enclosingElement; |
| 967 if (context == null) { |
| 968 context = annotatedElement; |
| 969 } |
| 970 ResolverVisitor visitor = visitorFor(context); |
967 node.accept(visitor); | 971 node.accept(visitor); |
968 annotation.value = compiler.metadataHandler.compileNodeWithDefinitions( | 972 annotation.value = compiler.metadataHandler.compileNodeWithDefinitions( |
969 node, visitor.mapping, isConst: true); | 973 node, visitor.mapping, isConst: true); |
970 | 974 |
971 annotation.resolutionState = STATE_DONE; | 975 annotation.resolutionState = STATE_DONE; |
972 })); | 976 })); |
973 } | 977 } |
974 | 978 |
975 error(Node node, MessageKind kind, [arguments = const {}]) { | 979 error(Node node, MessageKind kind, [arguments = const {}]) { |
976 ResolutionError message = new ResolutionError(kind, arguments); | 980 ResolutionError message = new ResolutionError(kind, arguments); |
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3997 return e; | 4001 return e; |
3998 } | 4002 } |
3999 | 4003 |
4000 /// Assumed to be called by [resolveRedirectingFactory]. | 4004 /// Assumed to be called by [resolveRedirectingFactory]. |
4001 Element visitReturn(Return node) { | 4005 Element visitReturn(Return node) { |
4002 Node expression = node.expression; | 4006 Node expression = node.expression; |
4003 return finishConstructorReference(visit(expression), | 4007 return finishConstructorReference(visit(expression), |
4004 expression, expression); | 4008 expression, expression); |
4005 } | 4009 } |
4006 } | 4010 } |
OLD | NEW |