Index: pkg/kernel/test/interpreter/suite.dart |
diff --git a/pkg/kernel/test/interpreter/suite.dart b/pkg/kernel/test/interpreter/suite.dart |
index 8c84abd1e2e05d1c7fac4e0369963828ff0bb87e..6d4f7dcb26eab37e0a3696a08ea6b5d65dc583b1 100644 |
--- a/pkg/kernel/test/interpreter/suite.dart |
+++ b/pkg/kernel/test/interpreter/suite.dart |
@@ -8,34 +8,99 @@ import 'dart:async' show Future; |
import 'dart:io' show File; |
+import 'package:front_end/physical_file_system.dart' show PhysicalFileSystem; |
+ |
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; |
-import 'package:front_end/src/fasta/testing/kernel_chain.dart' |
- show runDiff, Compile, CompileContext; |
+import 'package:front_end/src/fasta/testing/kernel_chain.dart' show runDiff; |
+ |
+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; |
import 'package:kernel/interpreter/interpreter.dart'; |
const String STRONG_MODE = " strong mode "; |
-class InterpreterContext extends ChainContext implements CompileContext { |
+class InterpreterContext extends ChainContext { |
final bool strongMode; |
+ final TranslateUri uriTranslator; |
+ |
final List<Step> steps; |
- InterpreterContext(this.strongMode) |
+ Future<Program> platform; |
+ |
+ InterpreterContext(this.strongMode, this.uriTranslator) |
: steps = <Step>[ |
- const Compile(), |
+ const FastaCompile(), |
const Interpret(), |
const MatchLogExpectation(".expect"), |
]; |
+ Future<Program> loadPlatform() async { |
+ Uri sdk = await computePatchedSdk(); |
+ return loadProgramFromBinary(sdk.resolve('platform.dill').toFilePath()); |
+ } |
+ |
static Future<InterpreterContext> create( |
Chain suite, Map<String, String> environment) async { |
+ Uri sdk = await computePatchedSdk(); |
+ Uri packages = Uri.base.resolve(".packages"); |
bool strongMode = environment.containsKey(STRONG_MODE); |
- return new InterpreterContext(strongMode); |
+ TranslateUri uriTranslator = await TranslateUri |
+ .parse(PhysicalFileSystem.instance, sdk, packages: packages); |
+ return new InterpreterContext(strongMode, uriTranslator); |
+ } |
+} |
+ |
+class FastaCompile extends Step<TestDescription, Program, InterpreterContext> { |
+ const FastaCompile(); |
+ |
+ String get name => "fasta compile"; |
+ |
+ Future<Result<Program>> run( |
+ TestDescription description, InterpreterContext 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); |
} |
} |