| 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 file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library fasta.outline; | 5 library fasta.outline; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 Future; | 8 Future; |
| 9 | 9 |
| 10 import 'dart:io' show | 10 import 'dart:io' show |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 import 'ticker.dart' show | 29 import 'ticker.dart' show |
| 30 Ticker; | 30 Ticker; |
| 31 | 31 |
| 32 import 'translate_uri.dart' show | 32 import 'translate_uri.dart' show |
| 33 TranslateUri; | 33 TranslateUri; |
| 34 | 34 |
| 35 import 'ast_kind.dart' show | 35 import 'ast_kind.dart' show |
| 36 AstKind; | 36 AstKind; |
| 37 | 37 |
| 38 // TODO(ahe): Remove this import. Instead make the SDK available as resource in |
| 39 // the executable, or something similar. |
| 40 import 'testing/kernel_chain.dart' show |
| 41 computePatchedSdk; |
| 42 |
| 38 CompilerCommandLine parseArguments(String programName, List<String> arguments) { | 43 CompilerCommandLine parseArguments(String programName, List<String> arguments) { |
| 39 return new CompilerCommandLine(programName, arguments); | 44 return new CompilerCommandLine(programName, arguments); |
| 40 } | 45 } |
| 41 | 46 |
| 42 Future<KernelSourceTarget> outline(List<String> arguments) async { | 47 Future<KernelSourceTarget> outline(List<String> arguments) async { |
| 43 try { | 48 try { |
| 44 CompilerCommandLine cl = parseArguments("outline", arguments); | 49 CompilerCommandLine cl = parseArguments("outline", arguments); |
| 45 if (cl.verbose) print("Building outlines for ${arguments.join(' ')}"); | 50 if (cl.verbose) print("Building outlines for ${arguments.join(' ')}"); |
| 46 return await doOutline(cl, new Ticker(isVerbose: cl.verbose), cl.output); | 51 return await doOutline(cl, new Ticker(isVerbose: cl.verbose), cl.output); |
| 47 } on InputError catch (e) { | 52 } on InputError catch (e) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 74 cl, new Ticker(isVerbose: cl.verbose), AstKind.Analyzer); | 79 cl, new Ticker(isVerbose: cl.verbose), AstKind.Analyzer); |
| 75 } on InputError catch (e) { | 80 } on InputError catch (e) { |
| 76 exitCode = 1; | 81 exitCode = 1; |
| 77 print(e.format()); | 82 print(e.format()); |
| 78 return null; | 83 return null; |
| 79 } | 84 } |
| 80 } | 85 } |
| 81 | 86 |
| 82 Future<KernelSourceTarget> doOutline(CompilerCommandLine cl, Ticker ticker, | 87 Future<KernelSourceTarget> doOutline(CompilerCommandLine cl, Ticker ticker, |
| 83 [Uri output]) async { | 88 [Uri output]) async { |
| 84 TranslateUri uriTranslator = await TranslateUri.parse(); | 89 Uri sdk = await computePatchedSdk(); |
| 90 ticker.logMs("Found patched SDK"); |
| 91 TranslateUri uriTranslator = await TranslateUri.parse(sdk); |
| 85 ticker.logMs("Read packages file"); | 92 ticker.logMs("Read packages file"); |
| 86 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); | 93 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); |
| 87 KernelSourceTarget sourceTarget = | 94 KernelSourceTarget sourceTarget = |
| 88 new KernelSourceTarget(dillTarget, uriTranslator); | 95 new KernelSourceTarget(dillTarget, uriTranslator); |
| 89 dillTarget.read(cl.platform); | 96 Uri platform = cl.platform; |
| 97 if (platform != null) { |
| 98 dillTarget.read(platform); |
| 99 } |
| 90 String argument = cl.arguments.first; | 100 String argument = cl.arguments.first; |
| 91 Uri uri = Uri.base.resolve(argument); | 101 Uri uri = Uri.base.resolve(argument); |
| 92 String path = uriTranslator.translate(uri)?.path ?? argument; | 102 String path = uriTranslator.translate(uri)?.path ?? argument; |
| 93 if (path.endsWith(".dart")) { | 103 if (path.endsWith(".dart")) { |
| 94 sourceTarget.read(uri); | 104 sourceTarget.read(uri); |
| 95 } else { | 105 } else { |
| 96 inputError(uri, -1, "Unexpected input: $uri"); | 106 inputError(uri, -1, "Unexpected input: $uri"); |
| 97 } | 107 } |
| 98 await dillTarget.writeOutline(null); | 108 await dillTarget.writeOutline(null); |
| 99 await sourceTarget.writeOutline(output); | 109 await sourceTarget.writeOutline(output); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 119 } catch (e, s) { | 129 } catch (e, s) { |
| 120 exitCode = 1; | 130 exitCode = 1; |
| 121 print("Verification of program failed: $e"); | 131 print("Verification of program failed: $e"); |
| 122 if (s != null && cl.verbose) { | 132 if (s != null && cl.verbose) { |
| 123 print(s); | 133 print(s); |
| 124 } | 134 } |
| 125 } | 135 } |
| 126 } | 136 } |
| 127 return uri; | 137 return uri; |
| 128 } | 138 } |
| OLD | NEW |