OLD | NEW |
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.test.memory_compiler; | 5 library dart2js.test.memory_compiler; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:compiler/compiler.dart' show DiagnosticHandler; | 9 import 'package:compiler/compiler.dart' show DiagnosticHandler; |
10 import 'package:compiler/compiler_new.dart' | 10 import 'package:compiler/compiler_new.dart' |
11 show | 11 show |
12 CompilationResult, | 12 CompilationResult, |
13 CompilerDiagnostics, | 13 CompilerDiagnostics, |
14 CompilerOutput, | 14 CompilerOutput, |
15 Diagnostic, | 15 Diagnostic, |
16 PackagesDiscoveryProvider; | 16 PackagesDiscoveryProvider; |
17 import 'package:compiler/src/diagnostics/messages.dart' show Message; | 17 import 'package:compiler/src/diagnostics/messages.dart' show Message; |
| 18 import 'package:compiler/src/enqueue.dart' show ResolutionEnqueuer; |
18 import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput; | 19 import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput; |
19 import 'package:compiler/src/library_loader.dart' show LoadedLibraries; | 20 import 'package:compiler/src/library_loader.dart' show LoadedLibraries; |
20 import 'package:compiler/src/options.dart' show CompilerOptions; | 21 import 'package:compiler/src/options.dart' show CompilerOptions; |
21 | 22 |
22 import 'memory_source_file_helper.dart'; | 23 import 'memory_source_file_helper.dart'; |
23 | 24 |
24 export 'output_collector.dart'; | 25 export 'output_collector.dart'; |
25 export 'package:compiler/compiler_new.dart' show CompilationResult; | 26 export 'package:compiler/compiler_new.dart' show CompilationResult; |
26 export 'diagnostic_helper.dart'; | 27 export 'diagnostic_helper.dart'; |
27 | 28 |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 var patchLibrary = library.patch; | 172 var patchLibrary = library.patch; |
172 compiler.onLibraryCreated(patchLibrary); | 173 compiler.onLibraryCreated(patchLibrary); |
173 compiler.onLibraryScanned(patchLibrary, null); | 174 compiler.onLibraryScanned(patchLibrary, null); |
174 } | 175 } |
175 copiedLibraries[library.canonicalUri] = library; | 176 copiedLibraries[library.canonicalUri] = library; |
176 } | 177 } |
177 }); | 178 }); |
178 // TODO(johnniwinther): Assert that no libraries are loaded lazily from | 179 // TODO(johnniwinther): Assert that no libraries are loaded lazily from |
179 // this call. | 180 // this call. |
180 compiler.onLibrariesLoaded(new MemoryLoadedLibraries(copiedLibraries)); | 181 compiler.onLibrariesLoaded(new MemoryLoadedLibraries(copiedLibraries)); |
| 182 ResolutionEnqueuer resolutionEnqueuer = compiler.startResolution(); |
181 | 183 |
182 compiler.backend.constantCompilerTask | 184 compiler.backend.constantCompilerTask |
183 .copyConstantValues(cachedCompiler.backend.constantCompilerTask); | 185 .copyConstantValues(cachedCompiler.backend.constantCompilerTask); |
184 | 186 |
185 Iterable cachedTreeElements = | 187 Iterable cachedTreeElements = |
186 cachedCompiler.enqueuer.resolution.processedEntities; | 188 cachedCompiler.enqueuer.resolution.processedEntities; |
187 cachedTreeElements.forEach((element) { | 189 cachedTreeElements.forEach((element) { |
188 if (element.library.isPlatformLibrary) { | 190 if (element.library.isPlatformLibrary) { |
189 compiler.enqueuer.resolution.registerProcessedElementInternal(element); | 191 resolutionEnqueuer.registerProcessedElementInternal(element); |
190 } | 192 } |
191 }); | 193 }); |
192 | 194 |
193 // One potential problem that can occur when reusing elements is that there | 195 // One potential problem that can occur when reusing elements is that there |
194 // is a stale reference to an old compiler object. By nulling out the old | 196 // is a stale reference to an old compiler object. By nulling out the old |
195 // compiler's fields, such stale references are easier to identify. | 197 // compiler's fields, such stale references are easier to identify. |
196 cachedCompiler.scanner = null; | 198 cachedCompiler.scanner = null; |
197 cachedCompiler.dietParser = null; | 199 cachedCompiler.dietParser = null; |
198 cachedCompiler.parser = null; | 200 cachedCompiler.parser = null; |
199 cachedCompiler.patchParser = null; | 201 cachedCompiler.patchParser = null; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { | 246 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { |
245 diagnosticHandler(uri, begin, end, message, kind); | 247 diagnosticHandler(uri, begin, end, message, kind); |
246 formattingHandler(uri, begin, end, message, kind); | 248 formattingHandler(uri, begin, end, message, kind); |
247 }; | 249 }; |
248 } | 250 } |
249 } else if (diagnosticHandler == null) { | 251 } else if (diagnosticHandler == null) { |
250 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; | 252 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; |
251 } | 253 } |
252 return handler; | 254 return handler; |
253 } | 255 } |
OLD | NEW |