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

Side by Side Diff: tests/compiler/dart2js/serialization/helper.dart

Issue 2088233003: Serialize erroneous element and more (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. 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 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:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import 'package:compiler/src/commandline_options.dart'; 10 import 'package:compiler/src/commandline_options.dart';
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 print('serialize dart:core'); 121 print('serialize dart:core');
122 print('------------------------------------------------------------------'); 122 print('------------------------------------------------------------------');
123 SerializedData serializedData; 123 SerializedData serializedData;
124 if (arguments.loadSerializedData) { 124 if (arguments.loadSerializedData) {
125 File file = new File(arguments.serializedDataFileName); 125 File file = new File(arguments.serializedDataFileName);
126 if (file.existsSync()) { 126 if (file.existsSync()) {
127 print('Loading data from $file'); 127 print('Loading data from $file');
128 serializedData = new SerializedData(uri, file.readAsStringSync()); 128 serializedData = new SerializedData(uri, file.readAsStringSync());
129 } 129 }
130 } else { 130 } else {
131 SerializationResult result = await serialize(Uris.dart_core, uri); 131 SerializationResult result = await serialize(Uris.dart_core, dataUri: uri);
132 serializedData = result.serializedData; 132 serializedData = result.serializedData;
133 } 133 }
134 if (arguments.saveSerializedData) { 134 if (arguments.saveSerializedData) {
135 File file = new File(arguments.serializedDataFileName); 135 File file = new File(arguments.serializedDataFileName);
136 print('Saving data to $file'); 136 print('Saving data to $file');
137 file.writeAsStringSync(serializedData.data); 137 file.writeAsStringSync(serializedData.data);
138 } 138 }
139 return serializedData; 139 return serializedData;
140 } 140 }
141 141
142 class SerializationResult { 142 class SerializationResult {
143 final Compiler compiler; 143 final Compiler compiler;
144 final SerializedData serializedData; 144 final SerializedData serializedData;
145 145
146 SerializationResult(this.compiler, this.serializedData); 146 SerializationResult(this.compiler, this.serializedData);
147 } 147 }
148 148
149 Future<SerializationResult> serialize(Uri entryPoint, [Uri dataUri]) async { 149 Future<SerializationResult> serialize(Uri entryPoint,
150 {Map<String, String> memorySourceFiles: const <String, String>{},
151 List<Uri> resolutionInputs: const <Uri>[],
152 Uri dataUri}) async {
150 if (dataUri == null) { 153 if (dataUri == null) {
151 dataUri = Uri.parse('memory:${DEFAULT_DATA_FILE_NAME}'); 154 dataUri = Uri.parse('memory:${DEFAULT_DATA_FILE_NAME}');
152 } 155 }
153 Compiler compiler = compilerFor(options: [Flags.analyzeAll]); 156 Compiler compiler = compilerFor(
157 options: [Flags.analyzeAll],
158 memorySourceFiles: memorySourceFiles,
159 resolutionInputs: resolutionInputs);
154 compiler.serialization.supportSerialization = true; 160 compiler.serialization.supportSerialization = true;
155 await compiler.run(entryPoint); 161 await compiler.run(entryPoint);
156 BufferedEventSink sink = new BufferedEventSink(); 162 BufferedEventSink sink = new BufferedEventSink();
157 compiler.serialization.serializeToSink( 163 compiler.serialization.serializeToSink(
158 sink, compiler.libraryLoader.libraries); 164 sink, compiler.libraryLoader.libraries);
159 SerializedData serializedData = new SerializedData(dataUri, sink.text); 165 SerializedData serializedData = new SerializedData(dataUri, sink.text);
160 return new SerializationResult(compiler, serializedData); 166 return new SerializationResult(compiler, serializedData);
161 } 167 }
162 168
163 class SerializedData { 169 class SerializedData {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 await compiler.run(null); 233 await compiler.run(null);
228 List<LibraryElement> libraries = <LibraryElement>[]; 234 List<LibraryElement> libraries = <LibraryElement>[];
229 for (Uri uri in uriList) { 235 for (Uri uri in uriList) {
230 libraries.add(compiler.libraryLoader.lookupLibrary(uri)); 236 libraries.add(compiler.libraryLoader.lookupLibrary(uri));
231 } 237 }
232 SerializedData additionalSerializedData = 238 SerializedData additionalSerializedData =
233 new SerializedData(Uri.parse('memory:additional.data'), 239 new SerializedData(Uri.parse('memory:additional.data'),
234 extractSerializedData(compiler, libraries)); 240 extractSerializedData(compiler, libraries));
235 return <SerializedData>[serializedData, additionalSerializedData]; 241 return <SerializedData>[serializedData, additionalSerializedData];
236 } 242 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/serialization/system.dart ('k') | tests/compiler/dart2js/serialization/reserialization_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698