Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/elements/modelx.dart

Issue 574683002: Use ConstExp for storing constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Remove ConstExpBuilder. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after
2596 * const data = const Data(); 2597 * const data = const Data();
2597 * 2598 *
2598 * @data 2599 * @data
2599 * class Foo {} 2600 * class Foo {}
2600 * 2601 *
2601 * @data @data 2602 * @data @data
2602 * class Bar {} 2603 * class Bar {}
2603 * 2604 *
2604 * In this example, there are three instances of [MetadataAnnotation] 2605 * In this example, there are three instances of [MetadataAnnotation]
2605 * and they correspond each to a location in the source code where 2606 * and they correspond each to a location in the source code where
2606 * there is an at-sign, '@'. The [value] of each of these instances 2607 * there is an at-sign, '@'. The [constant] of each of these instances
2607 * are the same compile-time constant, [: const Data() :]. 2608 * are the same compile-time constant, [: const Data() :].
2608 * 2609 *
2609 * The mirror system does not have a concept matching this class. 2610 * The mirror system does not have a concept matching this class.
2610 */ 2611 */
2611 abstract class MetadataAnnotationX implements MetadataAnnotation { 2612 abstract class MetadataAnnotationX implements MetadataAnnotation {
2612 /** 2613 /**
2613 * The compile-time constant which this annotation resolves to. 2614 * The compile-time constant which this annotation resolves to.
2614 * In the mirror system, this would be an object mirror. 2615 * In the mirror system, this would be an object mirror.
2615 */ 2616 */
2616 Constant value; 2617 ConstExp constant;
2617 Element annotatedElement; 2618 Element annotatedElement;
2618 int resolutionState; 2619 int resolutionState;
2619 2620
2620 /** 2621 /**
2621 * The beginning token of this annotation, or [:null:] if it is synthetic. 2622 * The beginning token of this annotation, or [:null:] if it is synthetic.
2622 */ 2623 */
2623 Token get beginToken; 2624 Token get beginToken;
2624 2625
2625 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]); 2626 MetadataAnnotationX([this.resolutionState = STATE_NOT_STARTED]);
2626 2627
2627 MetadataAnnotation ensureResolved(Compiler compiler) { 2628 MetadataAnnotation ensureResolved(Compiler compiler) {
2629 if (annotatedElement.isClass || annotatedElement.isTypedef) {
2630 TypeDeclarationElement typeDeclaration = annotatedElement;
2631 typeDeclaration.ensureResolved(compiler);
2632 }
2628 if (resolutionState == STATE_NOT_STARTED) { 2633 if (resolutionState == STATE_NOT_STARTED) {
2629 compiler.resolver.resolveMetadataAnnotation(this); 2634 compiler.resolver.resolveMetadataAnnotation(this);
2630 } 2635 }
2631 return this; 2636 return this;
2632 } 2637 }
2633 2638
2634 Node parseNode(DiagnosticListener listener); 2639 Node parseNode(DiagnosticListener listener);
2635 2640
2636 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 2641 String toString() => 'MetadataAnnotation($constant, $resolutionState)';
2637 } 2642 }
2638 2643
2639 /// Metadata annotation on a parameter. 2644 /// Metadata annotation on a parameter.
2640 class ParameterMetadataAnnotation extends MetadataAnnotationX { 2645 class ParameterMetadataAnnotation extends MetadataAnnotationX {
2641 final Metadata metadata; 2646 final Metadata metadata;
2642 2647
2643 ParameterMetadataAnnotation(Metadata this.metadata); 2648 ParameterMetadataAnnotation(Metadata this.metadata);
2644 2649
2645 Node parseNode(DiagnosticListener listener) => metadata.expression; 2650 Node parseNode(DiagnosticListener listener) => metadata.expression;
2646 2651
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2694 AstElement get definingElement; 2699 AstElement get definingElement;
2695 2700
2696 bool get hasResolvedAst => definingElement.hasTreeElements; 2701 bool get hasResolvedAst => definingElement.hasTreeElements;
2697 2702
2698 ResolvedAst get resolvedAst { 2703 ResolvedAst get resolvedAst {
2699 return new ResolvedAst(declaration, 2704 return new ResolvedAst(declaration,
2700 definingElement.node, definingElement.treeElements); 2705 definingElement.node, definingElement.treeElements);
2701 } 2706 }
2702 2707
2703 } 2708 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698