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

Unified Diff: pkg/front_end/lib/kernel_generator.dart

Issue 2982093003: Unifying compiler context (Closed)
Patch Set: revert change to kernel-service.dart 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/kernel_generator.dart
diff --git a/pkg/front_end/lib/kernel_generator.dart b/pkg/front_end/lib/kernel_generator.dart
index 3ffac6bf2c592806951a39d9380d5923ec4aa923..aae71f0544e238124769d4873fecbc0ca50b6d6d 100644
--- a/pkg/front_end/lib/kernel_generator.dart
+++ b/pkg/front_end/lib/kernel_generator.dart
@@ -13,6 +13,8 @@ import 'package:kernel/kernel.dart' show Program;
import 'compiler_options.dart';
import 'src/base/processed_options.dart';
import 'src/fasta/fasta_codes.dart';
+import 'src/fasta/compiler_context.dart';
+import 'src/fasta/severity.dart';
import 'src/kernel_generator_impl.dart';
/// Generates a kernel representation of the program whose main library is in
@@ -37,15 +39,17 @@ import 'src/kernel_generator_impl.dart';
// TODO(sigmund): rename to kernelForScript?
Future<Program> kernelForProgram(Uri source, CompilerOptions options) async {
var pOptions = new ProcessedOptions(options, false, [source]);
- var program = (await generateKernel(pOptions))?.program;
- if (program == null) return null;
+ return await CompilerContext.runWithOptions(pOptions, (context) async {
+ var program = (await generateKernelInternal())?.program;
+ if (program == null) return null;
- if (program.mainMethod == null) {
- pOptions.reportMessage(messageMissingMain.withLocation(source, -1));
- return null;
- }
-
- return program;
+ if (program.mainMethod == null) {
+ context.options
+ .report(messageMissingMain.withLocation(source, -1), Severity.error);
+ return null;
+ }
+ return program;
+ });
}
/// Generates a kernel representation for a build unit containing [sources].

Powered by Google App Engine
This is Rietveld 408576698