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

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

Issue 10879006: Create an outline of metadata API in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
« no previous file with comments | « dart/lib/compiler/implementation/compiler.dart ('k') | dart/lib/compiler/implementation/patch_parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2e5df0d36118a677c00062441ec2466bd71982b2..2cfa90d06652a110c01bd578db777c881f3c13b1 100644
--- a/dart/lib/compiler/implementation/elements/elements.dart
+++ b/dart/lib/compiler/implementation/elements/elements.dart
@@ -106,7 +106,7 @@ class Element implements Hashable {
final SourceString name;
final ElementKind kind;
final Element enclosingElement;
- Link<Node> metadata = const EmptyLink<Node>();
+ Link<MetadataAnnotation> metadata = const EmptyLink<MetadataAnnotation>();
Element(this.name, this.kind, this.enclosingElement) {
assert(getLibrary() !== null);
@@ -122,8 +122,8 @@ class Element implements Hashable {
compiler.internalError("$this.computeType.", token: position());
}
- void addMetadata(Node node) {
- metadata = metadata.prepend(node);
+ void addMetadata(MetadataAnnotation annotation) {
+ metadata = metadata.prepend(annotation);
}
bool isFunction() => kind === ElementKind.FUNCTION;
@@ -322,7 +322,7 @@ class ErroneousElement extends Element {
SourceString get name => unsupported();
ElementKind get kind => unsupported();
- Link<Node> get metadata => unsupported();
+ Link<MetadataAnnotation> get metadata => unsupported();
}
class ErroneousFunctionElement extends ErroneousElement
@@ -1566,3 +1566,39 @@ class TypeVariableElement extends Element {
return result;
}
}
+
+/**
+ * A single metadata annotation.
+ *
+ * For example, consider:
+ *
+ * [:
+ * class Data {
+ * const Data();
+ * }
+ *
+ * const data = const Data();
+ *
+ * @data
+ * class Foo {}
+ *
+ * @data @data
+ * class Bar {}
+ * :]
+ *
+ * In this example, there are three instances of [MetadataAnnotation]
+ * and they correspond each to a location in the source code where
+ * there is an at-sign, '@'. The [value] of each of these instances
+ * are the same compile-time constant, [: const Data() :].
+ *
+ * The mirror system does not have a concept matching this class.
+ */
+class MetadataAnnotation {
+ /**
+ * The compile-time constant which this annotation resolves to.
+ * In the mirror system, this would be an object mirror.
+ */
+ abstract Constant get value();
+
+ // TODO(ahe): Add more functionality as needed.
+}
« no previous file with comments | « dart/lib/compiler/implementation/compiler.dart ('k') | dart/lib/compiler/implementation/patch_parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698