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

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

Issue 2004833003: Support multiple resolution inputs from command line. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix and check library separation 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 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 int first = start ?? 0; 74 int first = start ?? 0;
75 int last = end ?? tests.length - 1; 75 int last = end ?? tests.length - 1;
76 for (int index = first; index <= last; index++) { 76 for (int index = first; index <= last; index++) {
77 Test test = TESTS[index]; 77 Test test = TESTS[index];
78 await f(index, test); 78 await f(index, test);
79 } 79 }
80 } 80 }
81 } 81 }
82 82
83 83
84 Future<String> serializeDartCore( 84 Future<SerializedData> serializeDartCore(
85 {Arguments arguments: const Arguments()}) async { 85 {Arguments arguments: const Arguments()}) async {
86 Uri uri = Uri.parse('memory:${arguments.serializedDataFileName}');
86 print('------------------------------------------------------------------'); 87 print('------------------------------------------------------------------');
87 print('serialize dart:core'); 88 print('serialize dart:core');
88 print('------------------------------------------------------------------'); 89 print('------------------------------------------------------------------');
89 String serializedData; 90 SerializedData serializedData;
90 if (arguments.loadSerializedData) { 91 if (arguments.loadSerializedData) {
91 File file = new File(arguments.serializedDataFileName); 92 File file = new File(arguments.serializedDataFileName);
92 if (file.existsSync()) { 93 if (file.existsSync()) {
93 print('Loading data from $file'); 94 print('Loading data from $file');
94 serializedData = file.readAsStringSync(); 95 serializedData = new SerializedData(uri, file.readAsStringSync());
95 } 96 }
96 } 97 }
97 if (serializedData == null) { 98 if (serializedData == null) {
98 Compiler compiler = compilerFor( 99 Compiler compiler = compilerFor(
99 options: [Flags.analyzeAll]); 100 options: [Flags.analyzeAll]);
100 compiler.serialization.supportSerialization = true; 101 compiler.serialization.supportSerialization = true;
101 await compiler.run(Uris.dart_core); 102 await compiler.run(Uris.dart_core);
102 BufferedEventSink sink = new BufferedEventSink(); 103 BufferedEventSink sink = new BufferedEventSink();
103 compiler.serialization.serializeToSink( 104 compiler.serialization.serializeToSink(
104 sink, compiler.libraryLoader.libraries); 105 sink, compiler.libraryLoader.libraries);
105 serializedData = sink.text; 106 serializedData = new SerializedData(uri, sink.text);
106 if (arguments.saveSerializedData) { 107 if (arguments.saveSerializedData) {
107 File file = new File(arguments.serializedDataFileName); 108 File file = new File(arguments.serializedDataFileName);
108 print('Saving data to $file'); 109 print('Saving data to $file');
109 file.writeAsStringSync(serializedData); 110 file.writeAsStringSync(serializedData.data);
110 } 111 }
111 } 112 }
112 return serializedData; 113 return serializedData;
113 } 114 }
115
116 class SerializedData {
117 final Uri uri;
118 final String data;
119
120 SerializedData(this.uri, this.data);
121
122 Map<String, String> toMemorySourceFiles([Map<String, String> input]) {
123 Map<String, String> sourceFiles = <String, String>{};
124 if (input != null) {
125 sourceFiles.addAll(input);
126 }
127 expandMemorySourceFiles(sourceFiles);
128 return sourceFiles;
129 }
130
131 void expandMemorySourceFiles(Map<String, String> sourceFiles) {
Siggi Cherem (dart-lang) 2016/05/24 18:08:15 are these expand methods used anywhere else? if no
Johnni Winther 2016/05/25 07:54:46 They are used in library_test.
132 if (uri.scheme == 'memory') {
133 sourceFiles[uri.path] = data;
134 }
135 }
136
137 List<Uri> toUris([List<Uri> input]) {
138 List<Uri> uris = <Uri>[];
139 if (input != null) {
140 uris.addAll(input);
141 }
142 expandUris(uris);
143 return uris;
144 }
145
146 void expandUris(List<Uri> uris) {
147 uris.add(uri);
148 }
149 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698