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

Side by Side Diff: pkg/front_end/lib/src/kernel_generator_impl.dart

Issue 2979623002: Use messages for (some) public API errors (Closed)
Patch Set: cl comments Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 /// Defines the front-end API for converting source code to Dart Kernel objects. 5 /// Defines the front-end API for converting source code to Dart Kernel objects.
6 library front_end.kernel_generator_impl; 6 library front_end.kernel_generator_impl;
7 7
8 import 'dart:async' show Future; 8 import 'dart:async' show Future;
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // program is destructive, so if we are emitting summaries and the 113 // program is destructive, so if we are emitting summaries and the
114 // program in a single API call, we would need to clone the program here 114 // program in a single API call, we would need to clone the program here
115 // to avoid deleting pieces that are needed by kernelTarget.buildProgram 115 // to avoid deleting pieces that are needed by kernelTarget.buildProgram
116 // below. 116 // below.
117 assert(!buildProgram); 117 assert(!buildProgram);
118 var excluded = 118 var excluded =
119 dillTarget.loader.libraries.map((lib) => lib.importUri).toSet(); 119 dillTarget.loader.libraries.map((lib) => lib.importUri).toSet();
120 trimProgram(summaryProgram, (uri) => !excluded.contains(uri)); 120 trimProgram(summaryProgram, (uri) => !excluded.contains(uri));
121 } 121 }
122 if (options.verify) { 122 if (options.verify) {
123 verifyProgram(summaryProgram).forEach((e) => options.reportError('$e')); 123 verifyProgram(summaryProgram).forEach(options.reportMessage);
124 } 124 }
125 if (options.debugDump) { 125 if (options.debugDump) {
126 printProgramText(summaryProgram, 126 printProgramText(summaryProgram,
127 libraryFilter: kernelTarget.isSourceLibrary); 127 libraryFilter: kernelTarget.isSourceLibrary);
128 } 128 }
129 if (kernelTarget.errors.isEmpty) { 129 if (kernelTarget.errors.isEmpty) {
130 summary = serializeProgram(summaryProgram, excludeUriToSource: true); 130 summary = serializeProgram(summaryProgram, excludeUriToSource: true);
131 } 131 }
132 options.ticker.logMs("Generated outline"); 132 options.ticker.logMs("Generated outline");
133 } 133 }
134 134
135 Program program; 135 Program program;
136 if (buildProgram && kernelTarget.errors.isEmpty) { 136 if (buildProgram && kernelTarget.errors.isEmpty) {
137 program = await kernelTarget.buildProgram(verify: options.verify); 137 program = await kernelTarget.buildProgram(verify: options.verify);
138 if (trimDependencies) { 138 if (trimDependencies) {
139 var excluded = 139 var excluded =
140 dillTarget.loader.libraries.map((lib) => lib.importUri).toSet(); 140 dillTarget.loader.libraries.map((lib) => lib.importUri).toSet();
141 trimProgram(program, (uri) => !excluded.contains(uri)); 141 trimProgram(program, (uri) => !excluded.contains(uri));
142 } 142 }
143 if (options.debugDump) { 143 if (options.debugDump) {
144 printProgramText(program, libraryFilter: kernelTarget.isSourceLibrary); 144 printProgramText(program, libraryFilter: kernelTarget.isSourceLibrary);
145 } 145 }
146 options.ticker.logMs("Generated program"); 146 options.ticker.logMs("Generated program");
147 } 147 }
148 148
149 if (kernelTarget.errors.isNotEmpty) { 149 if (kernelTarget.errors.isNotEmpty) {
150 kernelTarget.errors.forEach(options.reportError); 150 kernelTarget.errors.forEach(options.deprecated_reportError);
151 return null; 151 return null;
152 } 152 }
153 153
154 return new CompilerResult( 154 return new CompilerResult(
155 summary: summary, 155 summary: summary,
156 program: program, 156 program: program,
157 deps: kernelTarget.loader.getDependencies()); 157 deps: kernelTarget.loader.getDependencies());
158 } on deprecated_InputError catch (e) { 158 } on deprecated_InputError catch (e) {
159 options.reportError(e.deprecated_format()); 159 options.deprecated_reportError(e.deprecated_format());
160 return null; 160 return null;
161 } catch (e, t) { 161 } catch (e, t) {
162 return reportCrash(e, t); 162 return reportCrash(e, t);
163 } 163 }
164 } 164 }
165 165
166 /// Result object of [generateKernel]. 166 /// Result object of [generateKernel].
167 class CompilerResult { 167 class CompilerResult {
168 /// The generated summary bytes, if it was requested. 168 /// The generated summary bytes, if it was requested.
169 final List<int> summary; 169 final List<int> summary;
170 170
171 /// The generated program, if it was requested. 171 /// The generated program, if it was requested.
172 final Program program; 172 final Program program;
173 173
174 /// Dependencies traversed by the compiler. Used only for generating 174 /// Dependencies traversed by the compiler. Used only for generating
175 /// dependency .GN files in the dart-sdk build system. 175 /// dependency .GN files in the dart-sdk build system.
176 /// Note this might be removed when we switch to compute depencencies without 176 /// Note this might be removed when we switch to compute depencencies without
177 /// using the compiler itself. 177 /// using the compiler itself.
178 final List<Uri> deps; 178 final List<Uri> deps;
179 179
180 CompilerResult({this.summary, this.program, this.deps}); 180 CompilerResult({this.summary, this.program, this.deps});
181 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698