OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 // Partial test that the closed world computed from [WorldImpact]s derived from | 5 // Partial test that the closed world computed from [WorldImpact]s derived from |
6 // kernel is equivalent to the original computed from resolution. | 6 // kernel is equivalent to the original computed from resolution. |
7 library dart2js.kernel.compiler_helper; | 7 library dart2js.kernel.compiler_helper; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 : super(elementMap, null, null, reporter, measurer); | 134 : super(elementMap, null, null, reporter, measurer); |
135 | 135 |
136 Future<LoadedLibraries> loadLibrary(Uri resolvedUri, | 136 Future<LoadedLibraries> loadLibrary(Uri resolvedUri, |
137 {bool skipFileWithPartOfTag: false}) async { | 137 {bool skipFileWithPartOfTag: false}) async { |
138 return createLoadedLibraries(program); | 138 return createLoadedLibraries(program); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 Future<Compiler> compileWithDill( | 142 Future<Compiler> compileWithDill( |
143 Uri entryPoint, Map<String, String> memorySourceFiles, List<String> options, | 143 Uri entryPoint, Map<String, String> memorySourceFiles, List<String> options, |
144 {bool printSteps: false, CompilerOutput compilerOutput}) async { | 144 {bool printSteps: false, |
| 145 CompilerOutput compilerOutput, |
| 146 void beforeRun(Compiler compiler)}) async { |
145 if (memorySourceFiles.isNotEmpty) { | 147 if (memorySourceFiles.isNotEmpty) { |
146 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill'); | 148 Directory dir = await Directory.systemTemp.createTemp('dart2js-with-dill'); |
147 if (printSteps) { | 149 if (printSteps) { |
148 print('--- create temp directory $dir -------------------------------'); | 150 print('--- create temp directory $dir -------------------------------'); |
149 } | 151 } |
150 memorySourceFiles.forEach((String name, String source) { | 152 memorySourceFiles.forEach((String name, String source) { |
151 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source); | 153 new File.fromUri(dir.uri.resolve(name)).writeAsStringSync(source); |
152 }); | 154 }); |
153 entryPoint = dir.uri.resolve(entryPoint.path); | 155 entryPoint = dir.uri.resolve(entryPoint.path); |
154 } | 156 } |
(...skipping 12 matching lines...) Expand all Loading... |
167 | 169 |
168 if (printSteps) { | 170 if (printSteps) { |
169 print('---- compile from dill $dillFile ---------------------------------'); | 171 print('---- compile from dill $dillFile ---------------------------------'); |
170 } | 172 } |
171 Compiler compiler = compilerFor( | 173 Compiler compiler = compilerFor( |
172 entryPoint: dillFile, | 174 entryPoint: dillFile, |
173 options: [Flags.loadFromDill]..addAll(options), | 175 options: [Flags.loadFromDill]..addAll(options), |
174 outputProvider: compilerOutput); | 176 outputProvider: compilerOutput); |
175 ElementResolutionWorldBuilder.useInstantiationMap = true; | 177 ElementResolutionWorldBuilder.useInstantiationMap = true; |
176 compiler.resolution.retainCachesForTesting = true; | 178 compiler.resolution.retainCachesForTesting = true; |
| 179 if (beforeRun != null) { |
| 180 beforeRun(compiler); |
| 181 } |
177 await compiler.run(dillFile); | 182 await compiler.run(dillFile); |
178 return compiler; | 183 return compiler; |
179 } | 184 } |
OLD | NEW |