| 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 elements.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'elements.dart'; | 7 import 'elements.dart'; |
| 8 import '../../compiler.dart' as api; | 8 import '../../compiler.dart' as api; |
| 9 import '../tree/tree.dart'; | 9 import '../tree/tree.dart'; |
| 10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
| (...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1133 this.cachedNode) | 1133 this.cachedNode) |
| 1134 : this.variables = variables, | 1134 : this.variables = variables, |
| 1135 super(name, kind, variables.enclosingElement); | 1135 super(name, kind, variables.enclosingElement); |
| 1136 | 1136 |
| 1137 VariableElementX.synthetic(String name, | 1137 VariableElementX.synthetic(String name, |
| 1138 ElementKind kind, | 1138 ElementKind kind, |
| 1139 Element enclosing) : | 1139 Element enclosing) : |
| 1140 variables = null, | 1140 variables = null, |
| 1141 super(name, kind, enclosing); | 1141 super(name, kind, enclosing); |
| 1142 | 1142 |
| 1143 void addMetadata(MetadataAnnotation metadata) { |
| 1144 variables.addMetadata(metadata); |
| 1145 } |
| 1146 |
| 1147 Link<MetadataAnnotation> get metadata => variables.metadata; |
| 1148 |
| 1143 Node parseNode(DiagnosticListener listener) { | 1149 Node parseNode(DiagnosticListener listener) { |
| 1144 if (cachedNode != null) return cachedNode; | 1150 if (cachedNode != null) return cachedNode; |
| 1145 VariableDefinitions definitions = variables.parseNode(listener); | 1151 VariableDefinitions definitions = variables.parseNode(listener); |
| 1146 for (Link<Node> link = definitions.definitions.nodes; | 1152 for (Link<Node> link = definitions.definitions.nodes; |
| 1147 !link.isEmpty; link = link.tail) { | 1153 !link.isEmpty; link = link.tail) { |
| 1148 Expression initializedIdentifier = link.head; | 1154 Expression initializedIdentifier = link.head; |
| 1149 Identifier identifier = initializedIdentifier.asIdentifier(); | 1155 Identifier identifier = initializedIdentifier.asIdentifier(); |
| 1150 if (identifier == null) { | 1156 if (identifier == null) { |
| 1151 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); | 1157 identifier = initializedIdentifier.asSendSet().selector.asIdentifier(); |
| 1152 } | 1158 } |
| (...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 * there is an at-sign, '@'. The [value] of each of these instances | 2460 * there is an at-sign, '@'. The [value] of each of these instances |
| 2455 * are the same compile-time constant, [: const Data() :]. | 2461 * are the same compile-time constant, [: const Data() :]. |
| 2456 * | 2462 * |
| 2457 * The mirror system does not have a concept matching this class. | 2463 * The mirror system does not have a concept matching this class. |
| 2458 */ | 2464 */ |
| 2459 abstract class MetadataAnnotationX implements MetadataAnnotation { | 2465 abstract class MetadataAnnotationX implements MetadataAnnotation { |
| 2460 /** | 2466 /** |
| 2461 * The compile-time constant which this annotation resolves to. | 2467 * The compile-time constant which this annotation resolves to. |
| 2462 * In the mirror system, this would be an object mirror. | 2468 * In the mirror system, this would be an object mirror. |
| 2463 */ | 2469 */ |
| 2464 Constant get value; | 2470 Constant value; |
| 2465 Element annotatedElement; | 2471 Element annotatedElement; |
| 2466 int resolutionState; | 2472 int resolutionState; |
| 2467 | 2473 |
| 2468 /** | 2474 /** |
| 2469 * The beginning token of this annotation, or [:null:] if it is synthetic. | 2475 * The beginning token of this annotation, or [:null:] if it is synthetic. |
| 2470 */ | 2476 */ |
| 2471 Token get beginToken; | 2477 Token get beginToken; |
| 2472 | 2478 |
| 2473 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); | 2479 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); |
| 2474 | 2480 |
| 2475 MetadataAnnotation ensureResolved(Compiler compiler) { | 2481 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2476 if (resolutionState == STATE_NOT_STARTED) { | 2482 if (resolutionState == STATE_NOT_STARTED) { |
| 2477 compiler.resolver.resolveMetadataAnnotation(this); | 2483 compiler.resolver.resolveMetadataAnnotation(this); |
| 2478 } | 2484 } |
| 2479 return this; | 2485 return this; |
| 2480 } | 2486 } |
| 2481 | 2487 |
| 2488 Node parseNode(DiagnosticListener listener); |
| 2489 |
| 2482 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2490 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2483 } | 2491 } |
| 2492 |
| 2493 /// Metadata annotation on a parameter. |
| 2494 class ParameterMetadataAnnotation extends MetadataAnnotationX { |
| 2495 final Metadata metadata; |
| 2496 |
| 2497 ParameterMetadataAnnotation(Metadata this.metadata); |
| 2498 |
| 2499 Node parseNode(DiagnosticListener listener) => metadata.expression; |
| 2500 |
| 2501 Token get beginToken => metadata.getBeginToken(); |
| 2502 |
| 2503 Token get endToken => metadata.getEndToken(); |
| 2504 } |
| OLD | NEW |