| Index: pkg/front_end/lib/src/fasta/outline.dart
|
| diff --git a/pkg/front_end/lib/src/fasta/outline.dart b/pkg/front_end/lib/src/fasta/outline.dart
|
| index 128afb78d8b30d180e8e9b0437feb0a3ba26f8d8..3d328e761903c36cee438544b8770b2135533067 100644
|
| --- a/pkg/front_end/lib/src/fasta/outline.dart
|
| +++ b/pkg/front_end/lib/src/fasta/outline.dart
|
| @@ -24,8 +24,6 @@ import 'ticker.dart' show Ticker;
|
|
|
| import 'translate_uri.dart' show TranslateUri;
|
|
|
| -import 'ast_kind.dart' show AstKind;
|
| -
|
| Future<KernelTarget> outline(List<String> arguments) async {
|
| try {
|
| return await CompilerCommandLine.withGlobalOptions("outline", arguments,
|
| @@ -33,8 +31,9 @@ Future<KernelTarget> outline(List<String> arguments) async {
|
| if (c.options.verbose) {
|
| print("Building outlines for ${arguments.join(' ')}");
|
| }
|
| - return await doOutline(
|
| - c, new Ticker(isVerbose: c.options.verbose), c.options.output);
|
| + CompileTask task =
|
| + new CompileTask(c, new Ticker(isVerbose: c.options.verbose));
|
| + return await task.buildOutline(c.options.output);
|
| });
|
| } on InputError catch (e) {
|
| exitCode = 1;
|
| @@ -50,8 +49,9 @@ Future<Uri> compile(List<String> arguments) async {
|
| if (c.options.verbose) {
|
| print("Compiling directly to Kernel: ${arguments.join(' ')}");
|
| }
|
| - return await doCompile(
|
| - c, new Ticker(isVerbose: c.options.verbose), AstKind.Kernel);
|
| + CompileTask task =
|
| + new CompileTask(c, new Ticker(isVerbose: c.options.verbose));
|
| + return await task.compile();
|
| });
|
| } on InputError catch (e) {
|
| exitCode = 1;
|
| @@ -60,69 +60,62 @@ Future<Uri> compile(List<String> arguments) async {
|
| }
|
| }
|
|
|
| -Future<Uri> kompile(List<String> arguments) async {
|
| - try {
|
| - return await CompilerCommandLine.withGlobalOptions("kompile", arguments,
|
| - (CompilerContext c) async {
|
| - if (c.options.verbose) {
|
| - print("Compiling via analyzer: ${arguments.join(' ')}");
|
| - }
|
| - return await doCompile(
|
| - c, new Ticker(isVerbose: c.options.verbose), AstKind.Analyzer);
|
| - });
|
| - } on InputError catch (e) {
|
| - exitCode = 1;
|
| - print(e.format());
|
| - return null;
|
| - }
|
| -}
|
| +class CompileTask {
|
| + final CompilerContext c;
|
| + final Ticker ticker;
|
|
|
| -Future<KernelTarget> doOutline(CompilerContext c, Ticker ticker,
|
| - [Uri output]) async {
|
| - TranslateUri uriTranslator = await TranslateUri.parse(c.options.sdk);
|
| - ticker.logMs("Read packages file");
|
| - DillTarget dillTarget = new DillTarget(ticker, uriTranslator);
|
| - KernelTarget kernelTarget =
|
| - new KernelTarget(dillTarget, uriTranslator, c.uriToSource);
|
| - Uri platform = c.options.platform;
|
| - if (platform != null) {
|
| - dillTarget.read(platform);
|
| - }
|
| - String argument = c.options.arguments.first;
|
| - Uri uri = Uri.base.resolve(argument);
|
| - String path = uriTranslator.translate(uri)?.path ?? argument;
|
| - if (path.endsWith(".dart")) {
|
| - kernelTarget.read(uri);
|
| - } else {
|
| - inputError(uri, -1, "Unexpected input: $uri");
|
| - }
|
| - await dillTarget.writeOutline(null);
|
| - await kernelTarget.writeOutline(output);
|
| - if (c.options.dumpIr && output != null) {
|
| - kernelTarget.dumpIr();
|
| + CompileTask(this.c, this.ticker);
|
| +
|
| + KernelTarget createKernelTarget(
|
| + DillTarget dillTarget, TranslateUri uriTranslator) {
|
| + return new KernelTarget(dillTarget, uriTranslator, c.uriToSource);
|
| }
|
| - return kernelTarget;
|
| -}
|
|
|
| -Future<Uri> doCompile(CompilerContext c, Ticker ticker, AstKind kind) async {
|
| - KernelTarget kernelTarget = await doOutline(c, ticker);
|
| - if (exitCode != 0) return null;
|
| - Uri uri = c.options.output;
|
| - await kernelTarget.writeProgram(uri, kind);
|
| - if (c.options.dumpIr) {
|
| - kernelTarget.dumpIr();
|
| + Future<KernelTarget> buildOutline([Uri output]) async {
|
| + TranslateUri uriTranslator = await TranslateUri.parse(c.options.sdk);
|
| + ticker.logMs("Read packages file");
|
| + DillTarget dillTarget = new DillTarget(ticker, uriTranslator);
|
| + KernelTarget kernelTarget = createKernelTarget(dillTarget, uriTranslator);
|
| + Uri platform = c.options.platform;
|
| + if (platform != null) {
|
| + dillTarget.read(platform);
|
| + }
|
| + String argument = c.options.arguments.first;
|
| + Uri uri = Uri.base.resolve(argument);
|
| + String path = uriTranslator.translate(uri)?.path ?? argument;
|
| + if (path.endsWith(".dart")) {
|
| + kernelTarget.read(uri);
|
| + } else {
|
| + inputError(uri, -1, "Unexpected input: $uri");
|
| + }
|
| + await dillTarget.writeOutline(null);
|
| + await kernelTarget.writeOutline(output);
|
| + if (c.options.dumpIr && output != null) {
|
| + kernelTarget.dumpIr();
|
| + }
|
| + return kernelTarget;
|
| }
|
| - if (c.options.verify) {
|
| - try {
|
| - verifyProgram(kernelTarget.program);
|
| - ticker.logMs("Verified program");
|
| - } catch (e, s) {
|
| - exitCode = 1;
|
| - print("Verification of program failed: $e");
|
| - if (s != null && c.options.verbose) {
|
| - print(s);
|
| +
|
| + Future<Uri> compile() async {
|
| + KernelTarget kernelTarget = await buildOutline();
|
| + if (exitCode != 0) return null;
|
| + Uri uri = c.options.output;
|
| + await kernelTarget.writeProgram(uri);
|
| + if (c.options.dumpIr) {
|
| + kernelTarget.dumpIr();
|
| + }
|
| + if (c.options.verify) {
|
| + try {
|
| + verifyProgram(kernelTarget.program);
|
| + ticker.logMs("Verified program");
|
| + } catch (e, s) {
|
| + exitCode = 1;
|
| + print("Verification of program failed: $e");
|
| + if (s != null && c.options.verbose) {
|
| + print(s);
|
| + }
|
| }
|
| }
|
| + return uri;
|
| }
|
| - return uri;
|
| }
|
|
|