Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Side by Side Diff: pkg/front_end/lib/src/fasta/outline.dart

Issue 2704753002: Implement line and column numbers. (Closed)
Patch Set: Change message. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/front_end/lib/src/fasta/messages.dart ('k') | pkg/front_end/lib/src/fasta/run.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 exitCode; 11 exitCode;
12 12
13 import 'package:kernel/verifier.dart' show 13 import 'package:kernel/verifier.dart' show
14 verifyProgram; 14 verifyProgram;
15 15
16 import 'compiler_command_line.dart' show 16 import 'compiler_command_line.dart' show
17 CompilerCommandLine; 17 CompilerCommandLine;
18 18
19 import 'compiler_context.dart' show
20 CompilerContext;
21
19 import 'errors.dart' show 22 import 'errors.dart' show
20 InputError, 23 InputError,
21 inputError; 24 inputError;
22 25
23 import 'kernel/kernel_target.dart' show 26 import 'kernel/kernel_target.dart' show
24 KernelTarget; 27 KernelTarget;
25 28
26 import 'dill/dill_target.dart' show 29 import 'dill/dill_target.dart' show
27 DillTarget; 30 DillTarget;
28 31
29 import 'ticker.dart' show 32 import 'ticker.dart' show
30 Ticker; 33 Ticker;
31 34
32 import 'translate_uri.dart' show 35 import 'translate_uri.dart' show
33 TranslateUri; 36 TranslateUri;
34 37
35 import 'ast_kind.dart' show 38 import 'ast_kind.dart' show
36 AstKind; 39 AstKind;
37 40
38 // TODO(ahe): Remove this import. Instead make the SDK available as resource in 41 // TODO(ahe): Remove this import. Instead make the SDK available as resource in
39 // the executable, or something similar. 42 // the executable, or something similar.
40 import 'testing/kernel_chain.dart' show 43 import 'testing/kernel_chain.dart' show
41 computePatchedSdk; 44 computePatchedSdk;
42 45
43 CompilerCommandLine parseArguments(String programName, List<String> arguments) {
44 return new CompilerCommandLine(programName, arguments);
45 }
46
47 Future<KernelTarget> outline(List<String> arguments) async { 46 Future<KernelTarget> outline(List<String> arguments) async {
48 try { 47 try {
49 CompilerCommandLine cl = parseArguments("outline", arguments); 48 return await CompilerCommandLine.withGlobalOptions(
50 if (cl.verbose) print("Building outlines for ${arguments.join(' ')}"); 49 "outline", arguments, (CompilerContext c) async {
51 return await doOutline(cl, new Ticker(isVerbose: cl.verbose), cl.output); 50 if (c.options.verbose) {
51 print("Building outlines for ${arguments.join(' ')}");
52 }
53 return await doOutline(c, new Ticker(isVerbose: c.options.verbose),
54 c.options.output);
55 });
52 } on InputError catch (e) { 56 } on InputError catch (e) {
53 exitCode = 1; 57 exitCode = 1;
54 print(e.format()); 58 print(e.format());
55 return null; 59 return null;
56 } 60 }
57 } 61 }
58 62
59 Future<Uri> compile(List<String> arguments) async { 63 Future<Uri> compile(List<String> arguments) async {
60 try { 64 try {
61 CompilerCommandLine cl = parseArguments("compile", arguments); 65 return await CompilerCommandLine.withGlobalOptions(
62 if (cl.verbose) { 66 "compile", arguments, (CompilerContext c) async {
63 print("Compiling directly to Kernel: ${arguments.join(' ')}"); 67 if (c.options.verbose) {
64 } 68 print("Compiling directly to Kernel: ${arguments.join(' ')}");
65 return 69 }
66 await doCompile(cl, new Ticker(isVerbose: cl.verbose), AstKind.Kernel); 70 return await doCompile(c, new Ticker(isVerbose: c.options.verbose),
71 AstKind.Kernel);
72 });
67 } on InputError catch (e) { 73 } on InputError catch (e) {
68 exitCode = 1; 74 exitCode = 1;
69 print(e.format()); 75 print(e.format());
70 return null; 76 return null;
71 } 77 }
72 } 78 }
73 79
74 Future<Uri> kompile(List<String> arguments) async { 80 Future<Uri> kompile(List<String> arguments) async {
75 try { 81 try {
76 CompilerCommandLine cl = parseArguments("kompile", arguments); 82 return await CompilerCommandLine.withGlobalOptions(
77 if (cl.verbose) print("Compiling via analyzer: ${arguments.join(' ')}"); 83 "kompile", arguments, (CompilerContext c) async {
78 return await doCompile( 84 if (c.options.verbose) {
79 cl, new Ticker(isVerbose: cl.verbose), AstKind.Analyzer); 85 print("Compiling via analyzer: ${arguments.join(' ')}");
86 }
87 return await doCompile(c, new Ticker(isVerbose: c.options.verbose),
88 AstKind.Analyzer);
89 });
80 } on InputError catch (e) { 90 } on InputError catch (e) {
81 exitCode = 1; 91 exitCode = 1;
82 print(e.format()); 92 print(e.format());
83 return null; 93 return null;
84 } 94 }
85 } 95 }
86 96
87 Future<KernelTarget> doOutline(CompilerCommandLine cl, Ticker ticker, 97 Future<KernelTarget> doOutline(CompilerContext c, Ticker ticker,
88 [Uri output]) async { 98 [Uri output]) async {
89 Uri sdk = await computePatchedSdk(); 99 Uri sdk = await computePatchedSdk();
90 ticker.logMs("Found patched SDK"); 100 ticker.logMs("Found patched SDK");
91 TranslateUri uriTranslator = await TranslateUri.parse(sdk); 101 TranslateUri uriTranslator = await TranslateUri.parse(sdk);
92 ticker.logMs("Read packages file"); 102 ticker.logMs("Read packages file");
93 DillTarget dillTarget = new DillTarget(ticker, uriTranslator); 103 DillTarget dillTarget = new DillTarget(ticker, uriTranslator);
94 KernelTarget kernelTarget = new KernelTarget(dillTarget, uriTranslator); 104 KernelTarget kernelTarget =
95 Uri platform = cl.platform; 105 new KernelTarget(dillTarget, uriTranslator, c.uriToSource);
106 Uri platform = c.options.platform;
96 if (platform != null) { 107 if (platform != null) {
97 dillTarget.read(platform); 108 dillTarget.read(platform);
98 } 109 }
99 String argument = cl.arguments.first; 110 String argument = c.options.arguments.first;
100 Uri uri = Uri.base.resolve(argument); 111 Uri uri = Uri.base.resolve(argument);
101 String path = uriTranslator.translate(uri)?.path ?? argument; 112 String path = uriTranslator.translate(uri)?.path ?? argument;
102 if (path.endsWith(".dart")) { 113 if (path.endsWith(".dart")) {
103 kernelTarget.read(uri); 114 kernelTarget.read(uri);
104 } else { 115 } else {
105 inputError(uri, -1, "Unexpected input: $uri"); 116 inputError(uri, -1, "Unexpected input: $uri");
106 } 117 }
107 await dillTarget.writeOutline(null); 118 await dillTarget.writeOutline(null);
108 await kernelTarget.writeOutline(output); 119 await kernelTarget.writeOutline(output);
109 if (cl.dumpIr && output != null) { 120 if (c.options.dumpIr && output != null) {
110 kernelTarget.dumpIr(); 121 kernelTarget.dumpIr();
111 } 122 }
112 return kernelTarget; 123 return kernelTarget;
113 } 124 }
114 125
115 Future<Uri> doCompile(CompilerCommandLine cl, Ticker ticker, 126 Future<Uri> doCompile(CompilerContext c, Ticker ticker, AstKind kind) async {
116 AstKind kind) async { 127 KernelTarget kernelTarget = await doOutline(c, ticker);
117 KernelTarget kernelTarget = await doOutline(cl, ticker);
118 if (exitCode != 0) return null; 128 if (exitCode != 0) return null;
119 Uri uri = cl.output; 129 Uri uri = c.options.output;
120 await kernelTarget.writeProgram(uri, kind); 130 await kernelTarget.writeProgram(uri, kind);
121 if (cl.dumpIr) { 131 if (c.options.dumpIr) {
122 kernelTarget.dumpIr(); 132 kernelTarget.dumpIr();
123 } 133 }
124 if (cl.verify) { 134 if (c.options.verify) {
125 try { 135 try {
126 verifyProgram(kernelTarget.program); 136 verifyProgram(kernelTarget.program);
127 ticker.logMs("Verified program"); 137 ticker.logMs("Verified program");
128 } catch (e, s) { 138 } catch (e, s) {
129 exitCode = 1; 139 exitCode = 1;
130 print("Verification of program failed: $e"); 140 print("Verification of program failed: $e");
131 if (s != null && cl.verbose) { 141 if (s != null && c.options.verbose) {
132 print(s); 142 print(s);
133 } 143 }
134 } 144 }
135 } 145 }
136 return uri; 146 return uri;
137 } 147 }
OLDNEW
« no previous file with comments | « pkg/front_end/lib/src/fasta/messages.dart ('k') | pkg/front_end/lib/src/fasta/run.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698