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

Unified Diff: tests/compiler/dart2js/serialization/helper.dart

Issue 1970703002: Store ResolvedAst on AstElement (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 7 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/ssa/builder.dart ('k') | tests/compiler/dart2js/serialization/model_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/serialization/helper.dart
diff --git a/tests/compiler/dart2js/serialization/helper.dart b/tests/compiler/dart2js/serialization/helper.dart
index a2f38ad8f67106af785813e87a5c269c503e83e5..8a4aba5f16698f4b3acbebf02121f37f6222fa2b 100644
--- a/tests/compiler/dart2js/serialization/helper.dart
+++ b/tests/compiler/dart2js/serialization/helper.dart
@@ -230,9 +230,10 @@ class _DeserializerSystem extends DeserializerSystem {
return new Future<LibraryElement>.value(library);
}
+ // TODO(johnniwinther): Remove the need for this method.
@override
bool hasResolvedAst(ExecutableElement element) {
- return _resolvedAstDeserializer.hasResolvedAst(element);
+ return getResolvedAst(element) != null;
}
@override
@@ -275,6 +276,9 @@ class _DeserializerSystem extends DeserializerSystem {
ResolutionImpact resolutionImpact = getResolutionImpact(element);
assert(invariant(element, resolutionImpact != null,
message: 'No impact found for $element (${element.library})'));
+ if (element is ExecutableElement) {
+ getResolvedAst(element);
+ }
return _impactTransformer.transformResolutionImpact(resolutionImpact);
}
@@ -314,8 +318,6 @@ class ResolvedAstDeserializerPlugin extends DeserializerPlugin {
final DeserializerPlugin nativeDataDeserializer;
final Map<Uri, SourceFile> sourceFiles = <Uri, SourceFile>{};
- Map<ExecutableElement, ResolvedAst> _resolvedAstMap =
- <ExecutableElement, ResolvedAst>{};
Map<MemberElement, ObjectDecoder> _decoderMap =
<MemberElement, ObjectDecoder>{};
Map<Uri, Token> beginTokenMap = <Uri, Token>{};
@@ -324,24 +326,25 @@ class ResolvedAstDeserializerPlugin extends DeserializerPlugin {
this.parsingContext, this.nativeDataDeserializer);
bool hasResolvedAst(ExecutableElement element) {
- return _resolvedAstMap.containsKey(element) ||
- _decoderMap.containsKey(element.memberContext);
+ return getResolvedAst(element) != null;
}
ResolvedAst getResolvedAst(ExecutableElement element) {
- ResolvedAst resolvedAst = _resolvedAstMap[element];
- if (resolvedAst == null) {
- ObjectDecoder decoder = _decoderMap[element.memberContext];
- if (decoder != null) {
- ResolvedAstDeserializer.deserialize(
- element.memberContext, decoder, parsingContext, findToken,
- nativeDataDeserializer,
- _resolvedAstMap);
- _decoderMap.remove(element);
- resolvedAst = _resolvedAstMap[element];
- }
+ if (element.hasResolvedAst) {
+ return element.resolvedAst;
+ }
+
+ ObjectDecoder decoder = _decoderMap[element.memberContext];
+ if (decoder != null) {
+ ResolvedAstDeserializer.deserialize(
+ element.memberContext, decoder, parsingContext, findToken,
+ nativeDataDeserializer);
+ _decoderMap.remove(element);
+ assert(invariant(element, element.hasResolvedAst,
+ message: "ResolvedAst not computed for $element."));
+ return element.resolvedAst;
}
- return resolvedAst;
+ return null;
}
Token findToken(Uri uri, int offset) {
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | tests/compiler/dart2js/serialization/model_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698