| 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 '../cps_ir/const_expression.dart'; |
| 8 import '../helpers/helpers.dart'; // Included for debug helpers. | 9 import '../helpers/helpers.dart'; // Included for debug helpers. |
| 9 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| 10 import '../util/util.dart'; | 11 import '../util/util.dart'; |
| 11 import '../resolution/resolution.dart'; | 12 import '../resolution/resolution.dart'; |
| 12 import '../resolution/class_members.dart' show ClassMemberMixin; | 13 import '../resolution/class_members.dart' show ClassMemberMixin; |
| 13 | 14 |
| 14 import '../dart2jslib.dart' show invariant, | 15 import '../dart2jslib.dart' show invariant, |
| 15 InterfaceType, | 16 InterfaceType, |
| 16 DartType, | 17 DartType, |
| 17 TypeVariableType, | 18 TypeVariableType, |
| (...skipping 2585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2603 * const data = const Data(); | 2604 * const data = const Data(); |
| 2604 * | 2605 * |
| 2605 * @data | 2606 * @data |
| 2606 * class Foo {} | 2607 * class Foo {} |
| 2607 * | 2608 * |
| 2608 * @data @data | 2609 * @data @data |
| 2609 * class Bar {} | 2610 * class Bar {} |
| 2610 * | 2611 * |
| 2611 * In this example, there are three instances of [MetadataAnnotation] | 2612 * In this example, there are three instances of [MetadataAnnotation] |
| 2612 * and they correspond each to a location in the source code where | 2613 * and they correspond each to a location in the source code where |
| 2613 * there is an at-sign, '@'. The [value] of each of these instances | 2614 * there is an at-sign, '@'. The [constant] of each of these instances |
| 2614 * are the same compile-time constant, [: const Data() :]. | 2615 * are the same compile-time constant, [: const Data() :]. |
| 2615 * | 2616 * |
| 2616 * The mirror system does not have a concept matching this class. | 2617 * The mirror system does not have a concept matching this class. |
| 2617 */ | 2618 */ |
| 2618 abstract class MetadataAnnotationX implements MetadataAnnotation { | 2619 abstract class MetadataAnnotationX implements MetadataAnnotation { |
| 2619 /** | 2620 /** |
| 2620 * The compile-time constant which this annotation resolves to. | 2621 * The compile-time constant which this annotation resolves to. |
| 2621 * In the mirror system, this would be an object mirror. | 2622 * In the mirror system, this would be an object mirror. |
| 2622 */ | 2623 */ |
| 2623 Constant value; | 2624 ConstExp constant; |
| 2624 Element annotatedElement; | 2625 Element annotatedElement; |
| 2625 int resolutionState; | 2626 int resolutionState; |
| 2626 | 2627 |
| 2627 /** | 2628 /** |
| 2628 * The beginning token of this annotation, or [:null:] if it is synthetic. | 2629 * The beginning token of this annotation, or [:null:] if it is synthetic. |
| 2629 */ | 2630 */ |
| 2630 Token get beginToken; | 2631 Token get beginToken; |
| 2631 | 2632 |
| 2632 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); | 2633 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); |
| 2633 | 2634 |
| 2634 MetadataAnnotation ensureResolved(Compiler compiler) { | 2635 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2636 if (annotatedElement.isClass || annotatedElement.isTypedef) { |
| 2637 TypeDeclarationElement typeDeclaration = annotatedElement; |
| 2638 typeDeclaration.ensureResolved(compiler); |
| 2639 } |
| 2635 if (resolutionState == STATE_NOT_STARTED) { | 2640 if (resolutionState == STATE_NOT_STARTED) { |
| 2636 compiler.resolver.resolveMetadataAnnotation(this); | 2641 compiler.resolver.resolveMetadataAnnotation(this); |
| 2637 } | 2642 } |
| 2638 return this; | 2643 return this; |
| 2639 } | 2644 } |
| 2640 | 2645 |
| 2641 Node parseNode(DiagnosticListener listener); | 2646 Node parseNode(DiagnosticListener listener); |
| 2642 | 2647 |
| 2643 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2648 String toString() => 'MetadataAnnotation($constant, $resolutionState)'; |
| 2644 } | 2649 } |
| 2645 | 2650 |
| 2646 /// Metadata annotation on a parameter. | 2651 /// Metadata annotation on a parameter. |
| 2647 class ParameterMetadataAnnotation extends MetadataAnnotationX { | 2652 class ParameterMetadataAnnotation extends MetadataAnnotationX { |
| 2648 final Metadata metadata; | 2653 final Metadata metadata; |
| 2649 | 2654 |
| 2650 ParameterMetadataAnnotation(Metadata this.metadata); | 2655 ParameterMetadataAnnotation(Metadata this.metadata); |
| 2651 | 2656 |
| 2652 Node parseNode(DiagnosticListener listener) => metadata.expression; | 2657 Node parseNode(DiagnosticListener listener) => metadata.expression; |
| 2653 | 2658 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2701 AstElement get definingElement; | 2706 AstElement get definingElement; |
| 2702 | 2707 |
| 2703 bool get hasResolvedAst => definingElement.hasTreeElements; | 2708 bool get hasResolvedAst => definingElement.hasTreeElements; |
| 2704 | 2709 |
| 2705 ResolvedAst get resolvedAst { | 2710 ResolvedAst get resolvedAst { |
| 2706 return new ResolvedAst(declaration, | 2711 return new ResolvedAst(declaration, |
| 2707 definingElement.node, definingElement.treeElements); | 2712 definingElement.node, definingElement.treeElements); |
| 2708 } | 2713 } |
| 2709 | 2714 |
| 2710 } | 2715 } |
| OLD | NEW |