mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 14:51:30 +00:00
[vm/nnbd] Use NNBD flags from AsExpression, IsExpression
This is the VM-specific follow-up to https://dart-review.googlesource.com/c/sdk/+/133100 Change-Id: Iaa8728d2e0afebf421f9c65c3b3a48b286af5970 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134200 Reviewed-by: Régis Crelier <regis@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
a97c23b939
commit
e1e2604ff1
|
@ -3572,17 +3572,21 @@ Fragment StreamingFlowGraphBuilder::BuildIsExpression(TokenPosition* p) {
|
|||
TokenPosition position = ReadPosition(); // read position.
|
||||
if (p != NULL) *p = position;
|
||||
|
||||
NNBDMode nnbd_mode;
|
||||
if (translation_helper_.info().kernel_binary_version() >= 38) {
|
||||
// TODO(alexmarkov): Handle flags.
|
||||
ReadFlags(); // read flags.
|
||||
const uint8_t flags = ReadFlags(); // read flags.
|
||||
nnbd_mode = ((flags & kIsExpressionFlagForNonNullableByDefault) != 0)
|
||||
? NNBDMode::kOptedInLib
|
||||
: NNBDMode::kLegacyLib;
|
||||
} else {
|
||||
nnbd_mode = parsed_function()->function().nnbd_mode();
|
||||
}
|
||||
ASSERT(nnbd_mode == parsed_function()->function().nnbd_mode());
|
||||
|
||||
Fragment instructions = BuildExpression(); // read operand.
|
||||
|
||||
const AbstractType& type = T.BuildType(); // read type.
|
||||
|
||||
const NNBDMode nnbd_mode = parsed_function()->function().nnbd_mode();
|
||||
|
||||
// The VM does not like an instanceOf call with a dynamic type. We need to
|
||||
// special case this situation by detecting a top type.
|
||||
if (type.IsTopType(nnbd_mode)) {
|
||||
|
@ -3628,14 +3632,17 @@ Fragment StreamingFlowGraphBuilder::BuildAsExpression(TokenPosition* p) {
|
|||
TokenPosition position = ReadPosition(); // read position.
|
||||
if (p != NULL) *p = position;
|
||||
|
||||
// TODO(alexmarkov): Handle new flags.
|
||||
const uint8_t flags = ReadFlags(); // read flags.
|
||||
const bool is_type_error = (flags & (1 << 0)) != 0;
|
||||
const bool is_type_error = (flags & kAsExpressionFlagTypeError) != 0;
|
||||
const NNBDMode nnbd_mode =
|
||||
((flags & kAsExpressionFlagForNonNullableByDefault) != 0)
|
||||
? NNBDMode::kOptedInLib
|
||||
: NNBDMode::kLegacyLib;
|
||||
ASSERT(nnbd_mode == parsed_function()->function().nnbd_mode());
|
||||
|
||||
Fragment instructions = BuildExpression(); // read operand.
|
||||
|
||||
const AbstractType& type = T.BuildType(); // read type.
|
||||
const NNBDMode nnbd_mode = parsed_function()->function().nnbd_mode();
|
||||
if (type.IsInstantiated() && type.IsTopType(nnbd_mode)) {
|
||||
// We already evaluated the operand on the left and just leave it there as
|
||||
// the result of the `obj as dynamic` expression.
|
||||
|
|
|
@ -171,6 +171,19 @@ enum Variance {
|
|||
kLegacyCovariant = 4,
|
||||
};
|
||||
|
||||
// Keep in sync with package:kernel/lib/ast.dart
|
||||
enum AsExpressionFlags {
|
||||
kAsExpressionFlagTypeError = 1 << 0,
|
||||
kAsExpressionFlagCovarianceCheck = 1 << 1,
|
||||
kAsExpressionFlagForDynamic = 1 << 2,
|
||||
kAsExpressionFlagForNonNullableByDefault = 1 << 3,
|
||||
};
|
||||
|
||||
// Keep in sync with package:kernel/lib/ast.dart
|
||||
enum IsExpressionFlags {
|
||||
kIsExpressionFlagForNonNullableByDefault = 1 << 0,
|
||||
};
|
||||
|
||||
static const int SpecializedIntLiteralBias = 3;
|
||||
static const int LibraryCountFieldCountFromEnd = 1;
|
||||
static const int SourceTableFieldCountFromFirstLibraryOffset = 6;
|
||||
|
|
Loading…
Reference in a new issue