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

Unified Diff: pkg/compiler/lib/src/serialization/modelz.dart

Issue 2060183002: Serialize metadata (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 4 years, 6 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 | « pkg/compiler/lib/src/serialization/keys.dart ('k') | pkg/compiler/lib/src/types/constants.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/serialization/modelz.dart
diff --git a/pkg/compiler/lib/src/serialization/modelz.dart b/pkg/compiler/lib/src/serialization/modelz.dart
index a03ef2f2b12f68251d0365defecf0bac6df40494..c909f9acf56e4b26405ae9635102f41815c643d6 100644
--- a/pkg/compiler/lib/src/serialization/modelz.dart
+++ b/pkg/compiler/lib/src/serialization/modelz.dart
@@ -112,7 +112,6 @@ abstract class ElementZ extends Element with ElementCommon {
@override
bool get isTopLevel => false;
- // TODO(johnniwinther): Support metadata.
@override
Iterable<MetadataAnnotation> get metadata => const <MetadataAnnotation>[];
@@ -122,6 +121,7 @@ abstract class ElementZ extends Element with ElementCommon {
abstract class DeserializedElementZ extends ElementZ {
ObjectDecoder _decoder;
+ List<MetadataAnnotation> _metadata;
DeserializedElementZ(this._decoder);
@@ -147,6 +147,27 @@ abstract class DeserializedElementZ extends ElementZ {
}
return new SourceSpan(uri, offset, offset + length);
}
+
+ @override
+ Iterable<MetadataAnnotation> get metadata {
+ if (_metadata == null) {
+ _metadata = <MetadataAnnotation>[];
+ ListDecoder list = _decoder.getList(Key.METADATA, isOptional: true);
+ if (list != null) {
+ for (int index = 0; index < list.length; index++) {
+ ObjectDecoder object = list.getObject(index);
+ Element element = object.getElement(Key.ELEMENT);
+ Uri uri = object.getUri(Key.URI);
+ int offset = object.getInt(Key.OFFSET);
+ int length = object.getInt(Key.LENGTH);
+ ConstantExpression constant = object.getConstant(Key.CONSTANT);
+ _metadata.add(new MetadataAnnotationZ(
+ element, new SourceSpan(uri, offset, offset + length), constant));
+ }
+ }
+ }
+ return _metadata;
+ }
}
/// Deserializer for a collection of member elements serialized as a map from
@@ -946,6 +967,9 @@ class ClassElementZ extends DeserializedElementZ
bool get isProxy => _decoder.getBool(Key.IS_PROXY);
@override
+ bool get isInjected => _decoder.getBool(Key.IS_INJECTED);
+
+ @override
bool get isUnnamedMixinApplication => false;
@override
@@ -1480,6 +1504,9 @@ abstract class MemberElementMixin
@override
List<FunctionElement> get nestedClosures => <FunctionElement>[];
+
+ @override
+ bool get isInjected => _decoder.getBool(Key.IS_INJECTED);
}
abstract class FieldElementZ extends DeserializedElementZ
@@ -2263,3 +2290,25 @@ class PrefixElementZ extends DeserializedElementZ
return _unsupported('lookupLocalMember');
}
}
+
+class MetadataAnnotationZ implements MetadataAnnotation {
+ final Element annotatedElement;
+ final SourceSpan sourcePosition;
+ final ConstantExpression constant;
+
+ MetadataAnnotationZ(
+ this.annotatedElement, this.sourcePosition, this.constant);
+
+ @override
+ MetadataAnnotation ensureResolved(Resolution resolution) {
+ // Do nothing.
+ }
+
+ @override
+ Node get node => throw new UnsupportedError('${this}.node');
+
+ @override
+ bool get hasNode => false;
+
+ String toString() => 'MetadataAnnotationZ(${constant.toDartText()})';
+}
« no previous file with comments | « pkg/compiler/lib/src/serialization/keys.dart ('k') | pkg/compiler/lib/src/types/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698