[cfe,vm,dart2bytecode] Rename Variable into BaseVariable, ExpressionVariable into Variable
This is a follow-up to https://dart-review.googlesource.com/c/sdk/+/487381/comment/3eb20545_b37553c4/ Part of https://github.com/dart-lang/sdk/issues/61572 TEST=existing Change-Id: I15c7438dcec3d412f3050d3d80517d5cff5b515f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487800 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
committed by
Commit Queue
parent
1c02dda063
commit
67b3b0709f
@@ -1482,7 +1482,7 @@ class BytecodeGenerator extends RecursiveVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
void _genPushContextForVariable(ExpressionVariable variable,
|
||||
void _genPushContextForVariable(Variable variable,
|
||||
{int? currentContextLevel}) {
|
||||
currentContextLevel ??= locals.currentContextLevel;
|
||||
int depth = currentContextLevel - locals.getContextLevelOfVar(variable);
|
||||
@@ -1496,13 +1496,13 @@ class BytecodeGenerator extends RecursiveVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
void _genPushContextIfCaptured(ExpressionVariable variable) {
|
||||
void _genPushContextIfCaptured(Variable variable) {
|
||||
if (locals.isCaptured(variable)) {
|
||||
_genPushContextForVariable(variable);
|
||||
}
|
||||
}
|
||||
|
||||
void _genLoadVar(ExpressionVariable v, {int? currentContextLevel}) {
|
||||
void _genLoadVar(Variable v, {int? currentContextLevel}) {
|
||||
if (locals.isCaptured(v)) {
|
||||
_genPushContextForVariable(v, currentContextLevel: currentContextLevel);
|
||||
asm.emitLoadContextVar(
|
||||
@@ -1520,7 +1520,7 @@ class BytecodeGenerator extends RecursiveVisitor {
|
||||
|
||||
// Stores value into variable.
|
||||
// If variable is captured, context should be pushed before value.
|
||||
void _genStoreVar(ExpressionVariable variable) {
|
||||
void _genStoreVar(Variable variable) {
|
||||
if (locals.isCaptured(variable)) {
|
||||
asm.emitStoreContextVar(locals.getVarContextId(variable),
|
||||
locals.getVarIndexInContext(variable));
|
||||
@@ -2184,7 +2184,7 @@ class BytecodeGenerator extends RecursiveVisitor {
|
||||
}
|
||||
|
||||
void _declareLocalVariable(
|
||||
ExpressionVariable variable, int initializedPosition) {
|
||||
Variable variable, int initializedPosition) {
|
||||
bool isCaptured = locals.isCaptured(variable);
|
||||
asm.localVariableTable.declareVariable(
|
||||
asm.offset,
|
||||
|
||||
@@ -12,7 +12,7 @@ import 'options.dart' show BytecodeOptions;
|
||||
|
||||
class LocalVariables {
|
||||
final _scopes = new Map<TreeNode, Scope>();
|
||||
final _vars = new Map<ExpressionVariable, VarDesc>();
|
||||
final _vars = new Map<Variable, VarDesc>();
|
||||
Map<TreeNode, List<int>>? _temps;
|
||||
Map<TreeNode, VariableDeclaration>? _capturedSavedContextVars;
|
||||
Map<TreeNode, VariableDeclaration>? _capturedExceptionVars;
|
||||
@@ -27,11 +27,11 @@ class LocalVariables {
|
||||
Frame? _currentFrameInternal;
|
||||
Frame get _currentFrame => _currentFrameInternal!;
|
||||
|
||||
VarDesc _getVarDesc(ExpressionVariable variable) =>
|
||||
VarDesc _getVarDesc(Variable variable) =>
|
||||
_vars[variable] ??
|
||||
(throw 'Variable descriptor is not created for $variable');
|
||||
|
||||
int _getVarIndex(ExpressionVariable variable, bool isCaptured) {
|
||||
int _getVarIndex(Variable variable, bool isCaptured) {
|
||||
final v = _getVarDesc(variable);
|
||||
if (v.isCaptured != isCaptured) {
|
||||
throw 'Mismatch in captured state of $variable';
|
||||
@@ -39,13 +39,13 @@ class LocalVariables {
|
||||
return v.index ?? (throw 'Variable $variable is not allocated');
|
||||
}
|
||||
|
||||
bool isCaptured(ExpressionVariable variable) =>
|
||||
bool isCaptured(Variable variable) =>
|
||||
_getVarDesc(variable).isCaptured;
|
||||
|
||||
int getVarIndexInFrame(ExpressionVariable variable) =>
|
||||
int getVarIndexInFrame(Variable variable) =>
|
||||
_getVarIndex(variable, false);
|
||||
|
||||
int getVarIndexInContext(ExpressionVariable variable) =>
|
||||
int getVarIndexInContext(Variable variable) =>
|
||||
_getVarIndex(variable, true);
|
||||
|
||||
int getOriginalParamSlotIndex(VariableDeclaration variable) =>
|
||||
@@ -72,13 +72,13 @@ class LocalVariables {
|
||||
_currentFrame.contextLevelAtEntry ??
|
||||
(throw "Current frame is top level and it doesn't have a context at entry");
|
||||
|
||||
int getContextLevelOfVar(ExpressionVariable variable) {
|
||||
int getContextLevelOfVar(Variable variable) {
|
||||
final v = _getVarDesc(variable);
|
||||
assert(v.isCaptured);
|
||||
return v.scope.contextLevel!;
|
||||
}
|
||||
|
||||
int getVarContextId(ExpressionVariable variable) {
|
||||
int getVarContextId(Variable variable) {
|
||||
final v = _getVarDesc(variable);
|
||||
assert(v.isCaptured);
|
||||
return v.scope.contextId!;
|
||||
@@ -192,7 +192,7 @@ class LocalVariables {
|
||||
}
|
||||
|
||||
class VarDesc {
|
||||
final ExpressionVariable declaration;
|
||||
final Variable declaration;
|
||||
Scope scope;
|
||||
bool isCaptured = false;
|
||||
int? index;
|
||||
@@ -463,7 +463,7 @@ class _ScopeBuilder extends RecursiveVisitor {
|
||||
_currentScopeInternal = _currentScope.parent;
|
||||
}
|
||||
|
||||
void _declareVariable(ExpressionVariable variable, [Scope? scope]) {
|
||||
void _declareVariable(Variable variable, [Scope? scope]) {
|
||||
if (scope == null) {
|
||||
scope = _currentScope;
|
||||
}
|
||||
@@ -473,7 +473,7 @@ class _ScopeBuilder extends RecursiveVisitor {
|
||||
locals._vars[variable] = v;
|
||||
}
|
||||
|
||||
void _useVariable(ExpressionVariable variable) {
|
||||
void _useVariable(Variable variable) {
|
||||
final VarDesc? v = locals._vars[variable];
|
||||
if (v == null) {
|
||||
throw 'Variable $variable is used before declared';
|
||||
@@ -850,7 +850,7 @@ class _Allocator extends RecursiveVisitor {
|
||||
_currentScope.tempsUsed, _currentScope.tempsUsed + count)));
|
||||
}
|
||||
|
||||
void _allocateVariable(ExpressionVariable variable, {int? paramSlotIndex}) {
|
||||
void _allocateVariable(Variable variable, {int? paramSlotIndex}) {
|
||||
final VarDesc v = locals._getVarDesc(variable);
|
||||
|
||||
assert(!v.isAllocated);
|
||||
@@ -889,7 +889,7 @@ class _Allocator extends RecursiveVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
void _allocateParameter(ExpressionVariable node, int i) {
|
||||
void _allocateParameter(Variable node, int i) {
|
||||
final numParameters = _currentFrame.numParameters;
|
||||
assert(0 <= i && i < numParameters);
|
||||
assert(_currentScope.localsUsed ==
|
||||
|
||||
@@ -701,7 +701,7 @@ String extractLocalNameFromLateLoweredSetter(String name) {
|
||||
/// int Extension|method(int #this) => #this;
|
||||
///
|
||||
/// where '#this' is the synthetic "extension this" parameter.
|
||||
bool isExtensionThis(ExpressionVariable node) {
|
||||
bool isExtensionThis(Variable node) {
|
||||
assert(
|
||||
node.isLowered ||
|
||||
node.cosmeticName == null ||
|
||||
|
||||
@@ -35,7 +35,7 @@ import 'package:kernel/kernel.dart'
|
||||
DartType,
|
||||
DynamicType,
|
||||
Expression,
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
ExtensionType,
|
||||
Field,
|
||||
FunctionNode,
|
||||
@@ -2595,7 +2595,7 @@ class ExpressionEvaluationHelperImpl implements ExpressionEvaluationHelper {
|
||||
|
||||
ExpressionInferenceResult _returnKnownVariableUnavailable(
|
||||
Expression node,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
ProblemReporting problemReporting,
|
||||
CompilerContext compilerContext,
|
||||
Uri fileUri,
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'package:kernel/ast.dart'
|
||||
NamedParameter,
|
||||
NullLiteral,
|
||||
PositionalParameter,
|
||||
Variable,
|
||||
VariableBase,
|
||||
VariableDeclaration;
|
||||
import 'package:kernel/class_hierarchy.dart';
|
||||
|
||||
@@ -68,7 +68,7 @@ abstract class ParameterBuilder {
|
||||
|
||||
int get fileOffset;
|
||||
|
||||
Variable build(SourceLibraryBuilder library);
|
||||
VariableBase build(SourceLibraryBuilder library);
|
||||
}
|
||||
|
||||
abstract class ParameterVariableBuilder
|
||||
@@ -492,7 +492,7 @@ class FunctionTypeParameterBuilder implements ParameterBuilder {
|
||||
}
|
||||
|
||||
@override
|
||||
Variable build(SourceLibraryBuilder library) {
|
||||
VariableBase build(SourceLibraryBuilder library) {
|
||||
throw new UnsupportedError("${this.runtimeType}.build");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
// 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.
|
||||
|
||||
import 'package:kernel/ast.dart' show ExpressionVariable;
|
||||
import 'package:kernel/ast.dart' show Variable;
|
||||
|
||||
import '../base/lookup_result.dart';
|
||||
import '../builder/builder.dart';
|
||||
|
||||
abstract class VariableBuilder implements Builder, LookupResult {
|
||||
ExpressionVariable get variable;
|
||||
Variable get variable;
|
||||
|
||||
bool get isConst;
|
||||
|
||||
|
||||
@@ -6,11 +6,10 @@ import 'package:_fe_analyzer_shared/src/type_inference/assigned_variables.dart';
|
||||
import 'package:_fe_analyzer_shared/src/type_inference/promotion_key_store.dart';
|
||||
import 'package:kernel/ast.dart';
|
||||
|
||||
class AssignedVariablesImpl
|
||||
implements AssignedVariables<TreeNode, ExpressionVariable> {
|
||||
final AssignedVariables<TreeNode, ExpressionVariable> _delegate;
|
||||
final AssignedVariables<TreeNode, ExpressionVariable>? _insideAsserts;
|
||||
final AssignedVariables<TreeNode, ExpressionVariable>? _outsideAsserts;
|
||||
class AssignedVariablesImpl implements AssignedVariables<TreeNode, Variable> {
|
||||
final AssignedVariables<TreeNode, Variable> _delegate;
|
||||
final AssignedVariables<TreeNode, Variable>? _insideAsserts;
|
||||
final AssignedVariables<TreeNode, Variable>? _outsideAsserts;
|
||||
int _assertDepth = 0;
|
||||
final Map<AssignedVariablesNodeInfo, AssignedVariablesNodeInfo>?
|
||||
_deferredInsideAssertsByDeferredDelegate;
|
||||
@@ -21,10 +20,10 @@ class AssignedVariablesImpl
|
||||
this._delegate, {
|
||||
required bool isClosureContextLoweringEnabled,
|
||||
}) : _insideAsserts = isClosureContextLoweringEnabled
|
||||
? new AssignedVariables<TreeNode, ExpressionVariable>()
|
||||
? new AssignedVariables<TreeNode, Variable>()
|
||||
: null,
|
||||
_outsideAsserts = isClosureContextLoweringEnabled
|
||||
? new AssignedVariables<TreeNode, ExpressionVariable>()
|
||||
? new AssignedVariables<TreeNode, Variable>()
|
||||
: null,
|
||||
_deferredInsideAssertsByDeferredDelegate =
|
||||
isClosureContextLoweringEnabled
|
||||
@@ -72,7 +71,7 @@ class AssignedVariablesImpl
|
||||
}
|
||||
|
||||
@override
|
||||
void declare(ExpressionVariable variable, {bool ignoreDuplicates = false}) {
|
||||
void declare(Variable variable, {bool ignoreDuplicates = false}) {
|
||||
_delegate.declare(variable, ignoreDuplicates: ignoreDuplicates);
|
||||
_insideAsserts?.declare(variable, ignoreDuplicates: ignoreDuplicates);
|
||||
_outsideAsserts?.declare(variable, ignoreDuplicates: ignoreDuplicates);
|
||||
@@ -153,7 +152,7 @@ class AssignedVariablesImpl
|
||||
}
|
||||
|
||||
@override
|
||||
PromotionKeyStore<ExpressionVariable> get promotionKeyStore {
|
||||
PromotionKeyStore<Variable> get promotionKeyStore {
|
||||
return _delegate.promotionKeyStore;
|
||||
}
|
||||
|
||||
@@ -165,7 +164,7 @@ class AssignedVariablesImpl
|
||||
}
|
||||
|
||||
@override
|
||||
void read(ExpressionVariable variable) {
|
||||
void read(Variable variable) {
|
||||
_delegate.read(variable);
|
||||
if (_isInsideAssert) {
|
||||
_insideAsserts?.read(variable);
|
||||
@@ -203,7 +202,7 @@ class AssignedVariablesImpl
|
||||
}
|
||||
|
||||
@override
|
||||
void write(ExpressionVariable variable) {
|
||||
void write(Variable variable) {
|
||||
_delegate.write(variable);
|
||||
if (_isInsideAssert) {
|
||||
// Coverage-ignore-block(suite): Not run.
|
||||
|
||||
@@ -170,7 +170,7 @@ abstract class BodyBuilder {
|
||||
|
||||
BuildSingleExpressionResult buildSingleExpression({
|
||||
required Token token,
|
||||
required List<ExpressionVariable> extraKnownVariables,
|
||||
required List<Variable> extraKnownVariables,
|
||||
required List<NominalParameterBuilder>? typeParameterBuilders,
|
||||
required List<FormalParameterBuilder>? formals,
|
||||
required int fileOffset,
|
||||
@@ -344,7 +344,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
|
||||
final LocalStack<LocalScope> _localScopes;
|
||||
|
||||
Set<ExpressionVariable>? declaredInCurrentGuard;
|
||||
Set<Variable>? declaredInCurrentGuard;
|
||||
|
||||
JumpTarget? breakTarget;
|
||||
|
||||
@@ -386,7 +386,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
assignedVariables.declare(
|
||||
(builder.variable as InternalExpressionVariable).astVariable,
|
||||
(builder.variable as InternalVariable).astVariable,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -395,9 +395,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
// constructors.
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
assignedVariables.declare(
|
||||
(thisVariable as InternalExpressionVariable).astVariable,
|
||||
);
|
||||
assignedVariables.declare((thisVariable as InternalVariable).astVariable);
|
||||
}
|
||||
if (isClosureContextLoweringEnabled && _internalThisVariable != null) {
|
||||
assignedVariables.declare(_internalThisVariable!);
|
||||
@@ -634,12 +632,12 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
}
|
||||
|
||||
@override
|
||||
void registerVariableAssignment(ExpressionVariable variable) {
|
||||
void registerVariableAssignment(Variable variable) {
|
||||
// TODO(cstefantsova): Always pass [variable] to [assignedVariables.write]
|
||||
// when [InferenceVisitorBase.flowAnalysis] will use
|
||||
// [InternalExpressionVariable] instead of [ExpressionVariable] (that is,
|
||||
// pass it for the `Variable` type parameter of [FlowAnalysis]).
|
||||
if (variable case InternalExpressionVariable variable) {
|
||||
if (variable case InternalVariable variable) {
|
||||
assignedVariables.write(variable.astVariable);
|
||||
} else {
|
||||
// Coverage-ignore-block(suite): Not run.
|
||||
@@ -832,7 +830,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
}
|
||||
|
||||
void wrapVariableInitializerInError(
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
List<LocatedMessage> context,
|
||||
) {
|
||||
String name = variable.cosmeticName!;
|
||||
@@ -856,7 +854,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
}
|
||||
}
|
||||
|
||||
void declareVariable(ExpressionVariable variable, LocalScope scope) {
|
||||
void declareVariable(Variable variable, LocalScope scope) {
|
||||
String name = variable.cosmeticName!;
|
||||
Builder? existing = scope.lookupLocalVariable(name);
|
||||
if (existing != null) {
|
||||
@@ -2509,8 +2507,8 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
}
|
||||
|
||||
@override
|
||||
void registerVariableRead(ExpressionVariable variable) {
|
||||
if (variable case InternalExpressionVariable variable) {
|
||||
void registerVariableRead(Variable variable) {
|
||||
if (variable case InternalVariable variable) {
|
||||
if (!variable.isLocalFunction && !variable.isWildcard) {
|
||||
assignedVariables.read(variable.astVariable);
|
||||
}
|
||||
@@ -2525,7 +2523,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
/// Helper method to create a [VariableGet] of the [variable] using
|
||||
/// [charOffset] as the file offset.
|
||||
@override
|
||||
VariableGet createVariableGet(ExpressionVariable variable, int charOffset) {
|
||||
VariableGet createVariableGet(Variable variable, int charOffset) {
|
||||
registerVariableRead(variable);
|
||||
return new VariableGet(variable)..fileOffset = charOffset;
|
||||
}
|
||||
@@ -2534,7 +2532,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
/// using [token] and [charOffset] for offset information and [name]
|
||||
/// for `ExpressionGenerator._plainNameForRead`.
|
||||
ReadOnlyAccessGenerator _createReadOnlyVariableAccess(
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Token token,
|
||||
int charOffset,
|
||||
String? name,
|
||||
@@ -2550,7 +2548,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
}
|
||||
|
||||
@override
|
||||
bool isDeclaredInEnclosingCase(ExpressionVariable variable) {
|
||||
bool isDeclaredInEnclosingCase(Variable variable) {
|
||||
return declaredInCurrentGuard?.contains(variable) ?? false;
|
||||
}
|
||||
|
||||
@@ -2685,7 +2683,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
diag.notAConstantExpression,
|
||||
);
|
||||
}
|
||||
ExpressionVariable variable = getable.variable;
|
||||
Variable variable = getable.variable;
|
||||
if (forStatementScope &&
|
||||
getable.isAssignable &&
|
||||
getable.isLate &&
|
||||
@@ -3345,7 +3343,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
assignedVariables.storeInfo(
|
||||
(node.variable as InternalExpressionVariable).astVariable,
|
||||
(node.variable as InternalVariable).astVariable,
|
||||
assignedVariablesInfo!,
|
||||
);
|
||||
}
|
||||
@@ -3398,7 +3396,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
wildcardVariableIndex++;
|
||||
}
|
||||
VariableInitialization variableInitialization;
|
||||
InternalExpressionVariable internalVariable;
|
||||
InternalVariable internalVariable;
|
||||
if (isClosureContextLoweringEnabled) {
|
||||
internalVariable = new InternalLocalVariable(
|
||||
astVariable: new LocalVariable(
|
||||
@@ -5459,7 +5457,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
}
|
||||
}
|
||||
|
||||
ExpressionVariable functionParameter;
|
||||
Variable functionParameter;
|
||||
if (memberKind == MemberKind.Catch) {
|
||||
functionParameter = (parameter as CatchParameterBuilder).build(
|
||||
libraryBuilder,
|
||||
@@ -5510,7 +5508,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
assignedVariables.declare(
|
||||
(functionParameter as InternalExpressionVariable).astVariable,
|
||||
(functionParameter as InternalVariable).astVariable,
|
||||
ignoreDuplicates: true,
|
||||
);
|
||||
}
|
||||
@@ -8147,7 +8145,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
null,
|
||||
);
|
||||
assignedVariables.pushNode(assignedVariablesNodeInfo);
|
||||
ExpressionVariable variable = elements.variable;
|
||||
Variable variable = elements.variable;
|
||||
Expression? problem = elements.expressionProblem;
|
||||
if (entry is MapLiteralEntry) {
|
||||
ForInMapEntry result = forest.createForInMapEntry(
|
||||
@@ -8218,7 +8216,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
// constant evaluator further in the pipeline.
|
||||
lvalue.isConst = false;
|
||||
}
|
||||
} else if (lvalue is ExpressionVariable) {
|
||||
} else if (lvalue is Variable) {
|
||||
// Coverage-ignore-block(suite): Not run.
|
||||
// Late for-in variables are not supported. An error has already been
|
||||
// reported by the parser.
|
||||
@@ -8236,7 +8234,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
lvalue.isConst = false;
|
||||
}
|
||||
} else {
|
||||
ExpressionVariable astVariable = isClosureContextLoweringEnabled
|
||||
Variable astVariable = isClosureContextLoweringEnabled
|
||||
? new SyntheticVariable(type: const DynamicType())
|
||||
: forest.createVariableDeclaration(
|
||||
offsetForToken(forToken),
|
||||
@@ -8245,7 +8243,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
isSynthesized: true,
|
||||
);
|
||||
|
||||
ExpressionVariable variable = elements.syntheticVariableDeclaration =
|
||||
Variable variable = elements.syntheticVariableDeclaration =
|
||||
isClosureContextLoweringEnabled
|
||||
? new InternalSyntheticVariable(
|
||||
astVariable: astVariable as SyntheticVariable,
|
||||
@@ -8394,7 +8392,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
lvalue,
|
||||
body,
|
||||
);
|
||||
ExpressionVariable variable = elements.variable;
|
||||
Variable variable = elements.variable;
|
||||
Expression? problem = elements.expressionProblem;
|
||||
Statement forInStatement;
|
||||
if (elements.explicitVariableDeclaration != null) {
|
||||
@@ -11476,7 +11474,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
// Coverage-ignore(suite): Not run.
|
||||
BuildSingleExpressionResult buildSingleExpression({
|
||||
required Token token,
|
||||
required List<ExpressionVariable> extraKnownVariables,
|
||||
required List<Variable> extraKnownVariables,
|
||||
required List<NominalParameterBuilder>? typeParameterBuilders,
|
||||
required List<FormalParameterBuilder>? formals,
|
||||
required int fileOffset,
|
||||
@@ -11513,7 +11511,7 @@ class BodyBuilderImpl extends StackListenerImpl
|
||||
kind: LocalScopeKind.ifElement,
|
||||
);
|
||||
enterLocalScope(extraKnownVariablesScope);
|
||||
for (ExpressionVariable extraVariable in extraKnownVariables) {
|
||||
for (Variable extraVariable in extraKnownVariables) {
|
||||
declareVariable(extraVariable, _localScope);
|
||||
assignedVariables.declare(extraVariable);
|
||||
}
|
||||
|
||||
@@ -431,13 +431,13 @@ class Label {
|
||||
}
|
||||
|
||||
class ForInElements {
|
||||
ExpressionVariable? explicitVariableDeclaration;
|
||||
ExpressionVariable? syntheticVariableDeclaration;
|
||||
Variable? explicitVariableDeclaration;
|
||||
Variable? syntheticVariableDeclaration;
|
||||
Expression? syntheticAssignment;
|
||||
Expression? expressionProblem;
|
||||
Statement? expressionEffects;
|
||||
|
||||
ExpressionVariable get variable =>
|
||||
Variable get variable =>
|
||||
(explicitVariableDeclaration ?? syntheticVariableDeclaration)!;
|
||||
}
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ class ForElement extends ControlFlowElement
|
||||
|
||||
/// A 'for-in' element in a list or set literal.
|
||||
class ForInElement extends ControlFlowElement with ControlFlowElementMixin {
|
||||
ExpressionVariable expressionVariable;
|
||||
Variable expressionVariable;
|
||||
// Coverage-ignore(suite): Not run.
|
||||
// Has no initializer.
|
||||
VariableDeclaration get variable => expressionVariable as VariableDeclaration;
|
||||
@@ -1092,7 +1092,7 @@ class PatternForMapEntry extends TreeNode
|
||||
class ForInMapEntry extends TreeNode
|
||||
with ControlFlowMapEntryMixin
|
||||
implements ControlFlowMapEntry {
|
||||
ExpressionVariable expressionVariable;
|
||||
Variable expressionVariable;
|
||||
// Coverage-ignore(suite): Not run.
|
||||
// Has no initializer.
|
||||
VariableDeclaration get variable => expressionVariable as VariableDeclaration;
|
||||
|
||||
@@ -128,7 +128,7 @@ class _ConstantEvaluator extends TryConstantEvaluator {
|
||||
// TODO(fishythefish): Do caches need to be invalidated when the static type
|
||||
// context changes?
|
||||
/// Cache for local variables in the current method.
|
||||
Map<ExpressionVariable, Constant?> _variableCache = {};
|
||||
Map<Variable, Constant?> _variableCache = {};
|
||||
final Map<Field, Constant?> _staticFieldCache = {};
|
||||
final Map<FunctionNode, Constant?> _functionCache = {};
|
||||
final Map<FunctionNode, Constant?> _localFunctionCache = {};
|
||||
@@ -168,7 +168,7 @@ class _ConstantEvaluator extends TryConstantEvaluator {
|
||||
return _evaluate(expression);
|
||||
}
|
||||
|
||||
Constant? _evaluateVariableGet(ExpressionVariable variable) {
|
||||
Constant? _evaluateVariableGet(Variable variable) {
|
||||
// A function parameter can be declared final with an initializer, but
|
||||
// doesn't necessarily have the initializer's value.
|
||||
if (variable.parent is FunctionNode) return null;
|
||||
@@ -179,8 +179,10 @@ class _ConstantEvaluator extends TryConstantEvaluator {
|
||||
return _evaluate(initializer);
|
||||
}
|
||||
|
||||
Constant? _lookupVariableGet(ExpressionVariable variable) => _variableCache
|
||||
.putIfAbsent(variable, () => _evaluateVariableGet(variable));
|
||||
Constant? _lookupVariableGet(Variable variable) => _variableCache.putIfAbsent(
|
||||
variable,
|
||||
() => _evaluateVariableGet(variable),
|
||||
);
|
||||
|
||||
@override
|
||||
Constant visitVariableGet(VariableGet node) =>
|
||||
@@ -259,7 +261,7 @@ class _ConstantEvaluator extends TryConstantEvaluator {
|
||||
//
|
||||
// This can occur when calling const extension type constructors since these
|
||||
// are lowered into top level functions.
|
||||
Map<ExpressionVariable, Constant?> oldCache = _variableCache;
|
||||
Map<Variable, Constant?> oldCache = _variableCache;
|
||||
_variableCache = {};
|
||||
Constant result =
|
||||
_lookupStaticInvocation(node.target) ??
|
||||
|
||||
@@ -2183,7 +2183,7 @@ class ConstantsTransformer extends RemovingTransformer {
|
||||
|
||||
@override
|
||||
TreeNode visitVariableGet(VariableGet node, TreeNode? removalSentinel) {
|
||||
final ExpressionVariable variable = node.expressionVariable;
|
||||
final Variable variable = node.expressionVariable;
|
||||
if (variable.isConst) {
|
||||
variable.initializer = evaluateAndTransformWithContext(
|
||||
variable,
|
||||
@@ -4785,7 +4785,7 @@ class ConstantEvaluator
|
||||
//
|
||||
// TODO(kustermann): The heuristic of allowing all [VariableGet]s on [Let]
|
||||
// variables might allow more than it should.
|
||||
final ExpressionVariable variable = node.expressionVariable;
|
||||
final Variable variable = node.expressionVariable;
|
||||
if (enableConstFunctions || inExtensionTypeConstConstructor) {
|
||||
return env.lookupVariable(variable) ??
|
||||
// Coverage-ignore(suite): Not run.
|
||||
@@ -4822,7 +4822,7 @@ class ConstantEvaluator
|
||||
@override
|
||||
Constant visitVariableSet(VariableSet node) {
|
||||
if (enableConstFunctions || inExtensionTypeConstConstructor) {
|
||||
final ExpressionVariable variable = node.expressionVariable;
|
||||
final Variable variable = node.expressionVariable;
|
||||
Constant value = _evaluateSubexpression(node.value);
|
||||
if (value is AbortConstant) return value;
|
||||
Constant? result = env.updateVariableValue(variable, value);
|
||||
@@ -6416,15 +6416,14 @@ class EvaluationEnvironment {
|
||||
<TypeParameter, DartType>{};
|
||||
|
||||
/// The references to values of the parameters/variables in scope.
|
||||
final Map<ExpressionVariable, EvaluationReference> _variables =
|
||||
<ExpressionVariable, EvaluationReference>{};
|
||||
final Map<Variable, EvaluationReference> _variables =
|
||||
<Variable, EvaluationReference>{};
|
||||
|
||||
/// The variables that hold unevaluated constants.
|
||||
///
|
||||
/// Variables are removed from this set when looked up, leaving only the
|
||||
/// unread variables at the end.
|
||||
final Set<ExpressionVariable> _unreadUnevaluatedVariables =
|
||||
new Set<ExpressionVariable>();
|
||||
final Set<Variable> _unreadUnevaluatedVariables = new Set<Variable>();
|
||||
|
||||
final EvaluationEnvironment? _parent;
|
||||
|
||||
@@ -6445,14 +6444,14 @@ class EvaluationEnvironment {
|
||||
_typeParameters[parameter] = value;
|
||||
}
|
||||
|
||||
void addVariableValue(ExpressionVariable variable, Constant value) {
|
||||
void addVariableValue(Variable variable, Constant value) {
|
||||
_variables[variable] = new EvaluationReference(value);
|
||||
if (value is UnevaluatedConstant) {
|
||||
_unreadUnevaluatedVariables.add(variable);
|
||||
}
|
||||
}
|
||||
|
||||
Constant? updateVariableValue(ExpressionVariable variable, Constant value) {
|
||||
Constant? updateVariableValue(Variable variable, Constant value) {
|
||||
EvaluationReference? reference = _variables[variable];
|
||||
if (reference != null) {
|
||||
reference.value = value;
|
||||
@@ -6461,7 +6460,7 @@ class EvaluationEnvironment {
|
||||
return _parent?.updateVariableValue(variable, value);
|
||||
}
|
||||
|
||||
Constant? lookupVariable(ExpressionVariable variable) {
|
||||
Constant? lookupVariable(Variable variable) {
|
||||
Constant? value = _variables[variable]?.value;
|
||||
if (value is UnevaluatedConstant) {
|
||||
_unreadUnevaluatedVariables.remove(variable);
|
||||
@@ -6476,8 +6475,7 @@ class EvaluationEnvironment {
|
||||
if (_unreadUnevaluatedVariables.isEmpty) return const [];
|
||||
// Coverage-ignore(suite): Not run.
|
||||
return _unreadUnevaluatedVariables.map<UnevaluatedConstant>(
|
||||
(ExpressionVariable variable) =>
|
||||
_variables[variable]!.value as UnevaluatedConstant,
|
||||
(Variable variable) => _variables[variable]!.value as UnevaluatedConstant,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6770,7 +6768,7 @@ class HasUninstantiatedVisitor extends FindTypeVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
bool _isFormalParameter(ExpressionVariable variable) {
|
||||
bool _isFormalParameter(Variable variable) {
|
||||
final TreeNode? parent = variable.parent;
|
||||
if (parent is FunctionNode) {
|
||||
return parent.positionalParameters.contains(variable) ||
|
||||
|
||||
@@ -433,7 +433,7 @@ abstract class Generator {
|
||||
/// If the variable is final or read-only (like a parameter in a catch clause) a
|
||||
/// [ReadOnlyAccessGenerator] is created instead.
|
||||
class VariableUseGenerator extends Generator {
|
||||
final ExpressionVariable variable;
|
||||
final Variable variable;
|
||||
|
||||
VariableUseGenerator(
|
||||
ExpressionGeneratorHelper helper,
|
||||
@@ -523,7 +523,7 @@ class VariableUseGenerator extends Generator {
|
||||
_helper.registerVariableRead(variable);
|
||||
_helper.registerVariableAssignment(variable);
|
||||
return new LocalIncDec(
|
||||
variable: variable as InternalExpressionVariable,
|
||||
variable: variable as InternalVariable,
|
||||
forEffect: forEffect,
|
||||
isPost: isPost,
|
||||
isInc: binaryOperator == plusName,
|
||||
@@ -629,7 +629,7 @@ class ForInLateFinalVariableUseGenerator extends VariableUseGenerator {
|
||||
ForInLateFinalVariableUseGenerator(
|
||||
ExpressionGeneratorHelper helper,
|
||||
Token token,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
) : super(helper, token, variable);
|
||||
|
||||
@override
|
||||
|
||||
@@ -85,7 +85,7 @@ abstract class ExpressionGeneratorHelper {
|
||||
|
||||
LibraryFeatures get libraryFeatures;
|
||||
|
||||
bool isDeclaredInEnclosingCase(ExpressionVariable variable);
|
||||
bool isDeclaredInEnclosingCase(Variable variable);
|
||||
|
||||
Generator processLookupResult({
|
||||
required LookupResult? lookupResult,
|
||||
@@ -229,17 +229,17 @@ abstract class ExpressionGeneratorHelper {
|
||||
|
||||
/// Creates a [VariableGet] of the [variable] using [charOffset] as the file
|
||||
/// offset of the created node.
|
||||
Expression createVariableGet(ExpressionVariable variable, int charOffset);
|
||||
Expression createVariableGet(Variable variable, int charOffset);
|
||||
|
||||
/// Registers that [variable] is read from.
|
||||
///
|
||||
/// This is needed for type promotion.
|
||||
void registerVariableRead(ExpressionVariable variable);
|
||||
void registerVariableRead(Variable variable);
|
||||
|
||||
/// Registers that [variable] is assigned to.
|
||||
///
|
||||
/// This is needed for type promotion.
|
||||
void registerVariableAssignment(ExpressionVariable variable);
|
||||
void registerVariableAssignment(Variable variable);
|
||||
|
||||
TypeEnvironment get typeEnvironment;
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ class Forest {
|
||||
|
||||
ForInElement createForInElement(
|
||||
int fileOffset,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Expression iterable,
|
||||
Expression? synthesizedAssignment,
|
||||
Statement? expressionEffects,
|
||||
@@ -368,7 +368,7 @@ class Forest {
|
||||
|
||||
ForInMapEntry createForInMapEntry(
|
||||
int fileOffset,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Expression iterable,
|
||||
Expression? synthesizedAssignment,
|
||||
Statement? expressionEffects,
|
||||
@@ -952,7 +952,7 @@ class Forest {
|
||||
|
||||
AssignedVariablePattern createAssignedVariablePattern(
|
||||
int fileOffset,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
) {
|
||||
return new AssignedVariablePattern(variable)..fileOffset = fileOffset;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import '../type_inference/inference_results.dart';
|
||||
import '../type_inference/inference_visitor.dart';
|
||||
|
||||
typedef SharedMatchContext =
|
||||
shared.MatchContext<TreeNode, Expression, Pattern, ExpressionVariable>;
|
||||
shared.MatchContext<TreeNode, Expression, Pattern, Variable>;
|
||||
|
||||
mixin InternalTreeNode implements TreeNode {
|
||||
@override
|
||||
@@ -99,7 +99,7 @@ abstract class InternalStatement extends AuxiliaryStatement {
|
||||
}
|
||||
|
||||
class ForInStatementWithSynthesizedVariable extends InternalStatement {
|
||||
ExpressionVariable? variable;
|
||||
Variable? variable;
|
||||
Expression iterable;
|
||||
Expression? syntheticAssignment;
|
||||
Statement? expressionEffects;
|
||||
@@ -924,10 +924,10 @@ class ReturnStatementImpl extends ReturnStatement {
|
||||
|
||||
/// Front end specific implementation of [VariableDeclaration].
|
||||
class VariableDeclarationImpl extends VariableStatement
|
||||
with InternalExpressionVariableMixin
|
||||
implements InternalExpressionVariable {
|
||||
with InternalVariableMixin
|
||||
implements InternalVariable {
|
||||
@override
|
||||
ExpressionVariable get astVariable => this;
|
||||
Variable get astVariable => this;
|
||||
|
||||
@override
|
||||
final bool forSyntheticToken;
|
||||
@@ -1019,8 +1019,8 @@ class VariableDeclarationImpl extends VariableStatement
|
||||
}
|
||||
|
||||
class InternalLocalVariable extends TreeNode
|
||||
with InternalExpressionVariableMixin, DelegatingVariableMixin
|
||||
implements LocalVariable, InternalExpressionVariable {
|
||||
with InternalVariableMixin, DelegatingVariableMixin
|
||||
implements LocalVariable, InternalVariable {
|
||||
@override
|
||||
LocalVariable astVariable;
|
||||
|
||||
@@ -1061,8 +1061,8 @@ class InternalLocalVariable extends TreeNode
|
||||
}
|
||||
|
||||
class InternalPositionalParameter extends TreeNode
|
||||
with InternalExpressionVariableMixin, DelegatingVariableMixin
|
||||
implements PositionalParameter, InternalExpressionVariable {
|
||||
with InternalVariableMixin, DelegatingVariableMixin
|
||||
implements PositionalParameter, InternalVariable {
|
||||
@override
|
||||
PositionalParameter astVariable;
|
||||
|
||||
@@ -1161,17 +1161,17 @@ class InternalPositionalParameter extends TreeNode
|
||||
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
ExpressionVariable get variable => this;
|
||||
Variable get variable => this;
|
||||
|
||||
@override
|
||||
void set variable(ExpressionVariable value) {
|
||||
void set variable(Variable value) {
|
||||
throw new UnsupportedError("${this.runtimeType}");
|
||||
}
|
||||
}
|
||||
|
||||
class InternalNamedParameter extends TreeNode
|
||||
with InternalExpressionVariableMixin, DelegatingVariableMixin
|
||||
implements NamedParameter, InternalExpressionVariable {
|
||||
with InternalVariableMixin, DelegatingVariableMixin
|
||||
implements NamedParameter, InternalVariable {
|
||||
@override
|
||||
NamedParameter astVariable;
|
||||
|
||||
@@ -1280,17 +1280,17 @@ class InternalNamedParameter extends TreeNode
|
||||
|
||||
@override
|
||||
// Coverage-ignore(suite): Not run.
|
||||
ExpressionVariable get variable => this;
|
||||
Variable get variable => this;
|
||||
|
||||
@override
|
||||
void set variable(ExpressionVariable value) {
|
||||
void set variable(Variable value) {
|
||||
throw new UnsupportedError("${this.runtimeType}");
|
||||
}
|
||||
}
|
||||
|
||||
class InternalCatchVariable extends TreeNode
|
||||
with InternalExpressionVariableMixin, DelegatingVariableMixin
|
||||
implements CatchVariable, InternalExpressionVariable {
|
||||
with InternalVariableMixin, DelegatingVariableMixin
|
||||
implements CatchVariable, InternalVariable {
|
||||
@override
|
||||
CatchVariable astVariable;
|
||||
|
||||
@@ -1335,8 +1335,8 @@ class InternalCatchVariable extends TreeNode
|
||||
}
|
||||
|
||||
class InternalSyntheticVariable extends TreeNode
|
||||
with InternalExpressionVariableMixin, DelegatingVariableMixin
|
||||
implements SyntheticVariable, InternalExpressionVariable {
|
||||
with InternalVariableMixin, DelegatingVariableMixin
|
||||
implements SyntheticVariable, InternalVariable {
|
||||
@override
|
||||
SyntheticVariable astVariable;
|
||||
|
||||
@@ -1376,8 +1376,8 @@ class InternalSyntheticVariable extends TreeNode
|
||||
}
|
||||
}
|
||||
|
||||
mixin DelegatingVariableMixin on InternalExpressionVariableMixin
|
||||
implements InternalExpressionVariable {
|
||||
mixin DelegatingVariableMixin on InternalVariableMixin
|
||||
implements InternalVariable {
|
||||
@override
|
||||
String? get cosmeticName => astVariable.cosmeticName;
|
||||
|
||||
@@ -1718,8 +1718,7 @@ mixin DelegatingVariableMixin on InternalExpressionVariableMixin
|
||||
}
|
||||
}
|
||||
|
||||
abstract interface class InternalExpressionVariable
|
||||
implements IExpressionVariable, Annotatable {
|
||||
abstract interface class InternalVariable implements IVariable, Annotatable {
|
||||
/// This is the output variable that the clients receive.
|
||||
///
|
||||
/// Most of the calls to variable properties are delegated to [astVariable],
|
||||
@@ -1730,15 +1729,15 @@ abstract interface class InternalExpressionVariable
|
||||
/// * using [astVariable] as a part of the generated AST,
|
||||
/// * checking semantic properties of an AST node, such as [isExtensionThis]
|
||||
/// in `lowering_predicates.dart`.
|
||||
ExpressionVariable get astVariable;
|
||||
Variable get astVariable;
|
||||
|
||||
bool get forSyntheticToken;
|
||||
|
||||
/// Determine whether the given [InternalExpressionVariable] had an implicit
|
||||
/// Determine whether the given [InternalVariable] had an implicit
|
||||
/// type.
|
||||
bool get isImplicitlyTyped;
|
||||
|
||||
/// Determines whether the given [InternalExpressionVariable] represents a
|
||||
/// Determines whether the given [InternalVariable] represents a
|
||||
/// local function.
|
||||
bool get isLocalFunction;
|
||||
|
||||
@@ -1785,8 +1784,7 @@ abstract interface class InternalExpressionVariable
|
||||
abstract List<Expression> annotations;
|
||||
}
|
||||
|
||||
mixin InternalExpressionVariableMixin on TreeNode
|
||||
implements InternalExpressionVariable {
|
||||
mixin InternalVariableMixin on TreeNode implements InternalVariable {
|
||||
@override
|
||||
bool get forSyntheticToken;
|
||||
|
||||
@@ -1815,7 +1813,7 @@ mixin InternalExpressionVariableMixin on TreeNode
|
||||
String? lateName;
|
||||
|
||||
@override
|
||||
ExpressionVariable get asExpressionVariable => this as ExpressionVariable;
|
||||
Variable get asExpressionVariable => this as Variable;
|
||||
}
|
||||
|
||||
/// Front end specific implementation of [LoadLibrary].
|
||||
@@ -2740,7 +2738,7 @@ class ExtensionIncDec extends InternalExpression {
|
||||
///
|
||||
class LocalIncDec extends InternalExpression {
|
||||
/// The accessed variable.
|
||||
final InternalExpressionVariable variable;
|
||||
final InternalVariable variable;
|
||||
|
||||
/// `true` if the inc/dec is a postfix expression, i.e. of the form `a++` as
|
||||
/// opposed the prefix expression `++a`.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// 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.
|
||||
|
||||
import 'package:kernel/ast.dart' show ExpressionVariable;
|
||||
import 'package:kernel/ast.dart' show Variable;
|
||||
|
||||
import '../base/lookup_result.dart';
|
||||
import '../builder/builder.dart';
|
||||
@@ -18,7 +18,7 @@ class VariableBuilderImpl extends NamedBuilderImpl
|
||||
final Uri fileUri;
|
||||
|
||||
@override
|
||||
final ExpressionVariable variable;
|
||||
final Variable variable;
|
||||
|
||||
VariableBuilderImpl(this.name, this.variable, this.fileUri);
|
||||
|
||||
|
||||
@@ -837,7 +837,7 @@ class Resolver {
|
||||
required LookupScope scope,
|
||||
required Token token,
|
||||
required Procedure procedure,
|
||||
required List<ExpressionVariable> extraKnownVariables,
|
||||
required List<Variable> extraKnownVariables,
|
||||
required ExpressionEvaluationHelper expressionEvaluationHelper,
|
||||
required VariableDeclaration? extensionThis,
|
||||
}) {
|
||||
@@ -934,7 +934,7 @@ class Resolver {
|
||||
);
|
||||
}
|
||||
}
|
||||
for (ExpressionVariable extraVariable in extraKnownVariables) {
|
||||
for (Variable extraVariable in extraKnownVariables) {
|
||||
context.typeInferrer.flowAnalysis.declare(
|
||||
extraVariable,
|
||||
new SharedTypeView(extraVariable.type),
|
||||
@@ -1197,7 +1197,7 @@ class Resolver {
|
||||
/// [fileOffset] as the file offset.
|
||||
VariableGet _createVariableGet({
|
||||
required AssignedVariables assignedVariables,
|
||||
required InternalExpressionVariable variable,
|
||||
required InternalVariable variable,
|
||||
required int fileOffset,
|
||||
}) {
|
||||
if (!variable.isLocalFunction && !variable.isWildcard) {
|
||||
@@ -1228,7 +1228,7 @@ class Resolver {
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
typeInferrer.flowAnalysis.declare(
|
||||
(variable as InternalExpressionVariable).astVariable,
|
||||
(variable as InternalVariable).astVariable,
|
||||
new SharedTypeView(variable.type),
|
||||
initialized: true,
|
||||
);
|
||||
|
||||
@@ -145,16 +145,16 @@ abstract class ContextAllocationStrategy<Info extends ScopeProviderInfo> {
|
||||
}
|
||||
|
||||
void handleDeclarationOfVariable(
|
||||
ExpressionVariable variable, {
|
||||
Variable variable, {
|
||||
required CaptureKind captureKind,
|
||||
});
|
||||
|
||||
void handleVariablesCapturedByNode(
|
||||
ContextConsumer node,
|
||||
List<Variable> variables,
|
||||
List<VariableBase> variables,
|
||||
) {
|
||||
Set<VariableContext> contexts = {
|
||||
for (Variable variable in variables) variable.context,
|
||||
for (VariableBase variable in variables) variable.context,
|
||||
};
|
||||
(node.contexts ??= []).addAll(contexts);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ class TrivialContextAllocationStrategy
|
||||
extends ContextAllocationStrategy<ScopeProviderInfo> {
|
||||
@override
|
||||
void handleDeclarationOfVariable(
|
||||
ExpressionVariable variable, {
|
||||
Variable variable, {
|
||||
required CaptureKind captureKind,
|
||||
}) {
|
||||
assert(_currentScopeProviderInfo != null);
|
||||
@@ -256,7 +256,7 @@ class LoopDepthAllocationStrategy
|
||||
|
||||
@override
|
||||
void handleDeclarationOfVariable(
|
||||
ExpressionVariable variable, {
|
||||
Variable variable, {
|
||||
required CaptureKind captureKind,
|
||||
}) {
|
||||
CollectorScopeProviderInfo currentScope = _currentScopeProviderInfo!;
|
||||
|
||||
@@ -611,7 +611,7 @@ class EffectExpression implements DelayedExpression {
|
||||
/// to [_target].
|
||||
class DelayedAssignment extends DelayedExpression {
|
||||
final MatchingCache _cache;
|
||||
final ExpressionVariable _target;
|
||||
final Variable _target;
|
||||
final DartType _type;
|
||||
final DelayedExpression _value;
|
||||
final bool hasEffect;
|
||||
|
||||
@@ -169,7 +169,7 @@ VariableGet createVariableGet(
|
||||
|
||||
/// Creates a [VariableSet] of [variable] with the [value].
|
||||
Expression createVariableSet(
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Expression value, {
|
||||
bool allowFinalAssignment = false,
|
||||
required int fileOffset,
|
||||
|
||||
@@ -15,7 +15,7 @@ import 'object_access_target.dart';
|
||||
import 'type_schema.dart' show UnknownType;
|
||||
|
||||
class ForInResult {
|
||||
final ExpressionVariable variable;
|
||||
final Variable variable;
|
||||
final Expression iterable;
|
||||
final Expression? syntheticAssignment;
|
||||
final Statement? expressionSideEffects;
|
||||
@@ -49,7 +49,7 @@ class LocalForInVariable implements ForInVariable {
|
||||
|
||||
@override
|
||||
DartType computeElementType(InferenceVisitorBase visitor) {
|
||||
ExpressionVariable variable = variableSet.expressionVariable;
|
||||
Variable variable = variableSet.expressionVariable;
|
||||
DartType? promotedType = visitor.flowAnalysis
|
||||
.promotedType(variable)
|
||||
// Coverage-ignore(suite): Not run.
|
||||
|
||||
@@ -111,13 +111,13 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
TreeNode,
|
||||
Statement,
|
||||
Expression,
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
Pattern,
|
||||
InvalidExpression,
|
||||
TypeDeclarationType,
|
||||
TypeDeclaration
|
||||
>,
|
||||
NullShortingMixin<NullAwareGuard, Expression, ExpressionVariable>,
|
||||
NullShortingMixin<NullAwareGuard, Expression, Variable>,
|
||||
StackChecker,
|
||||
ExpressionVisitor1ExperimentExclusionMixin<
|
||||
ExpressionInferenceResult,
|
||||
@@ -3194,15 +3194,15 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
|
||||
ForInResult handleForInDeclaringVariable(
|
||||
TreeNode node,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Expression iterable,
|
||||
Statement? expressionEffects, {
|
||||
bool isAsync = false,
|
||||
}) {
|
||||
DartType elementType;
|
||||
bool isVariableTypeNeeded = false;
|
||||
ExpressionVariable astVariable;
|
||||
if (variable case InternalExpressionVariable variable) {
|
||||
Variable astVariable;
|
||||
if (variable case InternalVariable variable) {
|
||||
if (variable.isImplicitlyTyped) {
|
||||
isVariableTypeNeeded = true;
|
||||
elementType = const UnknownType();
|
||||
@@ -3363,7 +3363,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
|
||||
ForInResult _handleForInWithoutVariable(
|
||||
TreeNode node,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Expression iterable,
|
||||
Expression? syntheticAssignment,
|
||||
Statement? expressionEffects, {
|
||||
@@ -3413,7 +3413,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
|
||||
ForInResult _handlePatternForIn(
|
||||
TreeNode node,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Expression iterable,
|
||||
Expression? syntheticAssignment,
|
||||
PatternVariableDeclaration patternVariableDeclaration, {
|
||||
@@ -3498,7 +3498,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
|
||||
ForInResult handleForInWithoutVariable(
|
||||
TreeNode node,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Expression iterable,
|
||||
Expression? syntheticAssignment,
|
||||
Statement? expressionEffects, {
|
||||
@@ -3544,9 +3544,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
null,
|
||||
isAsync: node.isAsync,
|
||||
);
|
||||
ExpressionVariable astVariable =
|
||||
result.variable is InternalExpressionVariable
|
||||
? (result.variable as InternalExpressionVariable).astVariable
|
||||
Variable astVariable = result.variable is InternalVariable
|
||||
? (result.variable as InternalVariable).astVariable
|
||||
: result.variable;
|
||||
node.expressionVariable = astVariable..parent = node;
|
||||
if (isClosureContextLoweringEnabled) {
|
||||
@@ -3815,8 +3814,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
for (VariableDeclaration parameter in parameters) {
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
ExpressionVariable parameterAstVariable =
|
||||
(parameter as InternalExpressionVariable).astVariable;
|
||||
Variable parameterAstVariable =
|
||||
(parameter as InternalVariable).astVariable;
|
||||
_contextAllocationStrategy.handleDeclarationOfVariable(
|
||||
parameterAstVariable,
|
||||
captureKind: _captureKindForVariable(parameterAstVariable),
|
||||
@@ -4686,9 +4685,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
isAsync: element.isAsync,
|
||||
);
|
||||
}
|
||||
ExpressionVariable astVariable =
|
||||
result.variable is InternalExpressionVariable
|
||||
? (result.variable as InternalExpressionVariable).astVariable
|
||||
Variable astVariable = result.variable is InternalVariable
|
||||
? (result.variable as InternalVariable).astVariable
|
||||
: result.variable;
|
||||
element.expressionVariable = astVariable..parent = element;
|
||||
if (isClosureContextLoweringEnabled) {
|
||||
@@ -7070,7 +7068,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
|
||||
ForInStatement _createForInStatement(
|
||||
int fileOffset,
|
||||
ExpressionVariable variable,
|
||||
Variable variable,
|
||||
Expression iterable,
|
||||
Statement body, {
|
||||
bool isAsync = false,
|
||||
@@ -7857,9 +7855,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
isAsync: entry.isAsync,
|
||||
);
|
||||
}
|
||||
ExpressionVariable astVariable =
|
||||
result.variable is InternalExpressionVariable
|
||||
? (result.variable as InternalExpressionVariable).astVariable
|
||||
Variable astVariable = result.variable is InternalVariable
|
||||
? (result.variable as InternalVariable).astVariable
|
||||
:
|
||||
// Coverage-ignore(suite): Not run.
|
||||
result.variable;
|
||||
@@ -13659,7 +13656,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
// TODO(62401): Remove the casts when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
exceptionCatchVariable =
|
||||
(exceptionCatchVariable as InternalExpressionVariable).astVariable
|
||||
(exceptionCatchVariable as InternalVariable).astVariable
|
||||
as CatchVariable;
|
||||
_contextAllocationStrategy.handleDeclarationOfVariable(
|
||||
exceptionCatchVariable,
|
||||
@@ -13671,7 +13668,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
// TODO(62401): Remove the casts when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
stackTraceCatchVariable =
|
||||
(stackTraceCatchVariable as InternalExpressionVariable).astVariable
|
||||
(stackTraceCatchVariable as InternalVariable).astVariable
|
||||
as CatchVariable;
|
||||
_contextAllocationStrategy.handleDeclarationOfVariable(
|
||||
stackTraceCatchVariable,
|
||||
@@ -13709,9 +13706,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
// TODO(62401): Remove the casts when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
flowAnalysis.tryCatchStatement_catchBegin(
|
||||
(catchBlock.exceptionCatchVariable as InternalExpressionVariable?)
|
||||
?.astVariable,
|
||||
(catchBlock.stackTraceCatchVariable as InternalExpressionVariable?)
|
||||
(catchBlock.exceptionCatchVariable as InternalVariable?)?.astVariable,
|
||||
(catchBlock.stackTraceCatchVariable as InternalVariable?)
|
||||
?.astVariable,
|
||||
);
|
||||
visitCatch(catchBlock);
|
||||
@@ -13783,8 +13779,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
return result;
|
||||
}
|
||||
}
|
||||
InternalExpressionVariable variable =
|
||||
node.expressionVariable as InternalExpressionVariable;
|
||||
InternalVariable variable = node.expressionVariable as InternalVariable;
|
||||
var (DartType variableType, DartType writeContext) =
|
||||
computeVariableSetTypeAndWriteContext(variable);
|
||||
ExpressionInferenceResult rhsResult = inferExpression(
|
||||
@@ -13869,7 +13864,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
}
|
||||
}
|
||||
return inferVariableGet(
|
||||
variable: node.expressionVariable as InternalExpressionVariable,
|
||||
variable: node.expressionVariable as InternalVariable,
|
||||
typeContext: typeContext,
|
||||
nameOffset: node.fileOffset,
|
||||
node: node,
|
||||
@@ -14703,7 +14698,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
}
|
||||
|
||||
@override
|
||||
FlowAnalysis<TreeNode, Statement, Expression, ExpressionVariable> get flow =>
|
||||
FlowAnalysis<TreeNode, Statement, Expression, Variable> get flow =>
|
||||
flowAnalysis;
|
||||
|
||||
@override
|
||||
@@ -14895,7 +14890,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
void handleCase_afterCaseHeads(
|
||||
Statement node,
|
||||
int caseIndex,
|
||||
Iterable<ExpressionVariable> variables,
|
||||
Iterable<Variable> variables,
|
||||
) {}
|
||||
|
||||
@override
|
||||
@@ -14971,7 +14966,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
}
|
||||
|
||||
@override
|
||||
void setVariableType(ExpressionVariable variable, SharedTypeView type) {
|
||||
void setVariableType(Variable variable, SharedTypeView type) {
|
||||
variable.type = type.unwrapTypeView();
|
||||
}
|
||||
|
||||
@@ -16510,7 +16505,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
|
||||
@override
|
||||
void finishJoinedPatternVariable(
|
||||
ExpressionVariable variable, {
|
||||
Variable variable, {
|
||||
required JoinedPatternVariableLocation location,
|
||||
required JoinedPatternVariableInconsistency inconsistency,
|
||||
required bool isFinal,
|
||||
@@ -17134,7 +17129,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
return node is DotShorthand;
|
||||
}
|
||||
|
||||
CaptureKind _captureKindForVariable(ExpressionVariable variable) {
|
||||
CaptureKind _captureKindForVariable(Variable variable) {
|
||||
int variableKey = assignedVariables.promotionKeyStore.keyForVariable(
|
||||
variable,
|
||||
);
|
||||
@@ -17150,8 +17145,8 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
}
|
||||
}
|
||||
|
||||
List<Variable> _capturedVariablesForNode(TreeNode node) {
|
||||
List<Variable> capturedVariables = [];
|
||||
List<VariableBase> _capturedVariablesForNode(TreeNode node) {
|
||||
List<VariableBase> capturedVariables = [];
|
||||
AssignedVariablesNodeInfo nodeInfo = assignedVariables.getInfoForNode(node);
|
||||
for (int variableKey in nodeInfo.read) {
|
||||
capturedVariables.add(
|
||||
@@ -17170,8 +17165,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
StatementInferenceResult visitVariableInitialization(
|
||||
VariableInitialization node,
|
||||
) {
|
||||
InternalExpressionVariable nodeVariable =
|
||||
node.variable as InternalExpressionVariable;
|
||||
InternalVariable nodeVariable = node.variable as InternalVariable;
|
||||
StatementInferenceResult statementInferenceResult =
|
||||
_inferInternalExpressionVariableDeclaration(node, nodeVariable);
|
||||
node.variable = nodeVariable.astVariable;
|
||||
@@ -17186,7 +17180,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
|
||||
StatementInferenceResult _inferInternalExpressionVariableDeclaration(
|
||||
VariableInitialization node,
|
||||
InternalExpressionVariable nodeVariable,
|
||||
InternalVariable nodeVariable,
|
||||
) {
|
||||
DartType declaredType = nodeVariable.isImplicitlyTyped
|
||||
? const UnknownType()
|
||||
@@ -17217,8 +17211,7 @@ class InferenceVisitorImpl extends InferenceVisitorBase
|
||||
if (node.isLate && node.hasDeclaredInitializer) {
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
ExpressionVariable variable =
|
||||
(node.variable as InternalExpressionVariable).astVariable;
|
||||
Variable variable = (node.variable as InternalVariable).astVariable;
|
||||
if (isClosureContextLoweringEnabled) {
|
||||
_contextAllocationStrategy.handleVariablesCapturedByNode(
|
||||
node,
|
||||
|
||||
@@ -148,8 +148,8 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
|
||||
InferenceDataForTesting? get dataForTesting => _inferrer.dataForTesting;
|
||||
|
||||
FlowAnalysis<TreeNode, Statement, Expression, ExpressionVariable>
|
||||
get flowAnalysis => _inferrer.flowAnalysis;
|
||||
FlowAnalysis<TreeNode, Statement, Expression, Variable> get flowAnalysis =>
|
||||
_inferrer.flowAnalysis;
|
||||
|
||||
/// Provides access to the [OperationsCfe] object. This is needed by
|
||||
/// [isAssignable] and for caching types.
|
||||
@@ -2311,8 +2311,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
// Otherwise, if `Qi` is not `_`, let `Ri` be the greatest closure of
|
||||
// `Qi[T/S]` with respect to `?`. Otherwise, let `Ri` be `dynamic`.
|
||||
for (int i = 0; i < formals.length; i++) {
|
||||
InternalExpressionVariable formal =
|
||||
formals[i] as InternalExpressionVariable;
|
||||
InternalVariable formal = formals[i] as InternalVariable;
|
||||
if (formal.isImplicitlyTyped) {
|
||||
DartType inferredType;
|
||||
if (formalTypesFromContext[i] != null) {
|
||||
@@ -2367,8 +2366,8 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
VariableDeclaration parameter = positionalParameters[i];
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
ExpressionVariable parameterAstVariable =
|
||||
(parameter as InternalExpressionVariable).astVariable;
|
||||
Variable parameterAstVariable =
|
||||
(parameter as InternalVariable).astVariable;
|
||||
flowAnalysis.declare(
|
||||
parameterAstVariable,
|
||||
new SharedTypeView(parameterAstVariable.type),
|
||||
@@ -2387,8 +2386,8 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
for (VariableDeclaration parameter in function.namedParameters) {
|
||||
// TODO(62401): Remove the cast when the flow analysis uses
|
||||
// [InternalExpressionVariable]s.
|
||||
ExpressionVariable parameterAstVariable =
|
||||
(parameter as InternalExpressionVariable).astVariable;
|
||||
Variable parameterAstVariable =
|
||||
(parameter as InternalVariable).astVariable;
|
||||
flowAnalysis.declare(
|
||||
parameterAstVariable,
|
||||
new SharedTypeView(parameterAstVariable.type),
|
||||
@@ -2406,8 +2405,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
}
|
||||
|
||||
for (VariableDeclaration parameter in function.namedParameters) {
|
||||
InternalExpressionVariable formal =
|
||||
parameter as InternalExpressionVariable;
|
||||
InternalVariable formal = parameter as InternalVariable;
|
||||
// Required named parameters shouldn't have initializers.
|
||||
if (formal.isRequired && formal.hasDeclaredInitializer) {
|
||||
libraryBuilder.addProblem(
|
||||
@@ -2879,7 +2877,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
functionType: null,
|
||||
)..fileOffset = fileOffset;
|
||||
} else if (receiver is VariableGet) {
|
||||
ExpressionVariable variable = receiver.expressionVariable;
|
||||
Variable variable = receiver.expressionVariable;
|
||||
TreeNode? parent = variable.parent;
|
||||
if (parent is FunctionDeclaration) {
|
||||
assert(
|
||||
@@ -4226,7 +4224,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
/// If [node] is provided, it is used as the basis for the resulting
|
||||
/// expression, otherwise a new [VariableGet] is created.
|
||||
ExpressionInferenceResult inferVariableGet({
|
||||
required InternalExpressionVariable variable,
|
||||
required InternalVariable variable,
|
||||
required DartType typeContext,
|
||||
required int nameOffset,
|
||||
VariableGet? node,
|
||||
@@ -4352,7 +4350,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
/// Computes the possible promoted variable type of [variable] and the type
|
||||
/// context for the value expression in a local set to [variable].
|
||||
(DartType variableType, DartType writeContext)
|
||||
computeVariableSetTypeAndWriteContext(InternalExpressionVariable variable) {
|
||||
computeVariableSetTypeAndWriteContext(InternalVariable variable) {
|
||||
DartType declaredOrInferredType = variable.lateType ?? variable.type;
|
||||
DartType? promotedType = flowAnalysis
|
||||
.promotedType(variable.astVariable)
|
||||
@@ -4366,7 +4364,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
/// If [node] is provided, it is used as the basis for the resulting
|
||||
/// expression, otherwise a new [VariableSet] is created.
|
||||
ExpressionInferenceResult inferVariableSet({
|
||||
required InternalExpressionVariable variable,
|
||||
required InternalVariable variable,
|
||||
required DartType variableType,
|
||||
required ExpressionInferenceResult rhsResult,
|
||||
required int assignOffset,
|
||||
@@ -4843,7 +4841,7 @@ abstract class InferenceVisitorBase implements InferenceVisitor {
|
||||
}
|
||||
}
|
||||
if (expression is VariableGet) {
|
||||
ExpressionVariable variable = expression.expressionVariable;
|
||||
Variable variable = expression.expressionVariable;
|
||||
if (variable is VariableDeclarationImpl && variable.isLocalFunction) {
|
||||
return diag.invalidCastLocalFunction;
|
||||
}
|
||||
@@ -5595,12 +5593,7 @@ FunctionType replaceReturnType(FunctionType functionType, DartType returnType) {
|
||||
}
|
||||
|
||||
class _WhyNotPromotedVisitor
|
||||
implements
|
||||
NonPromotionReasonVisitor<
|
||||
List<LocatedMessage>,
|
||||
Node,
|
||||
ExpressionVariable
|
||||
> {
|
||||
implements NonPromotionReasonVisitor<List<LocatedMessage>, Node, Variable> {
|
||||
final InferenceVisitorBase inferrer;
|
||||
|
||||
Member? propertyReference;
|
||||
@@ -5609,7 +5602,7 @@ class _WhyNotPromotedVisitor
|
||||
|
||||
@override
|
||||
List<LocatedMessage> visitDemoteViaExplicitWrite(
|
||||
DemoteViaExplicitWrite<ExpressionVariable> reason,
|
||||
DemoteViaExplicitWrite<Variable> reason,
|
||||
) {
|
||||
TreeNode node = reason.node as TreeNode;
|
||||
if (inferrer.dataForTesting != null) {
|
||||
|
||||
@@ -21,14 +21,14 @@ import 'type_schema_environment.dart';
|
||||
class TypeConstraintGatherer
|
||||
extends
|
||||
shared.TypeConstraintGenerator<
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
TypeDeclarationType,
|
||||
TypeDeclaration,
|
||||
TreeNode
|
||||
>
|
||||
with
|
||||
shared.TypeConstraintGeneratorMixin<
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
TypeDeclarationType,
|
||||
TypeDeclaration,
|
||||
TreeNode
|
||||
|
||||
@@ -385,14 +385,14 @@ class TypeInferenceEngineImpl extends TypeInferenceEngine {
|
||||
if (dataForTesting != null) {
|
||||
// Coverage-ignore-block(suite): Not run.
|
||||
dataForTesting.flowAnalysisResult.assignedVariables =
|
||||
new AssignedVariablesForTesting<TreeNode, ExpressionVariable>();
|
||||
new AssignedVariablesForTesting<TreeNode, Variable>();
|
||||
assignedVariables = new AssignedVariablesImpl(
|
||||
dataForTesting.flowAnalysisResult.assignedVariables!,
|
||||
isClosureContextLoweringEnabled: isClosureContextLoweringEnabled,
|
||||
);
|
||||
} else {
|
||||
assignedVariables = new AssignedVariablesImpl(
|
||||
new AssignedVariables<TreeNode, ExpressionVariable>(),
|
||||
new AssignedVariables<TreeNode, Variable>(),
|
||||
isClosureContextLoweringEnabled: isClosureContextLoweringEnabled,
|
||||
);
|
||||
}
|
||||
@@ -456,7 +456,7 @@ class FlowAnalysisResult {
|
||||
final List<TreeNode> definitelyUnassignedNodes = [];
|
||||
|
||||
/// The assigned variables information that computed for the member.
|
||||
AssignedVariablesForTesting<TreeNode, ExpressionVariable>? assignedVariables;
|
||||
AssignedVariablesForTesting<TreeNode, Variable>? assignedVariables;
|
||||
|
||||
/// For each expression that led to an error because it was not promoted, a
|
||||
/// string describing the reason it was not promoted.
|
||||
@@ -471,14 +471,14 @@ class FlowAnalysisResult {
|
||||
class OperationsCfe
|
||||
with
|
||||
TypeAnalyzerOperationsMixin<
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
TypeDeclarationType,
|
||||
TypeDeclaration,
|
||||
TreeNode
|
||||
>
|
||||
implements
|
||||
TypeAnalyzerOperations<
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
TypeDeclarationType,
|
||||
TypeDeclaration,
|
||||
TreeNode
|
||||
@@ -600,7 +600,7 @@ class OperationsCfe
|
||||
bool isExtensionTypeInternal(DartType type) => type is ExtensionType;
|
||||
|
||||
@override
|
||||
bool isFinal(ExpressionVariable variable) {
|
||||
bool isFinal(Variable variable) {
|
||||
return variable.isFinal;
|
||||
}
|
||||
|
||||
@@ -688,12 +688,12 @@ class OperationsCfe
|
||||
}
|
||||
|
||||
@override
|
||||
SharedTypeView variableType(ExpressionVariable variable) {
|
||||
SharedTypeView variableType(Variable variable) {
|
||||
// When late variables get lowered, their type is changed, but the
|
||||
// original type is stored in `VariableDeclarationImpl.lateType`, so we
|
||||
// use that if it exists.
|
||||
DartType? lateType = variable is InternalExpressionVariable
|
||||
? (variable as InternalExpressionVariable).lateType
|
||||
DartType? lateType = variable is InternalVariable
|
||||
? (variable as InternalVariable).lateType
|
||||
: null;
|
||||
return new SharedTypeView(lateType ?? variable.type);
|
||||
}
|
||||
@@ -777,7 +777,7 @@ class OperationsCfe
|
||||
}
|
||||
|
||||
@override
|
||||
bool isVariableFinal(ExpressionVariable node) {
|
||||
bool isVariableFinal(Variable node) {
|
||||
return node.isFinal;
|
||||
}
|
||||
|
||||
@@ -1097,7 +1097,7 @@ class OperationsCfe
|
||||
|
||||
@override
|
||||
TypeConstraintGenerator<
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
TypeDeclarationType,
|
||||
TypeDeclaration,
|
||||
TreeNode
|
||||
@@ -1184,11 +1184,7 @@ class OperationsCfe
|
||||
|
||||
/// Type inference results used for testing.
|
||||
class TypeInferenceResultForTesting
|
||||
extends
|
||||
shared.TypeConstraintGenerationDataForTesting<
|
||||
ExpressionVariable,
|
||||
TreeNode
|
||||
> {
|
||||
extends shared.TypeConstraintGenerationDataForTesting<Variable, TreeNode> {
|
||||
final Map<TreeNode, List<DartType>> inferredTypeArguments = {};
|
||||
final Map<TreeNode, DartType> inferredVariableTypes = {};
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ abstract class TypeInferrer {
|
||||
ExtensionScope get extensionScope;
|
||||
|
||||
/// Returns the [FlowAnalysis] used during inference.
|
||||
FlowAnalysis<TreeNode, Statement, Expression, ExpressionVariable>
|
||||
get flowAnalysis;
|
||||
FlowAnalysis<TreeNode, Statement, Expression, Variable> get flowAnalysis;
|
||||
|
||||
AssignedVariablesImpl get assignedVariables;
|
||||
|
||||
@@ -115,7 +114,7 @@ class TypeInferrerImpl implements TypeInferrer {
|
||||
TypeAnalyzerOptions typeAnalyzerOptions;
|
||||
|
||||
@override
|
||||
late final FlowAnalysis<TreeNode, Statement, Expression, ExpressionVariable>
|
||||
late final FlowAnalysis<TreeNode, Statement, Expression, Variable>
|
||||
flowAnalysis = new FlowAnalysis(
|
||||
operations,
|
||||
assignedVariables,
|
||||
@@ -436,8 +435,8 @@ class TypeInferrerImplBenchmarked implements TypeInferrer {
|
||||
AssignedVariablesImpl get assignedVariables => impl.assignedVariables;
|
||||
|
||||
@override
|
||||
FlowAnalysis<TreeNode, Statement, Expression, ExpressionVariable>
|
||||
get flowAnalysis => impl.flowAnalysis;
|
||||
FlowAnalysis<TreeNode, Statement, Expression, Variable> get flowAnalysis =>
|
||||
impl.flowAnalysis;
|
||||
|
||||
@override
|
||||
TypeSchemaEnvironment get typeSchemaEnvironment => impl.typeSchemaEnvironment;
|
||||
|
||||
@@ -20,12 +20,11 @@ import 'type_inference_engine.dart';
|
||||
import 'type_demotion.dart';
|
||||
import 'type_schema.dart' show UnknownType;
|
||||
|
||||
typedef GeneratedTypeConstraint =
|
||||
shared.GeneratedTypeConstraint<ExpressionVariable>;
|
||||
typedef GeneratedTypeConstraint = shared.GeneratedTypeConstraint<Variable>;
|
||||
|
||||
typedef MergedTypeConstraint =
|
||||
shared.MergedTypeConstraint<
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
TypeDeclarationType,
|
||||
TypeDeclaration,
|
||||
TreeNode
|
||||
@@ -33,7 +32,7 @@ typedef MergedTypeConstraint =
|
||||
|
||||
typedef UnknownTypeConstraintOrigin =
|
||||
shared.UnknownTypeConstraintOrigin<
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
TypeDeclarationType,
|
||||
TypeDeclaration,
|
||||
TreeNode
|
||||
|
||||
@@ -53,12 +53,12 @@ class AssignedVariablesDataComputer extends CfeDataComputer<_Data> {
|
||||
SourceMemberBuilder memberBuilder =
|
||||
lookupMemberBuilder(testResultData.compilerResult, member)
|
||||
as SourceMemberBuilder;
|
||||
AssignedVariablesForTesting<TreeNode, ExpressionVariable>?
|
||||
assignedVariables = memberBuilder
|
||||
.dataForTesting!
|
||||
.inferenceData
|
||||
.flowAnalysisResult
|
||||
.assignedVariables;
|
||||
AssignedVariablesForTesting<TreeNode, Variable>? assignedVariables =
|
||||
memberBuilder
|
||||
.dataForTesting!
|
||||
.inferenceData
|
||||
.flowAnalysisResult
|
||||
.assignedVariables;
|
||||
if (assignedVariables == null) return;
|
||||
member.accept(
|
||||
new AssignedVariablesDataExtractor(
|
||||
@@ -72,8 +72,7 @@ class AssignedVariablesDataComputer extends CfeDataComputer<_Data> {
|
||||
|
||||
class AssignedVariablesDataExtractor extends CfeDataExtractor<_Data> {
|
||||
final SourceLoaderDataForTesting _sourceLoaderDataForTesting;
|
||||
final AssignedVariablesForTesting<TreeNode, ExpressionVariable>
|
||||
_assignedVariables;
|
||||
final AssignedVariablesForTesting<TreeNode, Variable> _assignedVariables;
|
||||
|
||||
AssignedVariablesDataExtractor(
|
||||
InternalCompilerResult compilerResult,
|
||||
|
||||
@@ -54,7 +54,7 @@ class UnreachableIfFinder extends RecursiveVisitor {
|
||||
|
||||
List<Warning> warnings = [];
|
||||
|
||||
Map<ExpressionVariable, bool> knownValues = {};
|
||||
Map<Variable, bool> knownValues = {};
|
||||
|
||||
@override
|
||||
void visitIfStatement(IfStatement node) {
|
||||
@@ -75,7 +75,7 @@ class UnreachableIfFinder extends RecursiveVisitor {
|
||||
// TODO(jensj): We could make the visit return a bool? instead and use that
|
||||
// from the condition instead of doing special casing on `Not` and
|
||||
// `VariableGet`.
|
||||
ExpressionVariable? newKnownValueHere;
|
||||
Variable? newKnownValueHere;
|
||||
bool conditionNegated = false;
|
||||
|
||||
if (condition is Not) {
|
||||
|
||||
@@ -542,7 +542,7 @@ class CloneVisitorNotMembers
|
||||
|
||||
@override
|
||||
TreeNode visitForInStatement(ForInStatement node) {
|
||||
ExpressionVariable newVariable = clone(node.expressionVariable);
|
||||
Variable newVariable = clone(node.expressionVariable);
|
||||
return new ForInStatement(
|
||||
newVariable, clone(node.iterable), clone(node.body),
|
||||
isAsync: node.isAsync)
|
||||
|
||||
@@ -189,7 +189,7 @@ class InvalidExpression extends Expression {
|
||||
|
||||
class VariableGet extends Expression {
|
||||
/// The target variable.
|
||||
ExpressionVariable expressionVariable;
|
||||
Variable expressionVariable;
|
||||
|
||||
/// Null if not promoted.
|
||||
DartType? promotedType;
|
||||
@@ -263,7 +263,7 @@ class VariableSet extends Expression {
|
||||
VariableDeclaration get variable => expressionVariable as VariableDeclaration;
|
||||
|
||||
/// The target variable.
|
||||
ExpressionVariable expressionVariable;
|
||||
Variable expressionVariable;
|
||||
|
||||
Expression value;
|
||||
|
||||
@@ -5307,9 +5307,9 @@ class TypedefTearOff extends Expression {
|
||||
/// [VariableRead] nodes are the replacement for the VariableGet nodes.
|
||||
///
|
||||
/// Despite of the name, [VariableRead] can't read [TypeVariable]s,
|
||||
/// which are also [Variable]s.
|
||||
/// which are also [VariableBase]s.
|
||||
class VariableRead extends Expression {
|
||||
final ExpressionVariable variable;
|
||||
final Variable variable;
|
||||
|
||||
VariableRead({required this.variable});
|
||||
|
||||
@@ -5360,9 +5360,9 @@ class VariableRead extends Expression {
|
||||
/// [VariableWrite] nodes are the replacement for the VariableSet nodes.
|
||||
///
|
||||
/// Despite of the name, [VariableWrite] can't write into
|
||||
/// [TypeVariable]s, which are also [Variable]s.
|
||||
/// [TypeVariable]s, which are also [VariableBase]s.
|
||||
class VariableWrite extends Expression {
|
||||
final ExpressionVariable variable;
|
||||
final Variable variable;
|
||||
final Expression value;
|
||||
|
||||
VariableWrite({required this.variable, required this.value});
|
||||
|
||||
@@ -879,7 +879,7 @@ class WildcardPattern extends Pattern {
|
||||
class AssignedVariablePattern extends Pattern {
|
||||
VariableDeclaration get variable => expressionVariable as VariableDeclaration;
|
||||
|
||||
final ExpressionVariable expressionVariable;
|
||||
final Variable expressionVariable;
|
||||
|
||||
/// The type of the expression against which this pattern is matched.
|
||||
///
|
||||
|
||||
@@ -629,7 +629,7 @@ class ForInStatement extends Statement implements LoopStatement, ScopeProvider {
|
||||
@override
|
||||
List<int>? get fileOffsetsIfMultiple => [fileOffset, bodyOffset];
|
||||
|
||||
ExpressionVariable expressionVariable;
|
||||
Variable expressionVariable;
|
||||
|
||||
// Has no initializer.
|
||||
VariableDeclaration get variable => expressionVariable as VariableDeclaration;
|
||||
@@ -1441,7 +1441,7 @@ abstract interface class VariableDeclaration
|
||||
implements
|
||||
Annotatable,
|
||||
Statement,
|
||||
ExpressionVariable,
|
||||
Variable,
|
||||
VariableInitialization,
|
||||
CatchVariable {
|
||||
/// The name of the variable as provided in the source code.
|
||||
@@ -1983,13 +1983,13 @@ class VariableStatement extends Statement implements VariableDeclaration {
|
||||
}
|
||||
|
||||
@override
|
||||
ExpressionVariable get asExpressionVariable => this;
|
||||
Variable get asExpressionVariable => this;
|
||||
|
||||
@override
|
||||
ExpressionVariable get variable => this;
|
||||
Variable get variable => this;
|
||||
|
||||
@override
|
||||
void set variable(ExpressionVariable value) {
|
||||
void set variable(Variable value) {
|
||||
throw new UnsupportedError("${this.runtimeType}");
|
||||
}
|
||||
|
||||
@@ -2104,7 +2104,7 @@ class FunctionDeclaration extends Statement implements LocalFunction {
|
||||
/// an initializer.
|
||||
class VariableInitialization extends Statement
|
||||
implements Annotatable, ContextConsumer {
|
||||
ExpressionVariable variable;
|
||||
Variable variable;
|
||||
|
||||
Expression? initializer;
|
||||
|
||||
@@ -2311,5 +2311,5 @@ class VariableInitialization extends Statement
|
||||
|
||||
VariableContext get context => variable.context;
|
||||
|
||||
ExpressionVariable get asExpressionVariable => variable;
|
||||
Variable get asExpressionVariable => variable;
|
||||
}
|
||||
|
||||
@@ -2354,7 +2354,7 @@ class RecordType extends DartType implements SharedRecordType {
|
||||
/// [TypeVariable] represents type variables of functions, such as top-level
|
||||
/// methods, static and instance methods, local declarations, and function
|
||||
/// expressions.
|
||||
class TypeVariable extends Variable {
|
||||
class TypeVariable extends VariableBase {
|
||||
@override
|
||||
String? cosmeticName;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
part of '../../ast.dart';
|
||||
|
||||
/// Generalized notion of a variable.
|
||||
sealed class Variable extends TreeNode implements Annotatable {
|
||||
sealed class VariableBase extends TreeNode implements Annotatable {
|
||||
VariableContext get context => parent as VariableContext;
|
||||
|
||||
/// The cosmetic name of the variable from the source code, if exists.
|
||||
@@ -22,10 +22,10 @@ sealed class Variable extends TreeNode implements Annotatable {
|
||||
}
|
||||
|
||||
/// This is a helper class to enable mixing a mixin into concrete
|
||||
/// implementations of the sealed class [ExpressionVariable]. It's not supposed
|
||||
/// implementations of the sealed class [Variable]. It's not supposed
|
||||
/// to be used as a type annotation, but purely for declaring the class
|
||||
/// hierarchy.
|
||||
abstract interface class IExpressionVariable implements TreeNode {
|
||||
abstract interface class IVariable implements TreeNode {
|
||||
abstract DartType type;
|
||||
abstract String? cosmeticName;
|
||||
abstract VariableInitialization? variableInitialization;
|
||||
@@ -59,12 +59,11 @@ abstract interface class IExpressionVariable implements TreeNode {
|
||||
bool get hasIsWildcard;
|
||||
bool get hasIsSuperInitializingFormal;
|
||||
bool get hasIsErroneouslyInitialized;
|
||||
ExpressionVariable get asExpressionVariable;
|
||||
Variable get asExpressionVariable;
|
||||
}
|
||||
|
||||
/// The root of the sealed hierarchy of non-type variables.
|
||||
sealed class ExpressionVariable extends Variable
|
||||
implements IExpressionVariable {
|
||||
sealed class Variable extends VariableBase implements IVariable {
|
||||
/// Static type of the variable.
|
||||
@override
|
||||
abstract DartType type;
|
||||
@@ -141,14 +140,14 @@ sealed class ExpressionVariable extends Variable
|
||||
bool get isAssignable;
|
||||
|
||||
@override
|
||||
ExpressionVariable get asExpressionVariable => this;
|
||||
Variable get asExpressionVariable => this;
|
||||
}
|
||||
|
||||
/// Local variables. They aren't Statements. A [LocalVariable] is "declared" in
|
||||
/// the [VariableContext] it appears in. [VariableInitialization]
|
||||
/// (which is a [Statement]) marks the spot of the original variable declaration
|
||||
/// in the Dart program.
|
||||
class LocalVariable extends ExpressionVariable {
|
||||
class LocalVariable extends Variable {
|
||||
@override
|
||||
String? cosmeticName;
|
||||
|
||||
@@ -420,7 +419,7 @@ class LocalVariable extends ExpressionVariable {
|
||||
/// } catch (e, s) {
|
||||
/// bar();
|
||||
/// }
|
||||
class CatchVariable extends ExpressionVariable {
|
||||
class CatchVariable extends Variable {
|
||||
final String catchVariableName;
|
||||
|
||||
@override
|
||||
@@ -680,8 +679,7 @@ class CatchVariable extends ExpressionVariable {
|
||||
}
|
||||
|
||||
/// Abstract parameter class, the parent for positional and named parameters.
|
||||
sealed class FunctionParameter extends ExpressionVariable
|
||||
implements VariableDeclaration {
|
||||
sealed class FunctionParameter extends Variable implements VariableDeclaration {
|
||||
Expression? defaultValue;
|
||||
|
||||
FunctionParameter(
|
||||
@@ -1013,10 +1011,10 @@ class PositionalParameter extends FunctionParameter {
|
||||
int fileEqualsOffset = TreeNode.noOffset;
|
||||
|
||||
@override
|
||||
ExpressionVariable get variable => this;
|
||||
Variable get variable => this;
|
||||
|
||||
@override
|
||||
void set variable(ExpressionVariable value) {
|
||||
void set variable(Variable value) {
|
||||
throw new UnsupportedError("${this.runtimeType}");
|
||||
}
|
||||
}
|
||||
@@ -1162,16 +1160,16 @@ class NamedParameter extends FunctionParameter {
|
||||
}
|
||||
|
||||
@override
|
||||
ExpressionVariable get variable => this;
|
||||
Variable get variable => this;
|
||||
|
||||
@override
|
||||
void set variable(ExpressionVariable value) {
|
||||
void set variable(Variable value) {
|
||||
throw new UnsupportedError("${this.runtimeType}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The variable storage for `this`.
|
||||
class ThisVariable extends ExpressionVariable {
|
||||
class ThisVariable extends Variable {
|
||||
@override
|
||||
String get cosmeticName => "this-variable";
|
||||
|
||||
@@ -1417,7 +1415,7 @@ class ThisVariable extends ExpressionVariable {
|
||||
|
||||
/// A variable introduced during desugaring. Such variables don't correspond to
|
||||
/// any variable declared by the programmer.
|
||||
class SyntheticVariable extends ExpressionVariable {
|
||||
class SyntheticVariable extends Variable {
|
||||
@override
|
||||
String? cosmeticName;
|
||||
|
||||
@@ -1671,11 +1669,11 @@ enum CaptureKind {
|
||||
/// environments.
|
||||
class VariableContext extends TreeNode {
|
||||
final CaptureKind captureKind;
|
||||
final List<Variable> variables;
|
||||
final List<VariableBase> variables;
|
||||
|
||||
VariableContext({required this.captureKind, required this.variables});
|
||||
|
||||
void addVariable(Variable variable) {
|
||||
void addVariable(VariableBase variable) {
|
||||
variable.parent = this;
|
||||
variables.add(variable);
|
||||
}
|
||||
|
||||
@@ -10014,34 +10014,34 @@ class EquivalenceStrategy {
|
||||
node.annotations, other.annotations, visitor.checkNodes, 'annotations');
|
||||
}
|
||||
|
||||
bool checkVariable_flags(
|
||||
EquivalenceVisitor visitor, Variable node, Variable other) {
|
||||
bool checkVariableBase_flags(
|
||||
EquivalenceVisitor visitor, VariableBase node, VariableBase other) {
|
||||
return visitor.checkValues(node.flags, other.flags, 'flags');
|
||||
}
|
||||
|
||||
bool checkExpressionVariable_flags(EquivalenceVisitor visitor,
|
||||
ExpressionVariable node, ExpressionVariable other) {
|
||||
return checkVariable_flags(visitor, node, other);
|
||||
bool checkVariable_flags(
|
||||
EquivalenceVisitor visitor, Variable node, Variable other) {
|
||||
return checkVariableBase_flags(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkCatchVariable_flags(
|
||||
EquivalenceVisitor visitor, CatchVariable node, CatchVariable other) {
|
||||
return checkExpressionVariable_flags(visitor, node, other);
|
||||
return checkVariable_flags(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkVariableBase_fileOffset(
|
||||
EquivalenceVisitor visitor, VariableBase node, VariableBase other) {
|
||||
return checkTreeNode_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkVariable_fileOffset(
|
||||
EquivalenceVisitor visitor, Variable node, Variable other) {
|
||||
return checkTreeNode_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkExpressionVariable_fileOffset(EquivalenceVisitor visitor,
|
||||
ExpressionVariable node, ExpressionVariable other) {
|
||||
return checkVariable_fileOffset(visitor, node, other);
|
||||
return checkVariableBase_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkCatchVariable_fileOffset(
|
||||
EquivalenceVisitor visitor, CatchVariable node, CatchVariable other) {
|
||||
return checkExpressionVariable_fileOffset(visitor, node, other);
|
||||
return checkVariable_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkLocalVariable_cosmeticName(
|
||||
@@ -10069,12 +10069,12 @@ class EquivalenceStrategy {
|
||||
|
||||
bool checkLocalVariable_flags(
|
||||
EquivalenceVisitor visitor, LocalVariable node, LocalVariable other) {
|
||||
return checkExpressionVariable_flags(visitor, node, other);
|
||||
return checkVariable_flags(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkLocalVariable_fileOffset(
|
||||
EquivalenceVisitor visitor, LocalVariable node, LocalVariable other) {
|
||||
return checkExpressionVariable_fileOffset(visitor, node, other);
|
||||
return checkVariable_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkPositionalParameter_cosmeticName(EquivalenceVisitor visitor,
|
||||
@@ -10119,7 +10119,7 @@ class EquivalenceStrategy {
|
||||
|
||||
bool checkFunctionParameter_flags(EquivalenceVisitor visitor,
|
||||
FunctionParameter node, FunctionParameter other) {
|
||||
return checkExpressionVariable_flags(visitor, node, other);
|
||||
return checkVariable_flags(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkPositionalParameter_flags(EquivalenceVisitor visitor,
|
||||
@@ -10129,7 +10129,7 @@ class EquivalenceStrategy {
|
||||
|
||||
bool checkFunctionParameter_fileOffset(EquivalenceVisitor visitor,
|
||||
FunctionParameter node, FunctionParameter other) {
|
||||
return checkExpressionVariable_fileOffset(visitor, node, other);
|
||||
return checkVariable_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkPositionalParameter_fileOffset(EquivalenceVisitor visitor,
|
||||
@@ -10194,12 +10194,12 @@ class EquivalenceStrategy {
|
||||
|
||||
bool checkThisVariable_flags(
|
||||
EquivalenceVisitor visitor, ThisVariable node, ThisVariable other) {
|
||||
return checkExpressionVariable_flags(visitor, node, other);
|
||||
return checkVariable_flags(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkThisVariable_fileOffset(
|
||||
EquivalenceVisitor visitor, ThisVariable node, ThisVariable other) {
|
||||
return checkExpressionVariable_fileOffset(visitor, node, other);
|
||||
return checkVariable_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkSyntheticVariable_cosmeticName(EquivalenceVisitor visitor,
|
||||
@@ -10227,12 +10227,12 @@ class EquivalenceStrategy {
|
||||
|
||||
bool checkSyntheticVariable_flags(EquivalenceVisitor visitor,
|
||||
SyntheticVariable node, SyntheticVariable other) {
|
||||
return checkExpressionVariable_flags(visitor, node, other);
|
||||
return checkVariable_flags(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkSyntheticVariable_fileOffset(EquivalenceVisitor visitor,
|
||||
SyntheticVariable node, SyntheticVariable other) {
|
||||
return checkExpressionVariable_fileOffset(visitor, node, other);
|
||||
return checkVariable_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkTypeVariable_cosmeticName(
|
||||
@@ -10255,12 +10255,12 @@ class EquivalenceStrategy {
|
||||
|
||||
bool checkTypeVariable_flags(
|
||||
EquivalenceVisitor visitor, TypeVariable node, TypeVariable other) {
|
||||
return checkVariable_flags(visitor, node, other);
|
||||
return checkVariableBase_flags(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkTypeVariable_fileOffset(
|
||||
EquivalenceVisitor visitor, TypeVariable node, TypeVariable other) {
|
||||
return checkVariable_fileOffset(visitor, node, other);
|
||||
return checkVariableBase_fileOffset(visitor, node, other);
|
||||
}
|
||||
|
||||
bool checkNominalParameter_flags(EquivalenceVisitor visitor,
|
||||
|
||||
@@ -98,7 +98,7 @@ class AstPrinter {
|
||||
int _indentationLevel = 0;
|
||||
late final Map<LabeledStatement, String> _labelNames = {};
|
||||
late final Map<VariableDeclaration, String> _variableDeclarationNames = {};
|
||||
late final Map<Variable, String> _variableNames = {};
|
||||
late final Map<VariableBase, String> _variableNames = {};
|
||||
|
||||
AstPrinter(this._strategy);
|
||||
|
||||
@@ -203,7 +203,7 @@ class AstPrinter {
|
||||
return _labelNames[node] ??= 'label${_labelNames.length}';
|
||||
}
|
||||
|
||||
String getVariableName(Variable node) {
|
||||
String getVariableName(VariableBase node) {
|
||||
switch (node) {
|
||||
case NamedParameter(parameterName: var name):
|
||||
case PositionalParameter(cosmeticName: var name?):
|
||||
@@ -513,7 +513,7 @@ class AstPrinter {
|
||||
///
|
||||
/// If [isLate] and [type] are provided, these values are used instead of
|
||||
/// the corresponding properties on [node].
|
||||
void writeExpressionVariable(ExpressionVariable node,
|
||||
void writeExpressionVariable(Variable node,
|
||||
{bool includeModifiersAndType = true, bool? isLate, DartType? type}) {
|
||||
if (includeModifiersAndType) {
|
||||
if (node is FunctionParameter && node.isRequired) {
|
||||
|
||||
@@ -137,8 +137,8 @@ String componentToString(Component node) {
|
||||
}
|
||||
|
||||
class NameSystem {
|
||||
final Namer<ExpressionVariable> variables =
|
||||
new NormalNamer<ExpressionVariable>('#t');
|
||||
final Namer<Variable> variables =
|
||||
new NormalNamer<Variable>('#t');
|
||||
final Namer<Reference> libraries = new NormalNamer<Reference>('#lib');
|
||||
final Namer<TypeParameter> typeParameters =
|
||||
new NormalNamer<TypeParameter>('#T');
|
||||
@@ -151,7 +151,7 @@ class NameSystem {
|
||||
final Disambiguator<Reference, CanonicalName> prefixes =
|
||||
new Disambiguator<Reference, CanonicalName>();
|
||||
|
||||
String nameVariable(ExpressionVariable node) => variables.getName(node);
|
||||
String nameVariable(Variable node) => variables.getName(node);
|
||||
String nameLibrary(Reference node) => libraries.getName(node);
|
||||
String nameTypeParameter(TypeParameter node) => typeParameters.getName(node);
|
||||
String nameStructuralParameter(StructuralParameter node) =>
|
||||
@@ -347,11 +347,11 @@ class Printer extends VisitorDefault<void> with VisitorVoidMixin {
|
||||
}
|
||||
}
|
||||
|
||||
String getVariableName(ExpressionVariable node) {
|
||||
String getVariableName(Variable node) {
|
||||
return node.cosmeticName ?? syntheticNames.nameVariable(node);
|
||||
}
|
||||
|
||||
String getVariableReference(ExpressionVariable node) {
|
||||
String getVariableReference(Variable node) {
|
||||
return getVariableName(node);
|
||||
}
|
||||
|
||||
@@ -1049,7 +1049,7 @@ class Printer extends VisitorDefault<void> with VisitorVoidMixin {
|
||||
writeWord(getTypedefReference(typedefNode));
|
||||
}
|
||||
|
||||
void writeVariableReference(ExpressionVariable variable) {
|
||||
void writeVariableReference(Variable variable) {
|
||||
final bool highlight = shouldHighlight(variable);
|
||||
if (highlight) {
|
||||
startHighlight(variable);
|
||||
@@ -1183,7 +1183,7 @@ class Printer extends VisitorDefault<void> with VisitorVoidMixin {
|
||||
endLine(';');
|
||||
}
|
||||
|
||||
void writeExpressionVariable(ExpressionVariable node) {
|
||||
void writeExpressionVariable(Variable node) {
|
||||
if (node is VariableDeclaration && node is! FunctionParameter) {
|
||||
writeVariableDeclaration(node);
|
||||
} else {
|
||||
|
||||
@@ -134,9 +134,9 @@ class VerifyingVisitor extends RecursiveResultVisitor<void> {
|
||||
Set<TypeParameter> typeParametersInScope = new Set<TypeParameter>();
|
||||
Set<StructuralParameter> structuralParametersInScope =
|
||||
new Set<StructuralParameter>();
|
||||
Set<ExpressionVariable> variableDeclarationsInScope =
|
||||
new Set<ExpressionVariable>();
|
||||
final List<ExpressionVariable> variableStack = <ExpressionVariable>[];
|
||||
Set<Variable> variableDeclarationsInScope =
|
||||
new Set<Variable>();
|
||||
final List<Variable> variableStack = <Variable>[];
|
||||
final Map<Typedef, TypedefState> typedefState = <Typedef, TypedefState>{};
|
||||
final Set<Constant> seenConstants = <Constant>{};
|
||||
|
||||
@@ -243,7 +243,7 @@ class VerifyingVisitor extends RecursiveResultVisitor<void> {
|
||||
// TODO(cstefantsova): Remove this method when the new variable model is
|
||||
// supported.
|
||||
bool _isNewModelVariable(TreeNode node) {
|
||||
return node is ExpressionVariable && node is! VariableDeclaration ||
|
||||
return node is Variable && node is! VariableDeclaration ||
|
||||
node is FunctionParameter;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ class VerifyingVisitor extends RecursiveResultVisitor<void> {
|
||||
exitTreeNode(node);
|
||||
}
|
||||
|
||||
void declareVariable(ExpressionVariable variable) {
|
||||
void declareVariable(Variable variable) {
|
||||
if (variableDeclarationsInScope.contains(variable)) {
|
||||
problem(variable, "Variable '$variable' declared more than once.");
|
||||
}
|
||||
@@ -302,7 +302,7 @@ class VerifyingVisitor extends RecursiveResultVisitor<void> {
|
||||
variableStack.add(variable);
|
||||
}
|
||||
|
||||
void undeclareVariable(ExpressionVariable variable) {
|
||||
void undeclareVariable(Variable variable) {
|
||||
variableDeclarationsInScope.remove(variable);
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ class VerifyingVisitor extends RecursiveResultVisitor<void> {
|
||||
structuralParametersInScope.removeAll(parameters);
|
||||
}
|
||||
|
||||
void checkVariableInScope(ExpressionVariable variable, TreeNode where) {
|
||||
void checkVariableInScope(Variable variable, TreeNode where) {
|
||||
if (!variableDeclarationsInScope.contains(variable)) {
|
||||
problem(where, "Variable '$variable' used out of scope.");
|
||||
}
|
||||
|
||||
@@ -272,14 +272,15 @@ class ForInLowering {
|
||||
final Block body = Block([syncForLoopVariableInitialization, stmt.body])
|
||||
..fileOffset = stmt.bodyOffset;
|
||||
|
||||
final forStatement = ForStatement([], condition, [], body)
|
||||
..scope = stmt.scope
|
||||
..fileOffset = stmt.fileOffset;
|
||||
final forStatement =
|
||||
ForStatement([], condition, [], body)
|
||||
..scope = stmt.scope
|
||||
..fileOffset = stmt.fileOffset;
|
||||
|
||||
return Block([syncForIteratorVariableInitialization, forStatement]);
|
||||
}
|
||||
|
||||
(ExpressionVariable, VariableInitialization)
|
||||
(Variable, VariableInitialization)
|
||||
_createSyncForIteratorVariableAndInitialization({
|
||||
required Expression initializer,
|
||||
required DartType type,
|
||||
@@ -307,7 +308,7 @@ class ForInLowering {
|
||||
}
|
||||
|
||||
VariableInitialization _ensureSyncForLoopVariableInitialization({
|
||||
required ExpressionVariable variable,
|
||||
required Variable variable,
|
||||
required Expression initializer,
|
||||
}) {
|
||||
if (isClosureContextLoweringEnabled) {
|
||||
|
||||
Reference in New Issue
Block a user