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/elements/entities.dart' show LibraryEntity; | 18 import 'package:compiler/src/elements/entities.dart' |
| 19 show LibraryEntity, MemberEntity; |
19 import 'package:compiler/src/enqueue.dart' show ResolutionEnqueuer; | 20 import 'package:compiler/src/enqueue.dart' show ResolutionEnqueuer; |
20 import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput; | 21 import 'package:compiler/src/null_compiler_output.dart' show NullCompilerOutput; |
21 import 'package:compiler/src/library_loader.dart' show LoadedLibraries; | 22 import 'package:compiler/src/library_loader.dart' show LoadedLibraries; |
22 import 'package:compiler/src/options.dart' show CompilerOptions; | 23 import 'package:compiler/src/options.dart' show CompilerOptions; |
23 | 24 |
24 import 'memory_source_file_helper.dart'; | 25 import 'memory_source_file_helper.dart'; |
25 | 26 |
26 export 'output_collector.dart'; | 27 export 'output_collector.dart'; |
27 export 'package:compiler/compiler_new.dart' show CompilationResult; | 28 export 'package:compiler/compiler_new.dart' show CompilationResult; |
28 export 'diagnostic_helper.dart'; | 29 export 'diagnostic_helper.dart'; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 libraryLoader.mapLibrary(library); | 177 libraryLoader.mapLibrary(library); |
177 copiedLibraries[library.canonicalUri] = library; | 178 copiedLibraries[library.canonicalUri] = library; |
178 } | 179 } |
179 }); | 180 }); |
180 compiler.processLoadedLibraries(new MemoryLoadedLibraries(copiedLibraries)); | 181 compiler.processLoadedLibraries(new MemoryLoadedLibraries(copiedLibraries)); |
181 ResolutionEnqueuer resolutionEnqueuer = compiler.startResolution(); | 182 ResolutionEnqueuer resolutionEnqueuer = compiler.startResolution(); |
182 | 183 |
183 compiler.backend.constantCompilerTask | 184 compiler.backend.constantCompilerTask |
184 .copyConstantValues(cachedCompiler.backend.constantCompilerTask); | 185 .copyConstantValues(cachedCompiler.backend.constantCompilerTask); |
185 | 186 |
186 Iterable cachedTreeElements = | 187 Iterable<MemberEntity> cachedTreeElements = |
187 cachedCompiler.enqueuer.resolution.processedEntities; | 188 cachedCompiler.enqueuer.resolution.processedEntities; |
188 cachedTreeElements.forEach((element) { | 189 cachedTreeElements.forEach((MemberEntity element) { |
189 if (element.library.isPlatformLibrary) { | 190 if (element.library.canonicalUri.scheme == 'dart') { |
190 resolutionEnqueuer.registerProcessedElementInternal(element); | 191 resolutionEnqueuer.registerProcessedElementInternal(element); |
191 } | 192 } |
192 }); | 193 }); |
193 | 194 |
194 // 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 |
195 // 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 |
196 // compiler's fields, such stale references are easier to identify. | 197 // compiler's fields, such stale references are easier to identify. |
197 cachedCompiler.scanner = null; | 198 cachedCompiler.scanner = null; |
198 cachedCompiler.dietParser = null; | 199 cachedCompiler.dietParser = null; |
199 cachedCompiler.parser = null; | 200 cachedCompiler.parser = null; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { | 248 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) { |
248 diagnosticHandler(uri, begin, end, message, kind); | 249 diagnosticHandler(uri, begin, end, message, kind); |
249 formattingHandler(uri, begin, end, message, kind); | 250 formattingHandler(uri, begin, end, message, kind); |
250 }; | 251 }; |
251 } | 252 } |
252 } else if (diagnosticHandler == null) { | 253 } else if (diagnosticHandler == null) { |
253 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; | 254 handler = (Uri uri, int begin, int end, String message, Diagnostic kind) {}; |
254 } | 255 } |
255 return handler; | 256 return handler; |
256 } | 257 } |
OLD | NEW |