| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 'memory_source_file_helper.dart'; | 7 import 'memory_source_file_helper.dart'; |
| 8 | 8 |
| 9 import 'package:compiler/src/dart2jslib.dart' | 9 import 'package:compiler/src/dart2jslib.dart' |
| 10 show NullSink; | 10 show NullSink; |
| 11 | 11 |
| 12 import 'package:compiler/compiler.dart' | 12 import 'package:compiler/compiler.dart' |
| 13 show Diagnostic, DiagnosticHandler, CompilerOutputProvider; | 13 show Diagnostic, DiagnosticHandler, CompilerOutputProvider; |
| 14 | 14 |
| 15 import 'dart:async'; | 15 import 'dart:async'; |
| 16 | 16 |
| 17 import 'package:compiler/src/mirrors/source_mirrors.dart'; | 17 import 'package:compiler/src/mirrors/source_mirrors.dart'; |
| 18 import 'package:compiler/src/mirrors/analyze.dart'; | 18 import 'package:compiler/src/mirrors/analyze.dart'; |
| 19 | 19 |
| 20 import 'package:compiler/src/library_loader.dart' |
| 21 show LoadedLibraries; |
| 22 |
| 20 class DiagnosticMessage { | 23 class DiagnosticMessage { |
| 21 final Uri uri; | 24 final Uri uri; |
| 22 final int begin; | 25 final int begin; |
| 23 final int end; | 26 final int end; |
| 24 final String message; | 27 final String message; |
| 25 final Diagnostic kind; | 28 final Diagnostic kind; |
| 26 | 29 |
| 27 DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind); | 30 DiagnosticMessage(this.uri, this.begin, this.end, this.message, this.kind); |
| 28 | 31 |
| 29 String toString() => '$uri:$begin:$end:$message:$kind'; | 32 String toString() => '$uri:$begin:$end:$message:$kind'; |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 if (library.isPatched) { | 179 if (library.isPatched) { |
| 177 var patchLibrary = library.patch; | 180 var patchLibrary = library.patch; |
| 178 compiler.onLibraryCreated(patchLibrary); | 181 compiler.onLibraryCreated(patchLibrary); |
| 179 compiler.onLibraryScanned(patchLibrary, null); | 182 compiler.onLibraryScanned(patchLibrary, null); |
| 180 } | 183 } |
| 181 copiedLibraries[library.canonicalUri] = library; | 184 copiedLibraries[library.canonicalUri] = library; |
| 182 } | 185 } |
| 183 }); | 186 }); |
| 184 // TODO(johnniwinther): Assert that no libraries are loaded lazily from | 187 // TODO(johnniwinther): Assert that no libraries are loaded lazily from |
| 185 // this call. | 188 // this call. |
| 186 compiler.onLibrariesLoaded(copiedLibraries); | 189 compiler.onLibrariesLoaded(new MemoryLoadedLibraries(copiedLibraries)); |
| 187 | 190 |
| 188 compiler.symbolConstructor = cachedCompiler.symbolConstructor; | 191 compiler.symbolConstructor = cachedCompiler.symbolConstructor; |
| 189 compiler.mirrorSystemClass = cachedCompiler.mirrorSystemClass; | 192 compiler.mirrorSystemClass = cachedCompiler.mirrorSystemClass; |
| 190 compiler.mirrorsUsedClass = cachedCompiler.mirrorsUsedClass; | 193 compiler.mirrorsUsedClass = cachedCompiler.mirrorsUsedClass; |
| 191 compiler.mirrorSystemGetNameFunction = | 194 compiler.mirrorSystemGetNameFunction = |
| 192 cachedCompiler.mirrorSystemGetNameFunction; | 195 cachedCompiler.mirrorSystemGetNameFunction; |
| 193 compiler.symbolImplementationClass = | 196 compiler.symbolImplementationClass = |
| 194 cachedCompiler.symbolImplementationClass; | 197 cachedCompiler.symbolImplementationClass; |
| 195 compiler.symbolValidatedConstructor = | 198 compiler.symbolValidatedConstructor = |
| 196 cachedCompiler.symbolValidatedConstructor; | 199 cachedCompiler.symbolValidatedConstructor; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 222 // Don't null out the enqueuer as it prevents us from using cachedCompiler | 225 // Don't null out the enqueuer as it prevents us from using cachedCompiler |
| 223 // more than once. | 226 // more than once. |
| 224 cachedCompiler.deferredLoadTask = null; | 227 cachedCompiler.deferredLoadTask = null; |
| 225 cachedCompiler.mirrorUsageAnalyzerTask = null; | 228 cachedCompiler.mirrorUsageAnalyzerTask = null; |
| 226 cachedCompiler.dumpInfoTask = null; | 229 cachedCompiler.dumpInfoTask = null; |
| 227 cachedCompiler.buildId = null; | 230 cachedCompiler.buildId = null; |
| 228 } | 231 } |
| 229 return compiler; | 232 return compiler; |
| 230 } | 233 } |
| 231 | 234 |
| 235 class MemoryLoadedLibraries implements LoadedLibraries { |
| 236 final Map copiedLibraries; |
| 237 |
| 238 MemoryLoadedLibraries(this.copiedLibraries); |
| 239 |
| 240 @override |
| 241 bool containsLibrary(Uri uri) => copiedLibraries.containsKey(uri); |
| 242 |
| 243 @override |
| 244 void forEachImportChain(f) {} |
| 245 |
| 246 @override |
| 247 void forEachLibrary(f) {} |
| 248 |
| 249 @override |
| 250 getLibrary(Uri uri) => copiedLibraries[uri]; |
| 251 |
| 252 @override |
| 253 Uri get rootUri => null; |
| 254 } |
| 255 |
| 232 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, | 256 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, |
| 233 {DiagnosticHandler diagnosticHandler, | 257 {DiagnosticHandler diagnosticHandler, |
| 234 List<String> options: const [], | 258 List<String> options: const [], |
| 235 bool showDiagnostics: true}) { | 259 bool showDiagnostics: true}) { |
| 236 Uri libraryRoot = Uri.base.resolve('sdk/'); | 260 Uri libraryRoot = Uri.base.resolve('sdk/'); |
| 237 Uri packageRoot = Uri.base.resolveUri( | 261 Uri packageRoot = Uri.base.resolveUri( |
| 238 new Uri.file('${Platform.packageRoot}/')); | 262 new Uri.file('${Platform.packageRoot}/')); |
| 239 | 263 |
| 240 var provider = new MemorySourceFileProvider(memorySourceFiles); | 264 var provider = new MemorySourceFileProvider(memorySourceFiles); |
| 241 var handler = | 265 var handler = |
| 242 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | 266 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
| 243 | 267 |
| 244 List<Uri> libraries = <Uri>[]; | 268 List<Uri> libraries = <Uri>[]; |
| 245 memorySourceFiles.forEach((String path, _) { | 269 memorySourceFiles.forEach((String path, _) { |
| 246 libraries.add(new Uri(scheme: 'memory', path: path)); | 270 libraries.add(new Uri(scheme: 'memory', path: path)); |
| 247 }); | 271 }); |
| 248 | 272 |
| 249 return analyze(libraries, libraryRoot, packageRoot, | 273 return analyze(libraries, libraryRoot, packageRoot, |
| 250 provider, handler, options); | 274 provider, handler, options); |
| 251 } | 275 } |
| OLD | NEW |