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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 library fasta.testing.suite; | 5 library fasta.testing.suite; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'dart:io' show File; | 9 import 'dart:io' show File; |
10 | 10 |
11 import 'dart:convert' show JSON; | 11 import 'dart:convert' show JSON; |
12 | 12 |
13 import 'package:front_end/physical_file_system.dart' show PhysicalFileSystem; | 13 import 'package:front_end/physical_file_system.dart' show PhysicalFileSystem; |
14 | 14 |
15 import 'package:front_end/src/base/libraries_specification.dart' | |
16 show TargetLibrariesSpecification; | |
17 | |
18 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart' | 15 import 'package:front_end/src/fasta/testing/validating_instrumentation.dart' |
19 show ValidatingInstrumentation; | 16 show ValidatingInstrumentation; |
20 | 17 |
21 import 'package:front_end/src/fasta/testing/patched_sdk_location.dart' | 18 import 'package:front_end/src/fasta/testing/patched_sdk_location.dart' |
22 show computeDartVm, computePatchedSdk; | 19 show computeDartVm, computePatchedSdk; |
23 import 'package:front_end/src/fasta/uri_translator_impl.dart'; | 20 import 'package:front_end/src/fasta/uri_translator_impl.dart'; |
24 | 21 |
25 import 'package:kernel/ast.dart' show Library, Program; | 22 import 'package:kernel/ast.dart' show Library, Program; |
26 | 23 |
27 import 'package:testing/testing.dart' | 24 import 'package:testing/testing.dart' |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 loadProgramFromBytes(new File.fromUri(outlineUri).readAsBytesSync()); | 148 loadProgramFromBytes(new File.fromUri(outlineUri).readAsBytesSync()); |
152 } | 149 } |
153 return outline; | 150 return outline; |
154 } | 151 } |
155 | 152 |
156 static Future<FastaContext> create( | 153 static Future<FastaContext> create( |
157 Chain suite, Map<String, String> environment) async { | 154 Chain suite, Map<String, String> environment) async { |
158 Uri sdk = await computePatchedSdk(); | 155 Uri sdk = await computePatchedSdk(); |
159 Uri vm = computeDartVm(sdk); | 156 Uri vm = computeDartVm(sdk); |
160 Uri packages = Uri.base.resolve(".packages"); | 157 Uri packages = Uri.base.resolve(".packages"); |
161 var options = new ProcessedOptions(new CompilerOptions() | 158 UriTranslator uriTranslator = await UriTranslatorImpl |
162 ..sdkRoot = sdk | 159 .parse(PhysicalFileSystem.instance, sdk, packages: packages); |
163 ..packagesFileUri = packages); | |
164 UriTranslator uriTranslator = await options.getUriTranslator(); | |
165 bool strongMode = environment.containsKey(STRONG_MODE); | 160 bool strongMode = environment.containsKey(STRONG_MODE); |
166 bool updateExpectations = environment["updateExpectations"] == "true"; | 161 bool updateExpectations = environment["updateExpectations"] == "true"; |
167 bool updateComments = environment["updateComments"] == "true"; | 162 bool updateComments = environment["updateComments"] == "true"; |
168 bool skipVm = environment["skipVm"] == "true"; | 163 bool skipVm = environment["skipVm"] == "true"; |
169 String astKindString = environment[AST_KIND_INDEX]; | 164 String astKindString = environment[AST_KIND_INDEX]; |
170 AstKind astKind = | 165 AstKind astKind = |
171 astKindString == null ? null : AstKind.values[int.parse(astKindString)]; | 166 astKindString == null ? null : AstKind.values[int.parse(astKindString)]; |
172 return new FastaContext( | 167 return new FastaContext( |
173 vm, | 168 vm, |
174 strongMode, | 169 strongMode, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 CompilerContext.current.disableColors(); | 235 CompilerContext.current.disableColors(); |
241 Program platformOutline = await context.loadPlatformOutline(); | 236 Program platformOutline = await context.loadPlatformOutline(); |
242 Ticker ticker = new Ticker(); | 237 Ticker ticker = new Ticker(); |
243 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator, | 238 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator, |
244 new TestVmFastaTarget(new TargetFlags(strongMode: strongMode))); | 239 new TestVmFastaTarget(new TargetFlags(strongMode: strongMode))); |
245 platformOutline.unbindCanonicalNames(); | 240 platformOutline.unbindCanonicalNames(); |
246 dillTarget.loader.appendLibraries(platformOutline); | 241 dillTarget.loader.appendLibraries(platformOutline); |
247 // We create a new URI translator to avoid reading platform libraries from | 242 // We create a new URI translator to avoid reading platform libraries from |
248 // file system. | 243 // file system. |
249 UriTranslatorImpl uriTranslator = new UriTranslatorImpl( | 244 UriTranslatorImpl uriTranslator = new UriTranslatorImpl( |
250 const TargetLibrariesSpecification('vm'), | 245 const <String, Uri>{}, |
| 246 const <String, List<Uri>>{}, |
251 context.uriTranslator.packages); | 247 context.uriTranslator.packages); |
252 KernelTarget sourceTarget = astKind == AstKind.Analyzer | 248 KernelTarget sourceTarget = astKind == AstKind.Analyzer |
253 ? new AnalyzerTarget(dillTarget, uriTranslator, strongMode) | 249 ? new AnalyzerTarget(dillTarget, uriTranslator, strongMode) |
254 : new KernelTarget( | 250 : new KernelTarget( |
255 PhysicalFileSystem.instance, false, dillTarget, uriTranslator); | 251 PhysicalFileSystem.instance, false, dillTarget, uriTranslator); |
256 | 252 |
257 Program p; | 253 Program p; |
258 try { | 254 try { |
259 sourceTarget.read(description.uri); | 255 sourceTarget.read(description.uri); |
260 await dillTarget.buildOutlines(); | 256 await dillTarget.buildOutlines(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 } | 320 } |
325 } | 321 } |
326 | 322 |
327 void performGlobalTransformations(CoreTypes coreTypes, Program program, | 323 void performGlobalTransformations(CoreTypes coreTypes, Program program, |
328 {void logger(String msg)}) { | 324 {void logger(String msg)}) { |
329 if (enabled) { | 325 if (enabled) { |
330 super.performGlobalTransformations(coreTypes, program, logger: logger); | 326 super.performGlobalTransformations(coreTypes, program, logger: logger); |
331 } | 327 } |
332 } | 328 } |
333 } | 329 } |
OLD | NEW |