Files
sdk/pkg/vm/lib/constants_error_reporter.dart
T
Aske Simon Christensen 1ea717f1c9 [CFE] Use Fasta diagnostics in constant evaluator.
The constant evaluator now generates all errors as Fasta diagnostic
messages. The ErrorReporter is simplified to just accept a diagnostic
message, or a notification that the constant evaluator encountered an
invalid expression (presumably put there due to an earlier error).

Also, the flow of control between the error reporter and the internal
abort exceptions is reversed, so the error reporter is now called as a
result of an abort exception being caught by the evaluate method.

Reland of https://dart-review.googlesource.com/c/sdk/+/96300

Change-Id: I7d32b6e98962b6ee781a6c96b593b00ee7fd8a89
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97225
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
2019-03-18 15:42:05 +00:00

32 lines
1.2 KiB
Dart

// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// Defines [ForwardConstantEvaluationErrors], an implementation of
/// [constants.ErrorReporter] which uses package:front_end to report errors.
library vm.constants_error_reporter;
import 'package:front_end/src/api_prototype/constant_evaluator.dart'
as constants;
import 'package:front_end/src/api_unstable/vm.dart'
show CompilerContext, LocatedMessage, Severity;
import 'package:kernel/ast.dart' show InvalidExpression;
class ForwardConstantEvaluationErrors implements constants.ErrorReporter {
// This will get the currently active [CompilerContext] from a zone variable.
// If there is no active context, this will throw.
final CompilerContext compilerContext = CompilerContext.current;
@override
void report(LocatedMessage message, List<LocatedMessage> context) {
compilerContext.options.report(message, Severity.error, context: context);
}
@override
void reportInvalidExpression(InvalidExpression node) {
// Assumed to be already reported.
}
}