| 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 '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' | 9 import '../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart' |
| 10 show NullSink; | 10 show NullSink; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 Compiler compilerFor(Map<String,String> memorySourceFiles, | 120 Compiler compilerFor(Map<String,String> memorySourceFiles, |
| 121 {DiagnosticHandler diagnosticHandler, | 121 {DiagnosticHandler diagnosticHandler, |
| 122 CompilerOutputProvider outputProvider, | 122 CompilerOutputProvider outputProvider, |
| 123 List<String> options: const [], | 123 List<String> options: const [], |
| 124 Compiler cachedCompiler, | 124 Compiler cachedCompiler, |
| 125 bool showDiagnostics: true, | 125 bool showDiagnostics: true, |
| 126 Uri packageRoot}) { | 126 Uri packageRoot}) { |
| 127 Uri libraryRoot = Uri.base.resolve('sdk/'); | 127 Uri libraryRoot = Uri.base.resolve('sdk/'); |
| 128 Uri script = Uri.base.resolveUri(Platform.script); | 128 Uri script = Uri.base.resolveUri(Platform.script); |
| 129 if (packageRoot == null) { | 129 if (packageRoot == null) { |
| 130 packageRoot = Uri.base.resolve('${Platform.packageRoot}/'); | 130 packageRoot = Uri.base.resolveUri(new Uri.file('${Platform.packageRoot}/')); |
| 131 } | 131 } |
| 132 | 132 |
| 133 MemorySourceFileProvider provider; | 133 MemorySourceFileProvider provider; |
| 134 var readStringFromUri; | 134 var readStringFromUri; |
| 135 if (cachedCompiler == null) { | 135 if (cachedCompiler == null) { |
| 136 provider = new MemorySourceFileProvider(memorySourceFiles); | 136 provider = new MemorySourceFileProvider(memorySourceFiles); |
| 137 readStringFromUri = provider.readStringFromUri; | 137 readStringFromUri = provider.readStringFromUri; |
| 138 // Saving the provider in case we need it later for a cached compiler. | 138 // Saving the provider in case we need it later for a cached compiler. |
| 139 expando[readStringFromUri] = provider; | 139 expando[readStringFromUri] = provider; |
| 140 } else { | 140 } else { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 159 Compiler compiler = new Compiler(readStringFromUri, | 159 Compiler compiler = new Compiler(readStringFromUri, |
| 160 outputProvider, | 160 outputProvider, |
| 161 handler, | 161 handler, |
| 162 libraryRoot, | 162 libraryRoot, |
| 163 packageRoot, | 163 packageRoot, |
| 164 options, | 164 options, |
| 165 {}); | 165 {}); |
| 166 if (cachedCompiler != null) { | 166 if (cachedCompiler != null) { |
| 167 compiler.coreLibrary = cachedCompiler.libraries['dart:core']; | 167 compiler.coreLibrary = cachedCompiler.libraries['dart:core']; |
| 168 compiler.types = cachedCompiler.types.copy(compiler); | 168 compiler.types = cachedCompiler.types.copy(compiler); |
| 169 Map copiedLibraries = {}; |
| 169 cachedCompiler.libraries.forEach((String uri, library) { | 170 cachedCompiler.libraries.forEach((String uri, library) { |
| 170 if (library.isPlatformLibrary) { | 171 if (library.isPlatformLibrary) { |
| 172 compiler.onLibraryCreated(library); |
| 171 compiler.libraries[uri] = library; | 173 compiler.libraries[uri] = library; |
| 172 compiler.onLibraryLoaded(library, library.canonicalUri); | 174 compiler.onLibraryScanned(library); |
| 175 copiedLibraries[library.canonicalUri] = library; |
| 173 } | 176 } |
| 174 }); | 177 }); |
| 178 // TODO(johnniwinther): Assert that no libraries are loaded lazily from |
| 179 // this call. |
| 180 compiler.onLibrariesLoaded(copiedLibraries); |
| 175 | 181 |
| 176 compiler.symbolConstructor = cachedCompiler.symbolConstructor; | 182 compiler.symbolConstructor = cachedCompiler.symbolConstructor; |
| 177 compiler.mirrorSystemClass = cachedCompiler.mirrorSystemClass; | 183 compiler.mirrorSystemClass = cachedCompiler.mirrorSystemClass; |
| 178 compiler.mirrorsUsedClass = cachedCompiler.mirrorsUsedClass; | 184 compiler.mirrorsUsedClass = cachedCompiler.mirrorsUsedClass; |
| 179 compiler.mirrorSystemGetNameFunction = | 185 compiler.mirrorSystemGetNameFunction = |
| 180 cachedCompiler.mirrorSystemGetNameFunction; | 186 cachedCompiler.mirrorSystemGetNameFunction; |
| 181 compiler.symbolImplementationClass = | 187 compiler.symbolImplementationClass = |
| 182 cachedCompiler.symbolImplementationClass; | 188 cachedCompiler.symbolImplementationClass; |
| 183 compiler.symbolValidatedConstructor = | 189 compiler.symbolValidatedConstructor = |
| 184 cachedCompiler.symbolValidatedConstructor; | 190 cachedCompiler.symbolValidatedConstructor; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 cachedCompiler.buildId = null; | 223 cachedCompiler.buildId = null; |
| 218 } | 224 } |
| 219 return compiler; | 225 return compiler; |
| 220 } | 226 } |
| 221 | 227 |
| 222 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, | 228 Future<MirrorSystem> mirrorSystemFor(Map<String,String> memorySourceFiles, |
| 223 {DiagnosticHandler diagnosticHandler, | 229 {DiagnosticHandler diagnosticHandler, |
| 224 List<String> options: const [], | 230 List<String> options: const [], |
| 225 bool showDiagnostics: true}) { | 231 bool showDiagnostics: true}) { |
| 226 Uri libraryRoot = Uri.base.resolve('sdk/'); | 232 Uri libraryRoot = Uri.base.resolve('sdk/'); |
| 227 Uri packageRoot = Uri.base.resolve('${Platform.packageRoot}/'); | 233 Uri packageRoot = Uri.base.resolveUri( |
| 234 new Uri.file('${Platform.packageRoot}/')); |
| 228 Uri script = Uri.base.resolveUri(Platform.script); | 235 Uri script = Uri.base.resolveUri(Platform.script); |
| 229 | 236 |
| 230 var provider = new MemorySourceFileProvider(memorySourceFiles); | 237 var provider = new MemorySourceFileProvider(memorySourceFiles); |
| 231 var handler = | 238 var handler = |
| 232 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); | 239 createDiagnosticHandler(diagnosticHandler, provider, showDiagnostics); |
| 233 | 240 |
| 234 List<Uri> libraries = <Uri>[]; | 241 List<Uri> libraries = <Uri>[]; |
| 235 memorySourceFiles.forEach((String path, _) { | 242 memorySourceFiles.forEach((String path, _) { |
| 236 libraries.add(new Uri(scheme: 'memory', path: path)); | 243 libraries.add(new Uri(scheme: 'memory', path: path)); |
| 237 }); | 244 }); |
| 238 | 245 |
| 239 return analyze(libraries, libraryRoot, packageRoot, | 246 return analyze(libraries, libraryRoot, packageRoot, |
| 240 provider, handler, options); | 247 provider, handler, options); |
| 241 } | 248 } |
| OLD | NEW |