Index: pkg/kernel/test/closures/suite.dart |
diff --git a/pkg/kernel/test/closures/suite.dart b/pkg/kernel/test/closures/suite.dart |
index f85602171ce144d526b49a9404b9008853f21e22..6e246fac176b28f27ade41622041c5ab8fd0d1da 100644 |
--- a/pkg/kernel/test/closures/suite.dart |
+++ b/pkg/kernel/test/closures/suite.dart |
@@ -6,10 +6,15 @@ library test.kernel.closures.suite; |
import 'dart:async' show Future; |
+import 'package:front_end/physical_file_system.dart' show PhysicalFileSystem; |
+ |
import 'package:kernel/core_types.dart' show CoreTypes; |
import 'package:testing/testing.dart' |
- show Chain, ChainContext, Result, Step, runMe; |
+ show Chain, ChainContext, Result, Step, TestDescription, runMe; |
+ |
+import 'package:front_end/src/fasta/testing/patched_sdk_location.dart' |
+ show computePatchedSdk; |
import 'package:kernel/ast.dart' show Program, Library; |
@@ -17,25 +22,40 @@ import 'package:kernel/transformations/closure_conversion.dart' |
as closure_conversion; |
import 'package:front_end/src/fasta/testing/kernel_chain.dart' |
- show |
- Print, |
- MatchExpectation, |
- WriteDill, |
- ReadDill, |
- Verify, |
- Compile, |
- CompileContext; |
+ show Print, MatchExpectation, WriteDill, ReadDill, Verify; |
+ |
+import 'package:front_end/src/fasta/ticker.dart' show Ticker; |
+ |
+import 'package:front_end/src/fasta/dill/dill_target.dart' show DillTarget; |
+ |
+import 'package:front_end/src/fasta/kernel/kernel_target.dart' |
+ show KernelTarget; |
+ |
+import 'package:front_end/src/fasta/translate_uri.dart' show TranslateUri; |
+ |
+import 'package:front_end/src/fasta/errors.dart' show InputError; |
+ |
+import 'package:front_end/src/fasta/testing/patched_sdk_location.dart'; |
+ |
+import 'package:kernel/kernel.dart' show loadProgramFromBinary; |
+ |
+import 'package:kernel/target/targets.dart' show TargetFlags; |
+ |
+import 'package:kernel/target/vm_fasta.dart' show VmFastaTarget; |
const String STRONG_MODE = " strong mode "; |
-class ClosureConversionContext extends ChainContext implements CompileContext { |
+class ClosureConversionContext extends ChainContext { |
final bool strongMode; |
+ final TranslateUri uriTranslator; |
+ |
final List<Step> steps; |
- ClosureConversionContext(this.strongMode, bool updateExpectations) |
+ ClosureConversionContext( |
+ this.strongMode, bool updateExpectations, this.uriTranslator) |
: steps = <Step>[ |
- const Compile(), |
+ const FastaCompile(), |
const Print(), |
const Verify(true), |
const ClosureConversion(), |
@@ -48,11 +68,21 @@ class ClosureConversionContext extends ChainContext implements CompileContext { |
// TODO(29143): add `Run` step when Vectors are added to VM. |
]; |
+ Future<Program> loadPlatform() async { |
+ Uri sdk = await computePatchedSdk(); |
+ return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); |
+ } |
+ |
static Future<ClosureConversionContext> create( |
Chain suite, Map<String, String> environment) async { |
+ Uri sdk = await computePatchedSdk(); |
+ Uri packages = Uri.base.resolve(".packages"); |
bool strongMode = environment.containsKey(STRONG_MODE); |
bool updateExpectations = environment["updateExpectations"] == "true"; |
- return new ClosureConversionContext(strongMode, updateExpectations); |
+ TranslateUri uriTranslator = await TranslateUri |
+ .parse(PhysicalFileSystem.instance, sdk, packages: packages); |
+ return new ClosureConversionContext( |
+ strongMode, updateExpectations, uriTranslator); |
} |
} |
@@ -63,6 +93,36 @@ Future<ClosureConversionContext> createContext( |
return ClosureConversionContext.create(suite, environment); |
} |
+class FastaCompile |
+ extends Step<TestDescription, Program, ClosureConversionContext> { |
+ const FastaCompile(); |
+ |
+ String get name => "fasta compilation"; |
+ |
+ Future<Result<Program>> run( |
+ TestDescription description, ClosureConversionContext context) async { |
+ Program platform = await context.loadPlatform(); |
+ Ticker ticker = new Ticker(); |
+ DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator, |
+ new VmFastaTarget(new TargetFlags(strongMode: context.strongMode))); |
+ platform.unbindCanonicalNames(); |
+ dillTarget.loader.appendLibraries(platform); |
+ KernelTarget sourceTarget = new KernelTarget( |
+ PhysicalFileSystem.instance, dillTarget, context.uriTranslator); |
+ |
+ Program p; |
+ try { |
+ sourceTarget.read(description.uri); |
+ await dillTarget.buildOutlines(); |
+ await sourceTarget.buildOutlines(); |
+ p = await sourceTarget.buildProgram(); |
+ } on InputError catch (e, s) { |
+ return fail(null, e.error, s); |
+ } |
+ return pass(p); |
+ } |
+} |
+ |
class ClosureConversion |
extends Step<Program, Program, ClosureConversionContext> { |
const ClosureConversion(); |