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

Side by Side Diff: tests/compiler/dart2js/serialization_helper.dart

Issue 1901683002: Support deserialization of ResolutionImpact for members of unnamed mixin applications (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 dart2js.serialization_helper; 5 library dart2js.serialization_helper;
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 import 'dart:async'; 8 import 'dart:async';
9 import 'package:async_helper/async_helper.dart'; 9 import 'package:async_helper/async_helper.dart';
10 import 'package:expect/expect.dart'; 10 import 'package:expect/expect.dart';
(...skipping 10 matching lines...) Expand all
21 import 'package:compiler/src/scanner/scanner.dart'; 21 import 'package:compiler/src/scanner/scanner.dart';
22 import 'package:compiler/src/serialization/element_serialization.dart'; 22 import 'package:compiler/src/serialization/element_serialization.dart';
23 import 'package:compiler/src/serialization/impact_serialization.dart'; 23 import 'package:compiler/src/serialization/impact_serialization.dart';
24 import 'package:compiler/src/serialization/json_serializer.dart'; 24 import 'package:compiler/src/serialization/json_serializer.dart';
25 import 'package:compiler/src/serialization/resolved_ast_serialization.dart'; 25 import 'package:compiler/src/serialization/resolved_ast_serialization.dart';
26 import 'package:compiler/src/serialization/serialization.dart'; 26 import 'package:compiler/src/serialization/serialization.dart';
27 import 'package:compiler/src/serialization/modelz.dart'; 27 import 'package:compiler/src/serialization/modelz.dart';
28 import 'package:compiler/src/serialization/task.dart'; 28 import 'package:compiler/src/serialization/task.dart';
29 import 'package:compiler/src/tokens/token.dart'; 29 import 'package:compiler/src/tokens/token.dart';
30 import 'package:compiler/src/script.dart'; 30 import 'package:compiler/src/script.dart';
31 import 'package:compiler/src/universe/call_structure.dart';
32 import 'package:compiler/src/universe/use.dart';
31 import 'package:compiler/src/universe/world_impact.dart'; 33 import 'package:compiler/src/universe/world_impact.dart';
32 import 'memory_compiler.dart'; 34 import 'memory_compiler.dart';
33 35
34 class Arguments { 36 class Arguments {
35 final String filename; 37 final String filename;
36 final bool loadSerializedData; 38 final bool loadSerializedData;
37 final bool saveSerializedData; 39 final bool saveSerializedData;
38 final String serializedDataFileName; 40 final String serializedDataFileName;
39 final bool verbose; 41 final bool verbose;
40 42
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 class ResolutionImpactSerializer extends SerializerPlugin { 141 class ResolutionImpactSerializer extends SerializerPlugin {
140 final Resolution resolution; 142 final Resolution resolution;
141 143
142 ResolutionImpactSerializer(this.resolution); 144 ResolutionImpactSerializer(this.resolution);
143 145
144 @override 146 @override
145 void onElement(Element element, ObjectEncoder createEncoder(String tag)) { 147 void onElement(Element element, ObjectEncoder createEncoder(String tag)) {
146 if (resolution.hasBeenResolved(element)) { 148 if (resolution.hasBeenResolved(element)) {
147 ResolutionImpact impact = resolution.getResolutionImpact(element); 149 ResolutionImpact impact = resolution.getResolutionImpact(element);
148 ObjectEncoder encoder = createEncoder(WORLD_IMPACT_TAG); 150 ObjectEncoder encoder = createEncoder(WORLD_IMPACT_TAG);
149 new ImpactSerializer(encoder).serialize(impact); 151 new ImpactSerializer(element, encoder).serialize(impact);
150 } 152 }
151 } 153 }
152 } 154 }
153 155
154 class ResolutionImpactDeserializer extends DeserializerPlugin { 156 class ResolutionImpactDeserializer extends DeserializerPlugin {
155 Map<Element, ResolutionImpact> impactMap = <Element, ResolutionImpact>{}; 157 Map<Element, ResolutionImpact> impactMap = <Element, ResolutionImpact>{};
156 158
157 @override 159 @override
158 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { 160 void onElement(Element element, ObjectDecoder getDecoder(String tag)) {
159 ObjectDecoder decoder = getDecoder(WORLD_IMPACT_TAG); 161 ObjectDecoder decoder = getDecoder(WORLD_IMPACT_TAG);
160 if (decoder != null) { 162 if (decoder != null) {
161 impactMap[element] = ImpactDeserializer.deserializeImpact(decoder); 163 impactMap[element] =
164 ImpactDeserializer.deserializeImpact(element, decoder);
162 } 165 }
163 } 166 }
164 } 167 }
165 168
166 class _DeserializerSystem extends DeserializerSystem { 169 class _DeserializerSystem extends DeserializerSystem {
167 final Compiler _compiler; 170 final Compiler _compiler;
168 final Deserializer _deserializer; 171 final Deserializer _deserializer;
169 final List<LibraryElement> deserializedLibraries = <LibraryElement>[]; 172 final List<LibraryElement> deserializedLibraries = <LibraryElement>[];
170 final ResolutionImpactDeserializer _resolutionImpactDeserializer = 173 final ResolutionImpactDeserializer _resolutionImpactDeserializer =
171 new ResolutionImpactDeserializer(); 174 new ResolutionImpactDeserializer();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 221
219 @override 222 @override
220 ResolvedAst getResolvedAst(Element element) { 223 ResolvedAst getResolvedAst(Element element) {
221 if (_resolvedAstDeserializer != null) { 224 if (_resolvedAstDeserializer != null) {
222 return _resolvedAstDeserializer.getResolvedAst(element); 225 return _resolvedAstDeserializer.getResolvedAst(element);
223 } 226 }
224 return null; 227 return null;
225 } 228 }
226 229
227 @override 230 @override
231 bool hasResolutionImpact(Element element) {
232 if (element.isConstructor &&
233 element.enclosingClass.isUnnamedMixinApplication) {
234 return true;
235 }
236 return _resolutionImpactDeserializer.impactMap.containsKey(element);
237 }
238
239 @override
228 ResolutionImpact getResolutionImpact(Element element) { 240 ResolutionImpact getResolutionImpact(Element element) {
241 if (element.isConstructor &&
242 element.enclosingClass.isUnnamedMixinApplication) {
243 ClassElement superclass = element.enclosingClass.superclass;
244 ConstructorElement superclassConstructor =
245 superclass.lookupConstructor(element.name);
246 assert(invariant(element, superclassConstructor != null,
247 message: "Superclass constructor '${element.name}' called from "
248 "${element} not found in ${superclass}."));
249 // TODO(johnniwinther): Compute callStructure. Currently not used.
250 CallStructure callStructure;
251 return _resolutionImpactDeserializer.impactMap.putIfAbsent(element, () {
252 return new DeserializedResolutionImpact(
253 staticUses: <StaticUse>[new StaticUse.superConstructorInvoke(
254 superclassConstructor, callStructure)]);
255 });
256 }
229 return _resolutionImpactDeserializer.impactMap[element]; 257 return _resolutionImpactDeserializer.impactMap[element];
230 } 258 }
231 259
232 @override 260 @override
233 WorldImpact computeWorldImpact(Element element) { 261 WorldImpact computeWorldImpact(Element element) {
234 ResolutionImpact resolutionImpact = getResolutionImpact(element); 262 ResolutionImpact resolutionImpact = getResolutionImpact(element);
235 assert(invariant(element, resolutionImpact != null, 263 assert(invariant(element, resolutionImpact != null,
236 message: 'No impact found for $element (${element.library})')); 264 message: 'No impact found for $element (${element.library})'));
237 return _impactTransformer.transformResolutionImpact(resolutionImpact); 265 return _impactTransformer.transformResolutionImpact(resolutionImpact);
238 } 266 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 335
308 @override 336 @override
309 void onElement(Element element, ObjectDecoder getDecoder(String tag)) { 337 void onElement(Element element, ObjectDecoder getDecoder(String tag)) {
310 ObjectDecoder decoder = getDecoder(RESOLVED_AST_TAG); 338 ObjectDecoder decoder = getDecoder(RESOLVED_AST_TAG);
311 if (decoder != null) { 339 if (decoder != null) {
312 _decoderMap[element] = decoder; 340 _decoderMap[element] = decoder;
313 } 341 }
314 } 342 }
315 } 343 }
316 344
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/task.dart ('k') | tests/compiler/dart2js/serialization_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698