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

Unified Diff: dart/lib/compiler/implementation/elements/elements.dart

Issue 10870010: Evaluate compile-time constants of metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased and use const instead of final Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: dart/lib/compiler/implementation/elements/elements.dart
diff --git a/dart/lib/compiler/implementation/elements/elements.dart b/dart/lib/compiler/implementation/elements/elements.dart
index 8550b5de3723582e13e0d11a71e1d83a045b3e66..c57803325668618afaaaec7aa372b20664650280 100644
--- a/dart/lib/compiler/implementation/elements/elements.dart
+++ b/dart/lib/compiler/implementation/elements/elements.dart
@@ -11,6 +11,10 @@
#import('../leg.dart'); // TODO(karlklose): we only need type.
#import('../util/util.dart');
+const int STATE_NOT_STARTED = 0;
+const int STATE_STARTED = 1;
+const int STATE_DONE = 2;
+
class ElementCategory {
/**
* Represents things that we don't expect to find when looking in a
@@ -123,6 +127,8 @@ class Element implements Hashable {
}
void addMetadata(MetadataAnnotation annotation) {
+ assert(annotation.annotatedElement === null);
+ annotation.annotatedElement = this;
metadata = metadata.prepend(annotation);
}
@@ -1081,10 +1087,6 @@ abstract class TypeDeclarationElement implements Element {
class ClassElement extends ScopeContainerElement
implements TypeDeclarationElement {
- static final int STATE_NOT_STARTED = 0;
- static final int STATE_STARTED = 1;
- static final int STATE_DONE = 2;
-
final int id;
InterfaceType type;
Type supertype;
@@ -1613,6 +1615,19 @@ class MetadataAnnotation {
* In the mirror system, this would be an object mirror.
*/
abstract Constant get value();
+ Element annotatedElement;
+ int resolutionState;
+
+ MetadataAnnotation([this.resolutionState = STATE_NOT_STARTED]);
+
+ abstract Node parseNode(DiagnosticListener listener);
+
+ MetadataAnnotation ensureResolved(Compiler compiler) {
+ if (resolutionState == STATE_NOT_STARTED) {
+ compiler.resolver.resolveMetadataAnnotation(this);
+ }
+ return this;
+ }
- // TODO(ahe): Add more functionality as needed.
+ String toString() => 'MetadataAnnotation($value, $resolutionState)';
}

Powered by Google App Engine
This is Rietveld 408576698