mirror of
https://github.com/dart-lang/sdk
synced 2024-10-02 23:59:16 +00:00
[dart2js] dart format --fix on ir/
Change-Id: Iae34547b8ea7840fdd7b6e5c3b95e8ee4ca3e670 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213861 Reviewed-by: Joshua Litt <joshualitt@google.com> Commit-Queue: Stephen Adams <sra@google.com>
This commit is contained in:
parent
6e3de72138
commit
552573ac93
|
@ -123,10 +123,10 @@ class IrAnnotationData {
|
|||
|
||||
IrAnnotationData processAnnotations(ModularCore modularCore) {
|
||||
ir.Component component = modularCore.component;
|
||||
IrAnnotationData data = new IrAnnotationData();
|
||||
IrAnnotationData data = IrAnnotationData();
|
||||
|
||||
void processMember(ir.Member member) {
|
||||
ir.StaticTypeContext staticTypeContext = new ir.StaticTypeContext(
|
||||
ir.StaticTypeContext staticTypeContext = ir.StaticTypeContext(
|
||||
member, modularCore.constantEvaluator.typeEnvironment);
|
||||
List<PragmaAnnotationData> pragmaAnnotations;
|
||||
List<String> createsAnnotations;
|
||||
|
@ -180,7 +180,7 @@ IrAnnotationData processAnnotations(ModularCore modularCore) {
|
|||
|
||||
for (ir.Library library in component.libraries) {
|
||||
ir.StaticTypeContext staticTypeContext =
|
||||
new ir.StaticTypeContext.forAnnotations(
|
||||
ir.StaticTypeContext.forAnnotations(
|
||||
library, modularCore.constantEvaluator.typeEnvironment);
|
||||
for (ir.Expression annotation in library.annotations) {
|
||||
if (annotation is ir.ConstantExpression) {
|
||||
|
@ -324,7 +324,7 @@ class PragmaAnnotationData {
|
|||
// TODO(johnniwinther): Support options objects when necessary.
|
||||
final bool hasOptions;
|
||||
|
||||
const PragmaAnnotationData(this.suffix, {this.hasOptions: false});
|
||||
const PragmaAnnotationData(this.suffix, {this.hasOptions = false});
|
||||
|
||||
String get name => 'dart2js:$suffix';
|
||||
|
||||
|
@ -360,7 +360,7 @@ PragmaAnnotationData _getPragmaAnnotation(ir.Constant constant) {
|
|||
String prefix = 'dart2js:';
|
||||
if (!name.startsWith(prefix)) return null;
|
||||
String suffix = name.substring(prefix.length);
|
||||
return new PragmaAnnotationData(suffix,
|
||||
return PragmaAnnotationData(suffix,
|
||||
hasOptions: optionsValue is! ir.NullConstant);
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -37,7 +37,7 @@ class KernelScopeInfo {
|
|||
/// this scope. The items in this set are either of type VariableDeclaration
|
||||
/// or TypeParameterTypeWithContext.
|
||||
Set<ir.Node /* VariableDeclaration | TypeParameterTypeWithContext */ >
|
||||
freeVariables = new Set<ir.Node>();
|
||||
freeVariables = Set<ir.Node>();
|
||||
|
||||
/// A set of type parameters that are defined in another scope and are only
|
||||
/// used if runtime type information is checked. If runtime type information
|
||||
|
@ -57,11 +57,11 @@ class KernelScopeInfo {
|
|||
/// performing runtime type checks. It is stored
|
||||
/// separately from [thisUsedAsFreeVariable] because we don't know at this
|
||||
/// stage if we will be needing type checks for this scope.
|
||||
Set<VariableUse> thisUsedAsFreeVariableIfNeedsRti = new Set<VariableUse>();
|
||||
Set<VariableUse> thisUsedAsFreeVariableIfNeedsRti = Set<VariableUse>();
|
||||
|
||||
KernelScopeInfo(this.hasThisLocal)
|
||||
: localsUsedInTryOrSync = new Set<ir.VariableDeclaration>(),
|
||||
boxedVariables = new Set<ir.VariableDeclaration>(),
|
||||
: localsUsedInTryOrSync = Set<ir.VariableDeclaration>(),
|
||||
boxedVariables = Set<ir.VariableDeclaration>(),
|
||||
capturedVariablesAccessor = null;
|
||||
|
||||
KernelScopeInfo.from(this.hasThisLocal, KernelScopeInfo info)
|
||||
|
@ -81,7 +81,7 @@ class KernelScopeInfo {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
sb.write('KernelScopeInfo(this=$hasThisLocal,');
|
||||
sb.write('freeVriables=$freeVariables,');
|
||||
sb.write('localsUsedInTryOrSync={${localsUsedInTryOrSync.join(', ')}}');
|
||||
|
@ -132,7 +132,7 @@ class KernelCapturedScope extends KernelScopeInfo {
|
|||
scope.hasThisLocal);
|
||||
|
||||
// Silly hack because we don't have const sets.
|
||||
static final Set<ir.VariableDeclaration> _empty = new Set();
|
||||
static final Set<ir.VariableDeclaration> _empty = Set();
|
||||
|
||||
bool get requiresContextBox => boxedVariables.isNotEmpty;
|
||||
}
|
||||
|
@ -293,25 +293,25 @@ class VariableUse {
|
|||
this.invocation = null;
|
||||
|
||||
static const VariableUse explicit =
|
||||
const VariableUse._simple(VariableUseKind.explicit);
|
||||
VariableUse._simple(VariableUseKind.explicit);
|
||||
|
||||
static const VariableUse localType =
|
||||
const VariableUse._simple(VariableUseKind.localType);
|
||||
VariableUse._simple(VariableUseKind.localType);
|
||||
|
||||
static const VariableUse implicitCast =
|
||||
const VariableUse._simple(VariableUseKind.implicitCast);
|
||||
VariableUse._simple(VariableUseKind.implicitCast);
|
||||
|
||||
static const VariableUse listLiteral =
|
||||
const VariableUse._simple(VariableUseKind.listLiteral);
|
||||
VariableUse._simple(VariableUseKind.listLiteral);
|
||||
|
||||
static const VariableUse setLiteral =
|
||||
const VariableUse._simple(VariableUseKind.setLiteral);
|
||||
VariableUse._simple(VariableUseKind.setLiteral);
|
||||
|
||||
static const VariableUse mapLiteral =
|
||||
const VariableUse._simple(VariableUseKind.mapLiteral);
|
||||
VariableUse._simple(VariableUseKind.mapLiteral);
|
||||
|
||||
static const VariableUse fieldType =
|
||||
const VariableUse._simple(VariableUseKind.fieldType);
|
||||
VariableUse._simple(VariableUseKind.fieldType);
|
||||
|
||||
@override
|
||||
int get hashCode =>
|
||||
|
@ -386,7 +386,7 @@ class TypeVariableTypeWithContext implements ir.Node {
|
|||
typeDeclaration = typeDeclaration.parent;
|
||||
context = typeDeclaration;
|
||||
}
|
||||
return new TypeVariableTypeWithContext.internal(
|
||||
return TypeVariableTypeWithContext.internal(
|
||||
type, context, kind, typeDeclaration);
|
||||
}
|
||||
|
||||
|
@ -395,17 +395,17 @@ class TypeVariableTypeWithContext implements ir.Node {
|
|||
|
||||
@override
|
||||
R accept<R>(ir.Visitor<R> v) {
|
||||
throw new UnsupportedError('TypeVariableTypeWithContext.accept');
|
||||
throw UnsupportedError('TypeVariableTypeWithContext.accept');
|
||||
}
|
||||
|
||||
@override
|
||||
R accept1<R, A>(ir.Visitor1<R, A> v, A arg) {
|
||||
throw new UnsupportedError('TypeVariableTypeWithContext.accept1');
|
||||
throw UnsupportedError('TypeVariableTypeWithContext.accept1');
|
||||
}
|
||||
|
||||
@override
|
||||
visitChildren(ir.Visitor v) {
|
||||
throw new UnsupportedError('TypeVariableTypeWithContext.visitChildren');
|
||||
throw UnsupportedError('TypeVariableTypeWithContext.visitChildren');
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -20,8 +20,8 @@ class Dart2jsConstantEvaluator extends ir.ConstantEvaluator {
|
|||
|
||||
Dart2jsConstantEvaluator(
|
||||
ir.TypeEnvironment typeEnvironment, ReportErrorFunction reportError,
|
||||
{Map<String, String> environment: const {},
|
||||
bool supportReevaluationForTesting: false,
|
||||
{Map<String, String> environment = const {},
|
||||
bool supportReevaluationForTesting = false,
|
||||
ir.EvaluationMode evaluationMode})
|
||||
: _supportReevaluationForTesting = supportReevaluationForTesting,
|
||||
assert(evaluationMode != null),
|
||||
|
@ -29,7 +29,7 @@ class Dart2jsConstantEvaluator extends ir.ConstantEvaluator {
|
|||
const Dart2jsConstantsBackend(supportsUnevaluatedConstants: false),
|
||||
environment,
|
||||
typeEnvironment,
|
||||
new ErrorReporter(reportError),
|
||||
ErrorReporter(reportError),
|
||||
enableTripleShift: true,
|
||||
evaluationMode: evaluationMode);
|
||||
|
||||
|
@ -49,8 +49,8 @@ class Dart2jsConstantEvaluator extends ir.ConstantEvaluator {
|
|||
ir.Constant evaluate(
|
||||
ir.StaticTypeContext staticTypeContext, ir.Expression node,
|
||||
{ir.TreeNode contextNode,
|
||||
bool requireConstant: true,
|
||||
bool replaceImplicitConstant: true}) {
|
||||
bool requireConstant = true,
|
||||
bool replaceImplicitConstant = true}) {
|
||||
errorReporter.requiresConstant = requireConstant;
|
||||
if (node is ir.ConstantExpression) {
|
||||
ir.Constant constant = node.constant;
|
||||
|
@ -189,27 +189,27 @@ class ConstantReference extends ir.TreeNode {
|
|||
|
||||
@override
|
||||
void visitChildren(ir.Visitor v) {
|
||||
throw new UnsupportedError("ConstantReference.visitChildren");
|
||||
throw UnsupportedError("ConstantReference.visitChildren");
|
||||
}
|
||||
|
||||
@override
|
||||
R accept<R>(ir.TreeVisitor<R> v) {
|
||||
throw new UnsupportedError("ConstantReference.accept");
|
||||
throw UnsupportedError("ConstantReference.accept");
|
||||
}
|
||||
|
||||
@override
|
||||
R accept1<R, A>(ir.TreeVisitor1<R, A> v, A arg) {
|
||||
throw new UnsupportedError("ConstantReference.accept");
|
||||
throw UnsupportedError("ConstantReference.accept");
|
||||
}
|
||||
|
||||
@override
|
||||
transformChildren(ir.Transformer v) {
|
||||
throw new UnsupportedError("ConstantReference.transformChildren");
|
||||
throw UnsupportedError("ConstantReference.transformChildren");
|
||||
}
|
||||
|
||||
@override
|
||||
transformOrRemoveChildren(ir.RemovingTransformer v) {
|
||||
throw new UnsupportedError("ConstantReference.transformOrRemoveChildren");
|
||||
throw UnsupportedError("ConstantReference.transformOrRemoveChildren");
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -511,7 +511,7 @@ abstract class ImpactBuilderBase extends StaticTypeVisitor
|
|||
// instantiated as int and String.
|
||||
registerNew(
|
||||
node.target,
|
||||
new ir.InterfaceType(node.target.enclosingClass,
|
||||
ir.InterfaceType(node.target.enclosingClass,
|
||||
node.target.enclosingLibrary.nonNullable, typeArguments),
|
||||
positionArguments,
|
||||
namedArguments,
|
||||
|
@ -679,7 +679,7 @@ abstract class ImpactBuilderBase extends StaticTypeVisitor
|
|||
@override
|
||||
void handleConstantExpression(ir.ConstantExpression node) {
|
||||
ir.LibraryDependency import = getDeferredImport(node);
|
||||
new ConstantImpactVisitor(this, import, node, staticTypeContext)
|
||||
ConstantImpactVisitor(this, import, node, staticTypeContext)
|
||||
.visitConstant(node.constant);
|
||||
}
|
||||
}
|
||||
|
@ -697,8 +697,8 @@ class ImpactBuilder extends ImpactBuilderBase with ImpactRegistryMixin {
|
|||
StaticTypeCacheImpl staticTypeCache,
|
||||
ir.ClassHierarchy classHierarchy,
|
||||
VariableScopeModel variableScopeModel,
|
||||
{this.useAsserts: false,
|
||||
this.inferEffectivelyFinalVariableTypes: true})
|
||||
{this.useAsserts = false,
|
||||
this.inferEffectivelyFinalVariableTypes = true})
|
||||
: super(staticTypeContext, staticTypeCache, classHierarchy,
|
||||
variableScopeModel);
|
||||
|
||||
|
@ -707,7 +707,7 @@ class ImpactBuilder extends ImpactBuilderBase with ImpactRegistryMixin {
|
|||
typeMapsForTesting = {};
|
||||
}
|
||||
node.accept(this);
|
||||
return new ImpactBuilderData(
|
||||
return ImpactBuilderData(
|
||||
node, impactData, typeMapsForTesting, getStaticTypeCache());
|
||||
}
|
||||
}
|
||||
|
@ -756,7 +756,7 @@ class ConstantImpactVisitor extends ir.VisitOnceConstantVisitor {
|
|||
|
||||
@override
|
||||
void defaultConstant(ir.Constant node) {
|
||||
throw new UnsupportedError(
|
||||
throw UnsupportedError(
|
||||
"Unexpected constant ${node} (${node.runtimeType}).");
|
||||
}
|
||||
|
||||
|
@ -795,7 +795,7 @@ class ConstantImpactVisitor extends ir.VisitOnceConstantVisitor {
|
|||
node.fieldValues.forEach((ir.Reference reference, ir.Constant value) {
|
||||
ir.Field field = reference.asField;
|
||||
registry.registerFieldConstantInitialization(
|
||||
field, new ConstantReference(expression, value));
|
||||
field, ConstantReference(expression, value));
|
||||
visitConstant(value);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,18 +13,18 @@ import 'static_type.dart';
|
|||
|
||||
/// [ImpactRegistry] that stores registered impact in an [ImpactData] object.
|
||||
abstract class ImpactRegistryMixin implements ImpactRegistry {
|
||||
final ImpactDataImpl _data = new ImpactDataImpl();
|
||||
final ImpactDataImpl _data = ImpactDataImpl();
|
||||
|
||||
ImpactData get impactData => _data;
|
||||
|
||||
void _registerFeature(_Feature feature) {
|
||||
_data._features ??= new EnumSet<_Feature>();
|
||||
_data._features ??= EnumSet<_Feature>();
|
||||
_data._features.add(feature);
|
||||
}
|
||||
|
||||
void _registerTypeUse(ir.DartType type, _TypeUseKind kind) {
|
||||
_data._typeUses ??= [];
|
||||
_data._typeUses.add(new _TypeUse(type, kind));
|
||||
_data._typeUses.add(_TypeUse(type, kind));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -35,11 +35,8 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
List<String> namedArguments,
|
||||
List<ir.DartType> typeArguments) {
|
||||
_data._superInitializers ??= [];
|
||||
_data._superInitializers.add(new _SuperInitializer(
|
||||
source,
|
||||
target,
|
||||
new _CallStructure(
|
||||
positionalArguments, namedArguments, typeArguments)));
|
||||
_data._superInitializers.add(_SuperInitializer(source, target,
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -58,40 +55,36 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
void registerSuperInvocation(ir.Member target, int positionalArguments,
|
||||
List<String> namedArguments, List<ir.DartType> typeArguments) {
|
||||
_data._superInvocations ??= [];
|
||||
_data._superInvocations.add(new _SuperInvocation(
|
||||
target,
|
||||
new _CallStructure(
|
||||
positionalArguments, namedArguments, typeArguments)));
|
||||
_data._superInvocations.add(_SuperInvocation(target,
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments)));
|
||||
}
|
||||
|
||||
@override
|
||||
void registerInstanceSet(
|
||||
ir.DartType receiverType, ClassRelation relation, ir.Member target) {
|
||||
_data._instanceSets ??= [];
|
||||
_data._instanceSets
|
||||
.add(new _InstanceAccess(receiverType, relation, target));
|
||||
_data._instanceSets.add(_InstanceAccess(receiverType, relation, target));
|
||||
}
|
||||
|
||||
@override
|
||||
void registerDynamicSet(
|
||||
ir.DartType receiverType, ClassRelation relation, ir.Name name) {
|
||||
_data._dynamicSets ??= [];
|
||||
_data._dynamicSets.add(new _DynamicAccess(receiverType, relation, name));
|
||||
_data._dynamicSets.add(_DynamicAccess(receiverType, relation, name));
|
||||
}
|
||||
|
||||
@override
|
||||
void registerInstanceGet(
|
||||
ir.DartType receiverType, ClassRelation relation, ir.Member target) {
|
||||
_data._instanceGets ??= [];
|
||||
_data._instanceGets
|
||||
.add(new _InstanceAccess(receiverType, relation, target));
|
||||
_data._instanceGets.add(_InstanceAccess(receiverType, relation, target));
|
||||
}
|
||||
|
||||
@override
|
||||
void registerDynamicGet(
|
||||
ir.DartType receiverType, ClassRelation relation, ir.Name name) {
|
||||
_data._dynamicGets ??= [];
|
||||
_data._dynamicGets.add(new _DynamicAccess(receiverType, relation, name));
|
||||
_data._dynamicGets.add(_DynamicAccess(receiverType, relation, name));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -101,10 +94,8 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
List<String> namedArguments,
|
||||
List<ir.DartType> typeArguments) {
|
||||
_data._functionInvocations ??= [];
|
||||
_data._functionInvocations.add(new _FunctionInvocation(
|
||||
receiverType,
|
||||
new _CallStructure(
|
||||
positionalArguments, namedArguments, typeArguments)));
|
||||
_data._functionInvocations.add(_FunctionInvocation(receiverType,
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -116,12 +107,11 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
List<String> namedArguments,
|
||||
List<ir.DartType> typeArguments) {
|
||||
_data._instanceInvocations ??= [];
|
||||
_data._instanceInvocations.add(new _InstanceInvocation(
|
||||
_data._instanceInvocations.add(_InstanceInvocation(
|
||||
receiverType,
|
||||
relation,
|
||||
target,
|
||||
new _CallStructure(
|
||||
positionalArguments, namedArguments, typeArguments)));
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -133,12 +123,11 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
List<String> namedArguments,
|
||||
List<ir.DartType> typeArguments) {
|
||||
_data._dynamicInvocations ??= [];
|
||||
_data._dynamicInvocations.add(new _DynamicInvocation(
|
||||
_data._dynamicInvocations.add(_DynamicInvocation(
|
||||
receiverType,
|
||||
relation,
|
||||
name,
|
||||
new _CallStructure(
|
||||
positionalArguments, namedArguments, typeArguments)));
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -148,10 +137,8 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
List<String> namedArguments,
|
||||
List<ir.DartType> typeArguments) {
|
||||
_data._localFunctionInvocations ??= [];
|
||||
_data._localFunctionInvocations.add(new _LocalFunctionInvocation(
|
||||
localFunction,
|
||||
new _CallStructure(
|
||||
positionalArguments, namedArguments, typeArguments)));
|
||||
_data._localFunctionInvocations.add(_LocalFunctionInvocation(localFunction,
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -162,9 +149,9 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
List<ir.DartType> typeArguments,
|
||||
ir.LibraryDependency import) {
|
||||
_data._staticInvocations ??= [];
|
||||
_data._staticInvocations.add(new _StaticInvocation(
|
||||
_data._staticInvocations.add(_StaticInvocation(
|
||||
target,
|
||||
new _CallStructure(positionalArguments, namedArguments, typeArguments),
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments),
|
||||
import));
|
||||
}
|
||||
|
||||
|
@ -178,10 +165,10 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
ir.LibraryDependency import,
|
||||
{bool isConst}) {
|
||||
_data._constructorInvocations ??= [];
|
||||
_data._constructorInvocations.add(new _ConstructorInvocation(
|
||||
_data._constructorInvocations.add(_ConstructorInvocation(
|
||||
constructor,
|
||||
type,
|
||||
new _CallStructure(positionalArguments, namedArguments, typeArguments),
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments),
|
||||
import,
|
||||
isConst: isConst));
|
||||
}
|
||||
|
@ -191,7 +178,7 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
ir.LibraryDependency import) {
|
||||
_data._constInstantiations ??= [];
|
||||
_data._constInstantiations
|
||||
.add(new _ConstInstantiation(cls, typeArguments, import));
|
||||
.add(_ConstInstantiation(cls, typeArguments, import));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -211,10 +198,8 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
List<String> namedArguments,
|
||||
List<ir.DartType> typeArguments) {
|
||||
_data._redirectingInitializers ??= [];
|
||||
_data._redirectingInitializers.add(new _RedirectingInitializer(
|
||||
constructor,
|
||||
new _CallStructure(
|
||||
positionalArguments, namedArguments, typeArguments)));
|
||||
_data._redirectingInitializers.add(_RedirectingInitializer(constructor,
|
||||
_CallStructure(positionalArguments, namedArguments, typeArguments)));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -238,7 +223,7 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
@override
|
||||
void registerTypeLiteral(ir.DartType type, ir.LibraryDependency import) {
|
||||
_data._typeLiterals ??= [];
|
||||
_data._typeLiterals.add(new _TypeLiteral(type, import));
|
||||
_data._typeLiterals.add(_TypeLiteral(type, import));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -260,7 +245,7 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
void registerAsyncForIn(ir.DartType iterableType, ir.DartType iteratorType,
|
||||
ClassRelation iteratorClassRelation) {
|
||||
_data._forInData ??= [];
|
||||
_data._forInData.add(new _ForInData(
|
||||
_data._forInData.add(_ForInData(
|
||||
iterableType, iteratorType, iteratorClassRelation,
|
||||
isAsync: true));
|
||||
}
|
||||
|
@ -269,7 +254,7 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
void registerSyncForIn(ir.DartType iterableType, ir.DartType iteratorType,
|
||||
ClassRelation iteratorClassRelation) {
|
||||
_data._forInData ??= [];
|
||||
_data._forInData.add(new _ForInData(
|
||||
_data._forInData.add(_ForInData(
|
||||
iterableType, iteratorType, iteratorClassRelation,
|
||||
isAsync: false));
|
||||
}
|
||||
|
@ -330,7 +315,7 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
ir.FunctionType expressionType, List<ir.DartType> typeArguments) {
|
||||
_data._genericInstantiations ??= [];
|
||||
_data._genericInstantiations
|
||||
.add(new _GenericInstantiation(expressionType, typeArguments));
|
||||
.add(_GenericInstantiation(expressionType, typeArguments));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -343,28 +328,28 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
@override
|
||||
void registerStaticSet(ir.Member member, ir.LibraryDependency import) {
|
||||
_data._staticSets ??= [];
|
||||
_data._staticSets.add(new _StaticAccess(member, import));
|
||||
_data._staticSets.add(_StaticAccess(member, import));
|
||||
}
|
||||
|
||||
@override
|
||||
void registerStaticGet(ir.Member member, ir.LibraryDependency import) {
|
||||
_data._staticGets ??= [];
|
||||
_data._staticGets.add(new _StaticAccess(member, import));
|
||||
_data._staticGets.add(_StaticAccess(member, import));
|
||||
}
|
||||
|
||||
@override
|
||||
void registerStaticTearOff(
|
||||
ir.Procedure procedure, ir.LibraryDependency import) {
|
||||
_data._staticTearOffs ??= [];
|
||||
_data._staticTearOffs.add(new _StaticAccess(procedure, import));
|
||||
_data._staticTearOffs.add(_StaticAccess(procedure, import));
|
||||
}
|
||||
|
||||
@override
|
||||
void registerMapLiteral(ir.DartType keyType, ir.DartType valueType,
|
||||
{bool isConst, bool isEmpty}) {
|
||||
_data._mapLiterals ??= [];
|
||||
_data._mapLiterals.add(new _MapLiteral(keyType, valueType,
|
||||
isConst: isConst, isEmpty: isEmpty));
|
||||
_data._mapLiterals.add(
|
||||
_MapLiteral(keyType, valueType, isConst: isConst, isEmpty: isEmpty));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -372,7 +357,7 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
{bool isConst, bool isEmpty}) {
|
||||
_data._listLiterals ??= [];
|
||||
_data._listLiterals.add(
|
||||
new _ContainerLiteral(elementType, isConst: isConst, isEmpty: isEmpty));
|
||||
_ContainerLiteral(elementType, isConst: isConst, isEmpty: isEmpty));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -380,7 +365,7 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
{bool isConst, bool isEmpty}) {
|
||||
_data._setLiterals ??= [];
|
||||
_data._setLiterals.add(
|
||||
new _ContainerLiteral(elementType, isConst: isConst, isEmpty: isEmpty));
|
||||
_ContainerLiteral(elementType, isConst: isConst, isEmpty: isEmpty));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -425,7 +410,7 @@ abstract class ImpactRegistryMixin implements ImpactRegistry {
|
|||
ir.DartType receiverType, ir.DartType argumentType) {
|
||||
_data._runtimeTypeUses ??= [];
|
||||
_data._runtimeTypeUses
|
||||
.add(new _RuntimeTypeUse(node, kind, receiverType, argumentType));
|
||||
.add(_RuntimeTypeUse(node, kind, receiverType, argumentType));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -529,77 +514,72 @@ class ImpactDataImpl implements ImpactData {
|
|||
ImpactDataImpl.fromDataSource(DataSource source) {
|
||||
source.begin(tag);
|
||||
_superInitializers = source.readList(
|
||||
() => new _SuperInitializer.fromDataSource(source),
|
||||
() => _SuperInitializer.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_superSets =
|
||||
source.readList(() => source.readMemberNode(), emptyAsNull: true);
|
||||
_superGets =
|
||||
source.readList(() => source.readMemberNode(), emptyAsNull: true);
|
||||
_superInvocations = source.readList(
|
||||
() => new _SuperInvocation.fromDataSource(source),
|
||||
() => _SuperInvocation.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_instanceSets = source.readList(
|
||||
() => new _InstanceAccess.fromDataSource(source),
|
||||
() => _InstanceAccess.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_dynamicSets = source.readList(
|
||||
() => new _DynamicAccess.fromDataSource(source),
|
||||
_dynamicSets = source.readList(() => _DynamicAccess.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_instanceGets = source.readList(
|
||||
() => new _InstanceAccess.fromDataSource(source),
|
||||
() => _InstanceAccess.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_dynamicGets = source.readList(
|
||||
() => new _DynamicAccess.fromDataSource(source),
|
||||
_dynamicGets = source.readList(() => _DynamicAccess.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_functionInvocations = source.readList(
|
||||
() => new _FunctionInvocation.fromDataSource(source),
|
||||
() => _FunctionInvocation.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_instanceInvocations = source.readList(
|
||||
() => new _InstanceInvocation.fromDataSource(source),
|
||||
() => _InstanceInvocation.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_dynamicInvocations = source.readList(
|
||||
() => new _DynamicInvocation.fromDataSource(source),
|
||||
() => _DynamicInvocation.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_localFunctionInvocations = source.readList(
|
||||
() => new _LocalFunctionInvocation.fromDataSource(source),
|
||||
() => _LocalFunctionInvocation.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_staticInvocations = source.readList(
|
||||
() => new _StaticInvocation.fromDataSource(source),
|
||||
() => _StaticInvocation.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_constructorInvocations = source.readList(
|
||||
() => new _ConstructorInvocation.fromDataSource(source),
|
||||
() => _ConstructorInvocation.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_features = new EnumSet<_Feature>.fromValue(source.readInt());
|
||||
_typeUses = source.readList(() => new _TypeUse.fromDataSource(source),
|
||||
_features = EnumSet<_Feature>.fromValue(source.readInt());
|
||||
_typeUses = source.readList(() => _TypeUse.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_redirectingInitializers = source.readList(
|
||||
() => new _RedirectingInitializer.fromDataSource(source),
|
||||
() => _RedirectingInitializer.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_fieldInitializers = source.readMemberNodes<ir.Field>(emptyAsNull: true);
|
||||
_fieldConstantInitializers =
|
||||
source.readMemberNodeMap(source.readTreeNodes, emptyAsNull: true);
|
||||
_typeLiterals = source.readList(
|
||||
() => new _TypeLiteral.fromDataSource(source),
|
||||
_typeLiterals = source.readList(() => _TypeLiteral.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_localFunctions = source.readTreeNodes(emptyAsNull: true);
|
||||
_genericInstantiations = source.readList(
|
||||
() => new _GenericInstantiation.fromDataSource(source),
|
||||
() => _GenericInstantiation.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_staticSets = source.readList(
|
||||
() => new _StaticAccess.fromDataSource(source),
|
||||
_staticSets = source.readList(() => _StaticAccess.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_staticGets = source.readList(
|
||||
() => new _StaticAccess.fromDataSource(source),
|
||||
_staticGets = source.readList(() => _StaticAccess.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_staticTearOffs = source.readList(
|
||||
() => new _StaticAccess.fromDataSource(source),
|
||||
() => _StaticAccess.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_mapLiterals = source.readList(() => new _MapLiteral.fromDataSource(source),
|
||||
_mapLiterals = source.readList(() => _MapLiteral.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_listLiterals = source.readList(
|
||||
() => new _ContainerLiteral.fromDataSource(source),
|
||||
() => _ContainerLiteral.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_setLiterals = source.readList(
|
||||
() => new _ContainerLiteral.fromDataSource(source),
|
||||
() => _ContainerLiteral.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
_symbolLiterals = source.readStrings(emptyAsNull: true)?.toSet();
|
||||
_stringLiterals = source.readStrings(emptyAsNull: true)?.toSet();
|
||||
|
@ -612,7 +592,7 @@ class ImpactDataImpl implements ImpactData {
|
|||
.readList(() => source.readIntegerValue(), emptyAsNull: true)
|
||||
?.toSet();
|
||||
_runtimeTypeUses = source.readList(
|
||||
() => new _RuntimeTypeUse.fromDataSource(source),
|
||||
() => _RuntimeTypeUse.fromDataSource(source),
|
||||
emptyAsNull: true);
|
||||
|
||||
// TODO(johnniwinther): Remove these when CFE provides constants.
|
||||
|
@ -1063,7 +1043,7 @@ class _CallStructure {
|
|||
|
||||
factory _CallStructure(int positionalArguments, List<String> namedArguments,
|
||||
List<ir.DartType> typeArguments) {
|
||||
return new _CallStructure.internal(
|
||||
return _CallStructure.internal(
|
||||
typeArguments, positionalArguments, namedArguments);
|
||||
}
|
||||
|
||||
|
@ -1073,7 +1053,7 @@ class _CallStructure {
|
|||
int positionalArguments = source.readInt();
|
||||
List<String> namedArguments = source.readStrings();
|
||||
source.end(tag);
|
||||
return new _CallStructure.internal(
|
||||
return _CallStructure.internal(
|
||||
typeArguments, positionalArguments, namedArguments);
|
||||
}
|
||||
|
||||
|
@ -1099,9 +1079,9 @@ class _SuperInitializer {
|
|||
source.begin(tag);
|
||||
ir.Constructor sourceConstructor = source.readMemberNode();
|
||||
ir.Constructor targetConstructor = source.readMemberNode();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
source.end(tag);
|
||||
return new _SuperInitializer(
|
||||
return _SuperInitializer(
|
||||
sourceConstructor, targetConstructor, callStructure);
|
||||
}
|
||||
|
||||
|
@ -1125,9 +1105,9 @@ class _SuperInvocation {
|
|||
factory _SuperInvocation.fromDataSource(DataSource source) {
|
||||
source.begin(tag);
|
||||
ir.Member member = source.readMemberNode();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
source.end(tag);
|
||||
return new _SuperInvocation(member, callStructure);
|
||||
return _SuperInvocation(member, callStructure);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1153,7 +1133,7 @@ class _InstanceAccess {
|
|||
ClassRelation classRelation = source.readEnum(ClassRelation.values);
|
||||
ir.Member target = source.readMemberNode();
|
||||
source.end(tag);
|
||||
return new _InstanceAccess(receiverType, classRelation, target);
|
||||
return _InstanceAccess(receiverType, classRelation, target);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1180,7 +1160,7 @@ class _DynamicAccess {
|
|||
ClassRelation classRelation = source.readEnum(ClassRelation.values);
|
||||
ir.Name name = source.readName();
|
||||
source.end(tag);
|
||||
return new _DynamicAccess(receiverType, classRelation, name);
|
||||
return _DynamicAccess(receiverType, classRelation, name);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1203,9 +1183,9 @@ class _FunctionInvocation {
|
|||
factory _FunctionInvocation.fromDataSource(DataSource source) {
|
||||
source.begin(tag);
|
||||
ir.DartType receiverType = source.readDartTypeNode();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
source.end(tag);
|
||||
return new _FunctionInvocation(receiverType, callStructure);
|
||||
return _FunctionInvocation(receiverType, callStructure);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1232,9 +1212,9 @@ class _InstanceInvocation {
|
|||
ir.DartType receiverType = source.readDartTypeNode();
|
||||
ClassRelation classRelation = source.readEnum(ClassRelation.values);
|
||||
ir.Member target = source.readMemberNode();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
source.end(tag);
|
||||
return new _InstanceInvocation(
|
||||
return _InstanceInvocation(
|
||||
receiverType, classRelation, target, callStructure);
|
||||
}
|
||||
|
||||
|
@ -1264,10 +1244,9 @@ class _DynamicInvocation {
|
|||
ir.DartType receiverType = source.readDartTypeNode();
|
||||
ClassRelation classRelation = source.readEnum(ClassRelation.values);
|
||||
ir.Name name = source.readName();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
source.end(tag);
|
||||
return new _DynamicInvocation(
|
||||
receiverType, classRelation, name, callStructure);
|
||||
return _DynamicInvocation(receiverType, classRelation, name, callStructure);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1291,9 +1270,9 @@ class _LocalFunctionInvocation {
|
|||
factory _LocalFunctionInvocation.fromDataSource(DataSource source) {
|
||||
source.begin(tag);
|
||||
ir.FunctionDeclaration localFunction = source.readTreeNode();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
source.end(tag);
|
||||
return new _LocalFunctionInvocation(localFunction, callStructure);
|
||||
return _LocalFunctionInvocation(localFunction, callStructure);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1316,10 +1295,10 @@ class _StaticInvocation {
|
|||
factory _StaticInvocation.fromDataSource(DataSource source) {
|
||||
source.begin(tag);
|
||||
ir.Procedure target = source.readMemberNode();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
ir.LibraryDependency import = source.readLibraryDependencyNodeOrNull();
|
||||
source.end(tag);
|
||||
return new _StaticInvocation(target, callStructure, import);
|
||||
return _StaticInvocation(target, callStructure, import);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1348,11 +1327,11 @@ class _ConstructorInvocation {
|
|||
source.begin(tag);
|
||||
ir.Member constructor = source.readMemberNode();
|
||||
ir.InterfaceType type = source.readDartTypeNode();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
ir.LibraryDependency import = source.readLibraryDependencyNodeOrNull();
|
||||
bool isConst = source.readBool();
|
||||
source.end(tag);
|
||||
return new _ConstructorInvocation(constructor, type, callStructure, import,
|
||||
return _ConstructorInvocation(constructor, type, callStructure, import,
|
||||
isConst: isConst);
|
||||
}
|
||||
|
||||
|
@ -1401,7 +1380,7 @@ class _TypeUse {
|
|||
ir.DartType type = source.readDartTypeNode();
|
||||
_TypeUseKind kind = source.readEnum(_TypeUseKind.values);
|
||||
source.end(tag);
|
||||
return new _TypeUse(type, kind);
|
||||
return _TypeUse(type, kind);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1434,9 +1413,9 @@ class _RedirectingInitializer {
|
|||
factory _RedirectingInitializer.fromDataSource(DataSource source) {
|
||||
source.begin(tag);
|
||||
ir.Constructor constructor = source.readMemberNode();
|
||||
_CallStructure callStructure = new _CallStructure.fromDataSource(source);
|
||||
_CallStructure callStructure = _CallStructure.fromDataSource(source);
|
||||
source.end(tag);
|
||||
return new _RedirectingInitializer(constructor, callStructure);
|
||||
return _RedirectingInitializer(constructor, callStructure);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1460,7 +1439,7 @@ class _TypeLiteral {
|
|||
ir.DartType type = source.readDartTypeNode();
|
||||
ir.LibraryDependency import = source.readLibraryDependencyNodeOrNull();
|
||||
source.end(tag);
|
||||
return new _TypeLiteral(type, import);
|
||||
return _TypeLiteral(type, import);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1484,7 +1463,7 @@ class _GenericInstantiation {
|
|||
ir.FunctionType expressionType = source.readDartTypeNode();
|
||||
List<ir.DartType> typeArguments = source.readDartTypeNodes();
|
||||
source.end(tag);
|
||||
return new _GenericInstantiation(expressionType, typeArguments);
|
||||
return _GenericInstantiation(expressionType, typeArguments);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1508,7 +1487,7 @@ class _StaticAccess {
|
|||
ir.Member target = source.readMemberNode();
|
||||
ir.LibraryDependency import = source.readLibraryDependencyNodeOrNull();
|
||||
source.end(tag);
|
||||
return new _StaticAccess(target, import);
|
||||
return _StaticAccess(target, import);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1564,8 +1543,7 @@ class _ContainerLiteral {
|
|||
bool isConst = source.readBool();
|
||||
bool isEmpty = source.readBool();
|
||||
source.end(tag);
|
||||
return new _ContainerLiteral(elementType,
|
||||
isConst: isConst, isEmpty: isEmpty);
|
||||
return _ContainerLiteral(elementType, isConst: isConst, isEmpty: isEmpty);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
@ -1596,7 +1574,7 @@ class _RuntimeTypeUse {
|
|||
ir.DartType receiverType = source.readDartTypeNode();
|
||||
ir.DartType argumentType = source.readDartTypeNode(allowNull: true);
|
||||
source.end(tag);
|
||||
return new _RuntimeTypeUse(node, kind, receiverType, argumentType);
|
||||
return _RuntimeTypeUse(node, kind, receiverType, argumentType);
|
||||
}
|
||||
|
||||
void toDataSink(DataSink sink) {
|
||||
|
|
|
@ -64,7 +64,7 @@ class RuntimeTypeUseData {
|
|||
case RuntimeTypeUseKind.equals:
|
||||
return receiverType != null && argumentType != null;
|
||||
}
|
||||
throw new UnsupportedError("Unexpected RuntimeTypeUseKind $kind.");
|
||||
throw UnsupportedError("Unexpected RuntimeTypeUseKind $kind.");
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -408,8 +408,8 @@ RuntimeTypeUseData computeRuntimeTypeUse(
|
|||
receiverGet = node;
|
||||
}
|
||||
|
||||
RuntimeTypeUseData data = new RuntimeTypeUseData(
|
||||
kind, receiverGet, receiver, argumentGet, argument);
|
||||
RuntimeTypeUseData data =
|
||||
RuntimeTypeUseData(kind, receiverGet, receiver, argumentGet, argument);
|
||||
cache[receiverGet] = data;
|
||||
if (argumentGet != null) {
|
||||
cache[argumentGet] = data;
|
||||
|
|
|
@ -22,7 +22,7 @@ class ScopeModel {
|
|||
/// be marked as free variables.
|
||||
factory ScopeModel.from(
|
||||
ir.Member node, ir.ConstantEvaluator constantEvaluator) {
|
||||
ScopeModelBuilder builder = new ScopeModelBuilder(constantEvaluator);
|
||||
ScopeModelBuilder builder = ScopeModelBuilder(constantEvaluator);
|
||||
return builder.computeModel(node);
|
||||
}
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ class VariableScopeModelImpl implements VariableScopeModel {
|
|||
Set<ir.VariableDeclaration> _assignedVariables;
|
||||
|
||||
VariableScope createScopeFor(ir.TreeNode node) {
|
||||
return _scopeMap[node] ??= new VariableScopeImpl();
|
||||
return _scopeMap[node] ??= VariableScopeImpl();
|
||||
}
|
||||
|
||||
void registerAssignedVariable(ir.VariableDeclaration node) {
|
||||
_assignedVariables ??= new Set<ir.VariableDeclaration>();
|
||||
_assignedVariables ??= Set<ir.VariableDeclaration>();
|
||||
_assignedVariables.add(node);
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ class VariableScopeImpl implements VariableScope {
|
|||
}
|
||||
|
||||
void registerAssignedVariable(ir.VariableDeclaration variable) {
|
||||
_assignedVariables ??= new Set<ir.VariableDeclaration>();
|
||||
_assignedVariables ??= Set<ir.VariableDeclaration>();
|
||||
_assignedVariables.add(variable);
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ class VariableScopeImpl implements VariableScope {
|
|||
|
||||
abstract class VariableCollectorMixin {
|
||||
VariableScopeImpl currentVariableScope;
|
||||
VariableScopeModelImpl variableScopeModel = new VariableScopeModelImpl();
|
||||
VariableScopeModelImpl variableScopeModel = VariableScopeModelImpl();
|
||||
|
||||
void visitInVariableScope(ir.TreeNode root, void f()) {
|
||||
VariableScopeImpl oldScope = currentVariableScope;
|
||||
|
|
|
@ -23,7 +23,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
ir.TypeEnvironment get _typeEnvironment => _constantEvaluator.typeEnvironment;
|
||||
ir.CoreTypes get _coreTypes => _typeEnvironment.coreTypes;
|
||||
|
||||
final ClosureScopeModel _model = new ClosureScopeModel();
|
||||
final ClosureScopeModel _model = ClosureScopeModel();
|
||||
|
||||
/// A map of each visited call node with the associated information about what
|
||||
/// variables are captured/used. Each ir.Node key corresponds to a scope that
|
||||
|
@ -56,13 +56,12 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
/// Keep track of the mutated local variables so that we don't need to box
|
||||
/// non-mutated variables. We know these are only VariableDeclarations because
|
||||
/// type variable types and `this` types can't be mutated!
|
||||
Set<ir.VariableDeclaration> _mutatedVariables =
|
||||
new Set<ir.VariableDeclaration>();
|
||||
Set<ir.VariableDeclaration> _mutatedVariables = Set<ir.VariableDeclaration>();
|
||||
|
||||
/// The set of variables that are accessed in some form, whether they are
|
||||
/// mutated or not.
|
||||
Set<ir.Node /* ir.VariableDeclaration | TypeParameterTypeWithContext */ >
|
||||
_capturedVariables = new Set<ir.Node>();
|
||||
_capturedVariables = Set<ir.Node>();
|
||||
|
||||
/// If true, the visitor is currently traversing some nodes that are inside a
|
||||
/// try block.
|
||||
|
@ -89,10 +88,10 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
ScopeModel computeModel(ir.Member node) {
|
||||
if (node.isAbstract && !node.isExternal) {
|
||||
return const ScopeModel(
|
||||
initializerComplexity: const EvaluationComplexity.lazy());
|
||||
initializerComplexity: EvaluationComplexity.lazy());
|
||||
}
|
||||
|
||||
_staticTypeContext = new ir.StaticTypeContext(node, _typeEnvironment);
|
||||
_staticTypeContext = ir.StaticTypeContext(node, _typeEnvironment);
|
||||
if (node is ir.Constructor) {
|
||||
_hasThisLocal = true;
|
||||
} else if (node is ir.Procedure && node.kind == ir.ProcedureKind.Factory) {
|
||||
|
@ -110,7 +109,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
initializerComplexity = node.accept(this);
|
||||
} else {
|
||||
initializerComplexity = const EvaluationComplexity.constant();
|
||||
_model.scopeInfo = new KernelScopeInfo(_hasThisLocal);
|
||||
_model.scopeInfo = KernelScopeInfo(_hasThisLocal);
|
||||
}
|
||||
} else {
|
||||
assert(node is ir.Procedure || node is ir.Constructor);
|
||||
|
@ -120,7 +119,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
node.accept(this);
|
||||
}
|
||||
}
|
||||
return new ScopeModel(
|
||||
return ScopeModel(
|
||||
closureScopeModel: _model,
|
||||
variableScopeModel: variableScopeModel,
|
||||
initializerComplexity: initializerComplexity);
|
||||
|
@ -159,7 +158,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
ir.Constant constant = _constantEvaluator.evaluate(_staticTypeContext, node,
|
||||
requireConstant: false, replaceImplicitConstant: false);
|
||||
if (constant != null) {
|
||||
return new EvaluationComplexity.constant(constant);
|
||||
return EvaluationComplexity.constant(constant);
|
||||
}
|
||||
return const EvaluationComplexity.lazy();
|
||||
}
|
||||
|
@ -180,7 +179,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
ir.Expression _handleExpression(ir.Expression node) {
|
||||
_lastExpressionComplexity = visitNode(node);
|
||||
if (_lastExpressionComplexity.isFreshConstant) {
|
||||
return new ir.ConstantExpression(_lastExpressionComplexity.constant,
|
||||
return ir.ConstantExpression(_lastExpressionComplexity.constant,
|
||||
node.getStaticType(_staticTypeContext))
|
||||
..fileOffset = node.fileOffset
|
||||
..parent = node.parent;
|
||||
|
@ -216,7 +215,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
/// this node if any variables are captured.
|
||||
void attachCapturedScopeVariables(ir.TreeNode node) {
|
||||
Set<ir.VariableDeclaration> capturedVariablesForScope =
|
||||
new Set<ir.VariableDeclaration>();
|
||||
Set<ir.VariableDeclaration>();
|
||||
|
||||
for (ir.Node variable in _scopeVariables) {
|
||||
// No need to box non-assignable elements.
|
||||
|
@ -233,12 +232,12 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
KernelScopeInfo from = _model.scopeInfo;
|
||||
|
||||
KernelCapturedScope capturedScope;
|
||||
var nodeBox = new NodeBox(getBoxName(), _executableContext);
|
||||
var nodeBox = NodeBox(getBoxName(), _executableContext);
|
||||
if (node is ir.ForStatement ||
|
||||
node is ir.ForInStatement ||
|
||||
node is ir.WhileStatement ||
|
||||
node is ir.DoStatement) {
|
||||
capturedScope = new KernelCapturedLoopScope(
|
||||
capturedScope = KernelCapturedLoopScope(
|
||||
capturedVariablesForScope,
|
||||
nodeBox,
|
||||
[],
|
||||
|
@ -249,7 +248,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
from.thisUsedAsFreeVariableIfNeedsRti,
|
||||
_hasThisLocal);
|
||||
} else {
|
||||
capturedScope = new KernelCapturedScope(
|
||||
capturedScope = KernelCapturedScope(
|
||||
capturedVariablesForScope,
|
||||
nodeBox,
|
||||
from.localsUsedInTryOrSync,
|
||||
|
@ -375,7 +374,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
_currentScopeInfo.freeVariables.add(variable);
|
||||
} else {
|
||||
_currentScopeInfo.freeVariablesForRti
|
||||
.putIfAbsent(variable, () => new Set<VariableUse>())
|
||||
.putIfAbsent(variable, () => Set<VariableUse>())
|
||||
.add(usage);
|
||||
}
|
||||
}
|
||||
|
@ -395,7 +394,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
@override
|
||||
EvaluationComplexity visitTypeParameter(ir.TypeParameter typeParameter) {
|
||||
TypeVariableTypeWithContext typeVariable(ir.Library library) =>
|
||||
new TypeVariableTypeWithContext(
|
||||
TypeVariableTypeWithContext(
|
||||
ir.TypeParameterType.withDefaultNullabilityForLibrary(
|
||||
typeParameter, library),
|
||||
// If this typeParameter is part of a typedef then its parent is
|
||||
|
@ -532,7 +531,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
});
|
||||
KernelCapturedScope scope = _scopesCapturedInClosureMap[node];
|
||||
if (scope != null) {
|
||||
_scopesCapturedInClosureMap[node] = new KernelCapturedLoopScope(
|
||||
_scopesCapturedInClosureMap[node] = KernelCapturedLoopScope(
|
||||
scope.boxedVariables,
|
||||
scope.capturedVariablesAccessor,
|
||||
boxedLoopVariables,
|
||||
|
@ -554,7 +553,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
}
|
||||
if (node.arguments.types.isNotEmpty) {
|
||||
visitNodesInContext(node.arguments.types,
|
||||
new VariableUse.staticTypeArgument(node.interfaceTarget));
|
||||
VariableUse.staticTypeArgument(node.interfaceTarget));
|
||||
}
|
||||
visitArguments(node.arguments);
|
||||
return const EvaluationComplexity.lazy();
|
||||
|
@ -588,7 +587,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
_isInsideClosure = _outermostNode != null;
|
||||
_executableContext = node;
|
||||
|
||||
_currentScopeInfo = new KernelScopeInfo(_hasThisLocal);
|
||||
_currentScopeInfo = KernelScopeInfo(_hasThisLocal);
|
||||
|
||||
if (_isInsideClosure) {
|
||||
_closuresToGenerate[node] = _currentScopeInfo;
|
||||
|
@ -825,8 +824,8 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
@override
|
||||
EvaluationComplexity visitFunctionNode(ir.FunctionNode node) {
|
||||
VariableUse parameterUsage = node.parent is ir.Member
|
||||
? new VariableUse.memberParameter(node.parent)
|
||||
: new VariableUse.localParameter(node.parent);
|
||||
? VariableUse.memberParameter(node.parent)
|
||||
: VariableUse.localParameter(node.parent);
|
||||
visitNodesInContext(node.typeParameters, parameterUsage);
|
||||
for (ir.VariableDeclaration declaration in node.positionalParameters) {
|
||||
_handleVariableDeclaration(declaration, parameterUsage);
|
||||
|
@ -837,8 +836,8 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
visitInContext(
|
||||
node.returnType,
|
||||
node.parent is ir.Member
|
||||
? new VariableUse.memberReturnType(node.parent)
|
||||
: new VariableUse.localReturnType(node.parent));
|
||||
? VariableUse.memberReturnType(node.parent)
|
||||
: VariableUse.localReturnType(node.parent));
|
||||
if (node.body != null) {
|
||||
visitNode(node.body);
|
||||
}
|
||||
|
@ -933,7 +932,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
if (target is ir.Field) {
|
||||
return target.isConst
|
||||
? const EvaluationComplexity.constant()
|
||||
: new EvaluationComplexity.eager(fields: <ir.Field>{target});
|
||||
: EvaluationComplexity.eager(fields: <ir.Field>{target});
|
||||
} else if (target is ir.Procedure &&
|
||||
target.kind == ir.ProcedureKind.Method) {
|
||||
return _evaluateImplicitConstant(node);
|
||||
|
@ -957,9 +956,9 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
if (node.arguments.types.isNotEmpty) {
|
||||
VariableUse usage;
|
||||
if (node.target.kind == ir.ProcedureKind.Factory) {
|
||||
usage = new VariableUse.constructorTypeArgument(node.target);
|
||||
usage = VariableUse.constructorTypeArgument(node.target);
|
||||
} else {
|
||||
usage = new VariableUse.staticTypeArgument(node.target);
|
||||
usage = VariableUse.staticTypeArgument(node.target);
|
||||
}
|
||||
|
||||
visitNodesInContext(node.arguments.types, usage);
|
||||
|
@ -1000,8 +999,8 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
}
|
||||
|
||||
if (node.arguments.types.isNotEmpty) {
|
||||
visitNodesInContext(node.arguments.types,
|
||||
new VariableUse.constructorTypeArgument(target));
|
||||
visitNodesInContext(
|
||||
node.arguments.types, VariableUse.constructorTypeArgument(target));
|
||||
}
|
||||
visitArguments(node.arguments);
|
||||
return node.isConst
|
||||
|
@ -1041,7 +1040,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
receiver.variable.parent is ir.LocalFunction),
|
||||
"Unexpected local function invocation ${node} "
|
||||
"(${node.runtimeType}).");
|
||||
VariableUse usage = new VariableUse.instanceTypeArgument(node);
|
||||
VariableUse usage = VariableUse.instanceTypeArgument(node);
|
||||
visitNodesInContext(node.arguments.types, usage);
|
||||
}
|
||||
EvaluationComplexity complexity = visitArguments(node.arguments);
|
||||
|
@ -1068,7 +1067,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
receiver.variable.parent is ir.LocalFunction),
|
||||
"Unexpected local function invocation ${node} "
|
||||
"(${node.runtimeType}).");
|
||||
VariableUse usage = new VariableUse.instanceTypeArgument(node);
|
||||
VariableUse usage = VariableUse.instanceTypeArgument(node);
|
||||
visitNodesInContext(node.arguments.types, usage);
|
||||
}
|
||||
visitArguments(node.arguments);
|
||||
|
@ -1085,7 +1084,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
receiver.variable.parent is ir.LocalFunction),
|
||||
"Unexpected local function invocation ${node} "
|
||||
"(${node.runtimeType}).");
|
||||
VariableUse usage = new VariableUse.instanceTypeArgument(node);
|
||||
VariableUse usage = VariableUse.instanceTypeArgument(node);
|
||||
visitNodesInContext(node.arguments.types, usage);
|
||||
}
|
||||
visitArguments(node.arguments);
|
||||
|
@ -1102,7 +1101,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
is ir.LocalFunction)),
|
||||
"Unexpected local function invocation ${node} "
|
||||
"(${node.runtimeType}).");
|
||||
VariableUse usage = new VariableUse.instanceTypeArgument(node);
|
||||
VariableUse usage = VariableUse.instanceTypeArgument(node);
|
||||
visitNodesInContext(node.arguments.types, usage);
|
||||
}
|
||||
visitArguments(node.arguments);
|
||||
|
@ -1115,7 +1114,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
_markVariableAsUsed(node.variable, VariableUse.explicit);
|
||||
if (node.arguments.types.isNotEmpty) {
|
||||
VariableUse usage =
|
||||
new VariableUse.localTypeArgument(node.localFunction, node);
|
||||
VariableUse.localTypeArgument(node.localFunction, node);
|
||||
visitNodesInContext(node.arguments.types, usage);
|
||||
}
|
||||
visitArguments(node.arguments);
|
||||
|
@ -1247,7 +1246,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
@override
|
||||
EvaluationComplexity visitInstantiation(ir.Instantiation node) {
|
||||
EvaluationComplexity typeArgumentsComplexity = visitNodesInContext(
|
||||
node.typeArguments, new VariableUse.instantiationTypeArgument(node));
|
||||
node.typeArguments, VariableUse.instantiationTypeArgument(node));
|
||||
node.expression = _handleExpression(node.expression);
|
||||
EvaluationComplexity expressionComplexity = _lastExpressionComplexity;
|
||||
|
||||
|
@ -1354,7 +1353,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
EvaluationComplexity visitSuperInitializer(ir.SuperInitializer node) {
|
||||
if (node.arguments.types.isNotEmpty) {
|
||||
visitNodesInContext(node.arguments.types,
|
||||
new VariableUse.constructorTypeArgument(node.target));
|
||||
VariableUse.constructorTypeArgument(node.target));
|
||||
}
|
||||
visitArguments(node.arguments);
|
||||
return const EvaluationComplexity.lazy();
|
||||
|
@ -1365,7 +1364,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
ir.RedirectingInitializer node) {
|
||||
if (node.arguments.types.isNotEmpty) {
|
||||
visitNodesInContext(node.arguments.types,
|
||||
new VariableUse.constructorTypeArgument(node.target));
|
||||
VariableUse.constructorTypeArgument(node.target));
|
||||
}
|
||||
visitArguments(node.arguments);
|
||||
return const EvaluationComplexity.lazy();
|
||||
|
@ -1407,7 +1406,7 @@ class ScopeModelBuilder extends ir.Visitor<EvaluationComplexity>
|
|||
assert(usage != null);
|
||||
if (_outermostNode is ir.Member) {
|
||||
TypeVariableTypeWithContext typeVariable =
|
||||
new TypeVariableTypeWithContext(type, _outermostNode);
|
||||
TypeVariableTypeWithContext(type, _outermostNode);
|
||||
switch (typeVariable.kind) {
|
||||
case TypeVariableKind.cls:
|
||||
if (_isFieldOrConstructor(_outermostNode)) {
|
||||
|
@ -1496,7 +1495,7 @@ class EvaluationComplexity {
|
|||
if (isLazy || isEager) {
|
||||
return this;
|
||||
} else {
|
||||
return new EvaluationComplexity.eager();
|
||||
return EvaluationComplexity.eager();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1510,7 +1509,7 @@ class EvaluationComplexity {
|
|||
|
||||
/// Returns a short textual representation used for testing.
|
||||
String get shortText {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
switch (level) {
|
||||
case ComplexityLevel.constant:
|
||||
sb.write('constant');
|
||||
|
@ -1528,7 +1527,7 @@ class EvaluationComplexity {
|
|||
sb.write('lazy');
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedError("Unexpected complexity level $level");
|
||||
throw UnsupportedError("Unexpected complexity level $level");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
: super(typeEnvironment);
|
||||
|
||||
StaticTypeCache getStaticTypeCache() {
|
||||
return new StaticTypeCache(_staticTypeCache._expressionTypes,
|
||||
return StaticTypeCache(_staticTypeCache._expressionTypes,
|
||||
_staticTypeCache._forInIteratorTypes);
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
|
||||
Set<ir.VariableDeclaration> _currentVariables;
|
||||
Set<ir.VariableDeclaration> _invalidatedVariables =
|
||||
new Set<ir.VariableDeclaration>();
|
||||
Set<ir.VariableDeclaration>();
|
||||
|
||||
TypeMap _typeMapBase = const TypeMap();
|
||||
TypeMap _typeMapWhenTrue;
|
||||
|
@ -415,7 +415,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
// We need to insert an implicit cast to preserve the invariant that
|
||||
// a property set with a known interface target is also statically
|
||||
// checked.
|
||||
return new ir.AsExpression(value, setterType)..isTypeError = true;
|
||||
return ir.AsExpression(value, setterType)..isTypeError = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -613,11 +613,11 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
ir.Expression updateArgument(ir.Expression expression, ir.TreeNode parent,
|
||||
ir.DartType argumentType, ir.DartType checkedParameterType) {
|
||||
ir.VariableDeclaration variable =
|
||||
new ir.VariableDeclaration.forValue(expression, type: argumentType);
|
||||
ir.VariableDeclaration.forValue(expression, type: argumentType);
|
||||
// Visit the newly created variable declaration.
|
||||
handleVariableDeclaration(variable);
|
||||
letVariables.add(variable);
|
||||
ir.VariableGet get = new ir.VariableGet(variable)..parent = parent;
|
||||
ir.VariableGet get = ir.VariableGet(variable)..parent = parent;
|
||||
// Visit the newly created variable get.
|
||||
handleVariableGet(get, argumentType);
|
||||
_staticTypeCache._expressionTypes[get] = argumentType;
|
||||
|
@ -628,10 +628,9 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
// We need to insert an implicit cast to preserve the invariant that
|
||||
// a method invocation with a known interface target is also
|
||||
// statically checked.
|
||||
ir.AsExpression implicitCast =
|
||||
new ir.AsExpression(get, checkedParameterType)
|
||||
..isTypeError = true
|
||||
..parent = parent;
|
||||
ir.AsExpression implicitCast = ir.AsExpression(get, checkedParameterType)
|
||||
..isTypeError = true
|
||||
..parent = parent;
|
||||
// Visit the newly created as expression; the original value has
|
||||
// already been visited.
|
||||
handleAsExpression(implicitCast, argumentType);
|
||||
|
@ -655,11 +654,11 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
argumentType, neededNamedChecks[argumentIndex]);
|
||||
}
|
||||
|
||||
ir.Expression dummy = new ir.NullLiteral();
|
||||
ir.Expression dummy = ir.NullLiteral();
|
||||
node.replaceWith(dummy);
|
||||
ir.Expression body = node;
|
||||
for (ir.VariableDeclaration variable in letVariables.reversed) {
|
||||
body = new ir.Let(variable, body);
|
||||
body = ir.Let(variable, body);
|
||||
}
|
||||
dummy.replaceWith(body);
|
||||
}
|
||||
|
@ -738,7 +737,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
ir.DartType argumentType = argumentTypes.positional[0];
|
||||
ir.DartType resultType = typeEnvironment
|
||||
.getTypeOfSpecialCasedBinaryOperator(receiverType, argumentType);
|
||||
return new ir.FunctionType(
|
||||
return ir.FunctionType(
|
||||
<ir.DartType>[argumentType], resultType, currentLibrary.nonNullable);
|
||||
}
|
||||
return getterType;
|
||||
|
@ -777,8 +776,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
if (arguments.positional.isEmpty) {
|
||||
positional = const <ir.DartType>[];
|
||||
} else {
|
||||
positional =
|
||||
new List<ir.DartType>.filled(arguments.positional.length, null);
|
||||
positional = List<ir.DartType>.filled(arguments.positional.length, null);
|
||||
int index = 0;
|
||||
for (ir.Expression argument in arguments.positional) {
|
||||
positional[index++] = visitNode(argument);
|
||||
|
@ -787,13 +785,13 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
if (arguments.named.isEmpty) {
|
||||
named = const <ir.DartType>[];
|
||||
} else {
|
||||
named = new List<ir.DartType>.filled(arguments.named.length, null);
|
||||
named = List<ir.DartType>.filled(arguments.named.length, null);
|
||||
int index = 0;
|
||||
for (ir.NamedExpression argument in arguments.named) {
|
||||
named[index++] = visitNode(argument);
|
||||
}
|
||||
}
|
||||
return new ArgumentTypes(positional, named);
|
||||
return ArgumentTypes(positional, named);
|
||||
}
|
||||
|
||||
void handleDynamicInvocation(
|
||||
|
@ -1115,9 +1113,9 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
ir.DartType visitConstructorInvocation(ir.ConstructorInvocation node) {
|
||||
ArgumentTypes argumentTypes = _visitArguments(node.arguments);
|
||||
ir.DartType resultType = node.arguments.types.isEmpty
|
||||
? new ExactInterfaceType.from(typeEnvironment.coreTypes
|
||||
? ExactInterfaceType.from(typeEnvironment.coreTypes
|
||||
.nonNullableRawType(node.target.enclosingClass))
|
||||
: new ExactInterfaceType(node.target.enclosingClass,
|
||||
: ExactInterfaceType(node.target.enclosingClass,
|
||||
ir.Nullability.nonNullable, node.arguments.types);
|
||||
_staticTypeCache._expressionTypes[node] = resultType;
|
||||
handleConstructorInvocation(node, argumentTypes, resultType);
|
||||
|
@ -1566,7 +1564,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
currentLibrary,
|
||||
typeEnvironment.coreTypes);
|
||||
if (streamType != null) {
|
||||
iteratorType = new ir.InterfaceType(
|
||||
iteratorType = ir.InterfaceType(
|
||||
typeEnvironment.coreTypes.streamIteratorClass,
|
||||
ir.Nullability.nonNullable,
|
||||
streamType.typeArguments);
|
||||
|
@ -1574,7 +1572,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
} else {
|
||||
ir.InterfaceType iterableInterfaceType = getInterfaceTypeOf(iterableType);
|
||||
ir.Member member = hierarchy.getInterfaceMember(
|
||||
iterableInterfaceType.classNode, new ir.Name(Identifiers.iterator));
|
||||
iterableInterfaceType.classNode, ir.Name(Identifiers.iterator));
|
||||
if (member != null) {
|
||||
iteratorType = ir.Substitution.fromInterfaceType(
|
||||
typeEnvironment.getTypeAsInstanceOf(
|
||||
|
@ -1729,7 +1727,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
|
||||
@override
|
||||
Null visitProcedure(ir.Procedure node) {
|
||||
thisType = new ThisInterfaceType.from(node.enclosingClass?.getThisType(
|
||||
thisType = ThisInterfaceType.from(node.enclosingClass?.getThisType(
|
||||
typeEnvironment.coreTypes, node.enclosingLibrary.nonNullable));
|
||||
_currentVariables = {};
|
||||
currentLibrary = node.enclosingLibrary;
|
||||
|
@ -1746,7 +1744,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
|
||||
@override
|
||||
Null visitConstructor(ir.Constructor node) {
|
||||
thisType = new ThisInterfaceType.from(node.enclosingClass.getThisType(
|
||||
thisType = ThisInterfaceType.from(node.enclosingClass.getThisType(
|
||||
typeEnvironment.coreTypes, node.enclosingLibrary.nonNullable));
|
||||
_currentVariables = {};
|
||||
currentLibrary = node.enclosingLibrary;
|
||||
|
@ -1764,7 +1762,7 @@ abstract class StaticTypeVisitor extends StaticTypeBase {
|
|||
|
||||
@override
|
||||
Null visitField(ir.Field node) {
|
||||
thisType = new ThisInterfaceType.from(node.enclosingClass?.getThisType(
|
||||
thisType = ThisInterfaceType.from(node.enclosingClass?.getThisType(
|
||||
typeEnvironment.coreTypes, node.enclosingLibrary.nonNullable));
|
||||
_currentVariables = {};
|
||||
currentLibrary = node.enclosingLibrary;
|
||||
|
@ -1911,7 +1909,7 @@ class TypeHolder {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
sb.write('TypeHolder(');
|
||||
sb.write('declared=$declaredType');
|
||||
if (trueTypes != null) {
|
||||
|
@ -1950,7 +1948,7 @@ class TargetInfo {
|
|||
/// be an instance of [type]. If [isTrue] is `false`, the local variable is
|
||||
/// known _not_ to be an instance of [type].
|
||||
TargetInfo promote(ir.DartType type, {bool isTrue}) {
|
||||
Set<TypeHolder> newTypeHolders = new Set<TypeHolder>();
|
||||
Set<TypeHolder> newTypeHolders = Set<TypeHolder>();
|
||||
|
||||
bool addTypeHolder(TypeHolder typeHolder) {
|
||||
bool changed = false;
|
||||
|
@ -1958,7 +1956,7 @@ class TargetInfo {
|
|||
Set<ir.DartType> addAsCopy(Set<ir.DartType> set, ir.DartType type) {
|
||||
Set<ir.DartType> result;
|
||||
if (set == null) {
|
||||
result = new Set<ir.DartType>();
|
||||
result = Set<ir.DartType>();
|
||||
} else if (set.contains(type)) {
|
||||
return set;
|
||||
} else {
|
||||
|
@ -1995,12 +1993,11 @@ class TargetInfo {
|
|||
if (typesOfInterest.contains(type)) {
|
||||
newTypesOfInterest = typesOfInterest;
|
||||
} else {
|
||||
newTypesOfInterest = new Set<ir.DartType>.from(typesOfInterest)
|
||||
..add(type);
|
||||
newTypesOfInterest = Set<ir.DartType>.from(typesOfInterest)..add(type);
|
||||
changed = true;
|
||||
}
|
||||
return changed
|
||||
? new TargetInfo(declaredType, newTypeHolders, newTypesOfInterest)
|
||||
? TargetInfo(declaredType, newTypeHolders, newTypesOfInterest)
|
||||
: this;
|
||||
}
|
||||
|
||||
|
@ -2012,8 +2009,8 @@ class TargetInfo {
|
|||
if (other == null) return null;
|
||||
if (identical(this, other)) return this;
|
||||
|
||||
Set<TypeHolder> newTypeHolders = new Set<TypeHolder>();
|
||||
Set<ir.DartType> newTypesOfInterest = new Set<ir.DartType>();
|
||||
Set<TypeHolder> newTypeHolders = Set<TypeHolder>();
|
||||
Set<ir.DartType> newTypesOfInterest = Set<ir.DartType>();
|
||||
|
||||
/// Adds the [typeHolders] to [newTypeHolders] for types in
|
||||
/// [otherTypesOfInterest] while removing the information
|
||||
|
@ -2026,7 +2023,7 @@ class TargetInfo {
|
|||
for (TypeHolder typeHolder in typeHolders) {
|
||||
Set<ir.DartType> newTrueTypes;
|
||||
if (typeHolder.trueTypes != null) {
|
||||
newTrueTypes = new Set<ir.DartType>.from(typeHolder.trueTypes);
|
||||
newTrueTypes = Set<ir.DartType>.from(typeHolder.trueTypes);
|
||||
|
||||
/// Only types in [otherTypesOfInterest] has information from all
|
||||
/// paths.
|
||||
|
@ -2044,7 +2041,7 @@ class TargetInfo {
|
|||
}
|
||||
Set<ir.DartType> newFalseTypes;
|
||||
if (typeHolder.falseTypes != null) {
|
||||
newFalseTypes = new Set<ir.DartType>.from(typeHolder.falseTypes);
|
||||
newFalseTypes = Set<ir.DartType>.from(typeHolder.falseTypes);
|
||||
|
||||
/// Only types in [otherTypesOfInterest] has information from all
|
||||
/// paths.
|
||||
|
@ -2063,13 +2060,13 @@ class TargetInfo {
|
|||
if (newTrueTypes != null || newFalseTypes != null) {
|
||||
// Only include type holders with information.
|
||||
newTypeHolders
|
||||
.add(new TypeHolder(declaredType, newTrueTypes, newFalseTypes));
|
||||
.add(TypeHolder(declaredType, newTrueTypes, newFalseTypes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Set<ir.DartType> thisTrueTypes = new Set<ir.DartType>();
|
||||
Set<ir.DartType> thisFalseTypes = new Set<ir.DartType>();
|
||||
Set<ir.DartType> thisTrueTypes = Set<ir.DartType>();
|
||||
Set<ir.DartType> thisFalseTypes = Set<ir.DartType>();
|
||||
for (TypeHolder typeHolder in typeHolders) {
|
||||
if (typeHolder.trueTypes != null) {
|
||||
thisTrueTypes.addAll(typeHolder.trueTypes);
|
||||
|
@ -2079,8 +2076,8 @@ class TargetInfo {
|
|||
}
|
||||
}
|
||||
|
||||
Set<ir.DartType> otherTrueTypes = new Set<ir.DartType>();
|
||||
Set<ir.DartType> otherFalseTypes = new Set<ir.DartType>();
|
||||
Set<ir.DartType> otherTrueTypes = Set<ir.DartType>();
|
||||
Set<ir.DartType> otherFalseTypes = Set<ir.DartType>();
|
||||
for (TypeHolder typeHolder in other.typeHolders) {
|
||||
if (typeHolder.trueTypes != null) {
|
||||
otherTrueTypes.addAll(typeHolder.trueTypes);
|
||||
|
@ -2100,7 +2097,7 @@ class TargetInfo {
|
|||
return null;
|
||||
}
|
||||
|
||||
return new TargetInfo(declaredType, newTypeHolders, newTypesOfInterest);
|
||||
return TargetInfo(declaredType, newTypeHolders, newTypesOfInterest);
|
||||
}
|
||||
|
||||
/// Computes a single type that soundly represents the promoted type of the
|
||||
|
@ -2151,7 +2148,7 @@ class TargetInfo {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
sb.write('TargetInfo(');
|
||||
sb.write('declaredType=$declaredType,');
|
||||
sb.write('typeHolders=$typeHolders,');
|
||||
|
@ -2180,7 +2177,7 @@ class TypeMap {
|
|||
TypeMap promote(ir.VariableDeclaration variable, ir.DartType type,
|
||||
{bool isTrue}) {
|
||||
Map<ir.VariableDeclaration, TargetInfo> newInfoMap =
|
||||
new Map<ir.VariableDeclaration, TargetInfo>.from(_targetInfoMap);
|
||||
Map<ir.VariableDeclaration, TargetInfo>.from(_targetInfoMap);
|
||||
TargetInfo targetInfo = newInfoMap[variable];
|
||||
bool changed = false;
|
||||
if (targetInfo != null) {
|
||||
|
@ -2190,16 +2187,15 @@ class TypeMap {
|
|||
} else {
|
||||
changed = true;
|
||||
Set<ir.DartType> trueTypes =
|
||||
isTrue ? (new Set<ir.DartType>()..add(type)) : null;
|
||||
isTrue ? (Set<ir.DartType>()..add(type)) : null;
|
||||
Set<ir.DartType> falseTypes =
|
||||
isTrue ? null : (new Set<ir.DartType>()..add(type));
|
||||
TypeHolder typeHolder =
|
||||
new TypeHolder(variable.type, trueTypes, falseTypes);
|
||||
targetInfo = new TargetInfo(
|
||||
isTrue ? null : (Set<ir.DartType>()..add(type));
|
||||
TypeHolder typeHolder = TypeHolder(variable.type, trueTypes, falseTypes);
|
||||
targetInfo = TargetInfo(
|
||||
variable.type, <TypeHolder>[typeHolder], <ir.DartType>[type]);
|
||||
}
|
||||
newInfoMap[variable] = targetInfo;
|
||||
return changed ? new TypeMap(newInfoMap) : this;
|
||||
return changed ? TypeMap(newInfoMap) : this;
|
||||
}
|
||||
|
||||
/// Returns the [TypeMap] that describes that the locals are either of [this]
|
||||
|
@ -2217,7 +2213,7 @@ class TypeMap {
|
|||
newInfoMap[variable] = result;
|
||||
}
|
||||
});
|
||||
return changed ? new TypeMap(newInfoMap) : this;
|
||||
return changed ? TypeMap(newInfoMap) : this;
|
||||
}
|
||||
|
||||
/// Returns the [TypeMap] in which all type information for any of the
|
||||
|
@ -2232,7 +2228,7 @@ class TypeMap {
|
|||
changed = true;
|
||||
}
|
||||
});
|
||||
return changed ? new TypeMap(newInfoMap) : this;
|
||||
return changed ? TypeMap(newInfoMap) : this;
|
||||
}
|
||||
|
||||
/// Returns the [TypeMap] where type information for `node.variable` is
|
||||
|
@ -2247,7 +2243,7 @@ class TypeMap {
|
|||
newInfoMap[variable] = info;
|
||||
} else if (type != null) {
|
||||
changed = true;
|
||||
Set<ir.DartType> newTypesOfInterest = new Set<ir.DartType>();
|
||||
Set<ir.DartType> newTypesOfInterest = Set<ir.DartType>();
|
||||
for (ir.DartType typeOfInterest in info.typesOfInterest) {
|
||||
if (typeEnvironment.isSubtypeOf(type, typeOfInterest,
|
||||
ir.SubtypeCheckMode.ignoringNullabilities)) {
|
||||
|
@ -2262,10 +2258,10 @@ class TypeMap {
|
|||
// declared type or null) and the canonical way to represent this is
|
||||
// to have _no_ target info.
|
||||
TypeHolder typeHolderIfNonNull =
|
||||
new TypeHolder(info.declaredType, newTypesOfInterest, null);
|
||||
TypeHolder typeHolderIfNull = new TypeHolder(info.declaredType, null,
|
||||
new Set<ir.DartType>()..add(info.declaredType));
|
||||
newInfoMap[variable] = new TargetInfo(
|
||||
TypeHolder(info.declaredType, newTypesOfInterest, null);
|
||||
TypeHolder typeHolderIfNull = TypeHolder(info.declaredType, null,
|
||||
Set<ir.DartType>()..add(info.declaredType));
|
||||
newInfoMap[variable] = TargetInfo(
|
||||
info.declaredType,
|
||||
<TypeHolder>[typeHolderIfNonNull, typeHolderIfNull],
|
||||
newTypesOfInterest);
|
||||
|
@ -2274,7 +2270,7 @@ class TypeMap {
|
|||
changed = true;
|
||||
}
|
||||
});
|
||||
return changed ? new TypeMap(newInfoMap) : this;
|
||||
return changed ? TypeMap(newInfoMap) : this;
|
||||
}
|
||||
|
||||
/// Computes a single type that soundly represents the promoted type of
|
||||
|
@ -2289,7 +2285,7 @@ class TypeMap {
|
|||
}
|
||||
|
||||
String getText(String Function(Iterable<ir.DartType>) typesToText) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
sb.write('{');
|
||||
String comma = '';
|
||||
_targetInfoMap.forEach((ir.VariableDeclaration variable, TargetInfo info) {
|
||||
|
@ -2303,7 +2299,7 @@ class TypeMap {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
sb.write('TypeMap(');
|
||||
String comma = '';
|
||||
_targetInfoMap.forEach((ir.VariableDeclaration variable, TargetInfo info) {
|
||||
|
|
|
@ -23,8 +23,7 @@ class ThisInterfaceType extends ir.InterfaceType {
|
|||
: super(classNode, nullability, typeArguments);
|
||||
|
||||
factory ThisInterfaceType.from(ir.InterfaceType type) => type != null
|
||||
? new ThisInterfaceType(
|
||||
type.classNode, type.nullability, type.typeArguments)
|
||||
? ThisInterfaceType(type.classNode, type.nullability, type.typeArguments)
|
||||
: null;
|
||||
|
||||
@override
|
||||
|
@ -39,8 +38,7 @@ class ExactInterfaceType extends ir.InterfaceType {
|
|||
: super(classNode, nullability, typeArguments);
|
||||
|
||||
factory ExactInterfaceType.from(ir.InterfaceType type) => type != null
|
||||
? new ExactInterfaceType(
|
||||
type.classNode, type.nullability, type.typeArguments)
|
||||
? ExactInterfaceType(type.classNode, type.nullability, type.typeArguments)
|
||||
: null;
|
||||
|
||||
@override
|
||||
|
|
|
@ -24,7 +24,7 @@ class StaticTypeCache {
|
|||
Map<ir.ForInStatement, ir.DartType> forInIteratorTypes = source
|
||||
.readTreeNodeMapInContext(source.readDartTypeNode, emptyAsNull: true);
|
||||
source.end(tag);
|
||||
return new StaticTypeCache(expressionTypes, forInIteratorTypes);
|
||||
return StaticTypeCache(expressionTypes, forInIteratorTypes);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ SourceSpan computeSourceSpanFromTreeNode(ir.TreeNode node) {
|
|||
node = node.parent;
|
||||
}
|
||||
if (uri != null) {
|
||||
return new SourceSpan(uri, offset, offset + 1);
|
||||
return SourceSpan(uri, offset, offset + 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ AsyncMarker getAsyncMarker(ir.FunctionNode node) {
|
|||
return AsyncMarker.SYNC_STAR;
|
||||
case ir.AsyncMarker.SyncYielding:
|
||||
default:
|
||||
throw new UnsupportedError(
|
||||
throw UnsupportedError(
|
||||
"Async marker ${node.asyncMarker} is not supported.");
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ Variance convertVariance(ir.TypeParameter node) {
|
|||
case ir.Variance.invariant:
|
||||
return Variance.invariant;
|
||||
default:
|
||||
throw new UnsupportedError("Variance ${node.variance} is not supported.");
|
||||
throw UnsupportedError("Variance ${node.variance} is not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ NullAwareExpression getNullAwareExpression(ir.TreeNode node) {
|
|||
if (receiver is ir.VariableGet && receiver.variable == node.variable) {
|
||||
// We have
|
||||
// let #t1 = e0 in #t1 == null ? null : e1
|
||||
return new NullAwareExpression(node.variable, body.otherwise);
|
||||
return NullAwareExpression(node.variable, body.otherwise);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ class _FreeVariableVisitor implements ir.DartTypeVisitor<bool> {
|
|||
|
||||
@override
|
||||
bool defaultDartType(ir.DartType node) {
|
||||
throw new UnsupportedError("FreeVariableVisitor.defaultTypeNode");
|
||||
throw UnsupportedError("FreeVariableVisitor.defaultTypeNode");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class Stringifier extends ir.ExpressionVisitor<String> {
|
|||
|
||||
@override
|
||||
String visitStringConcatenation(ir.StringConcatenation node) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuffer sb = StringBuffer();
|
||||
for (ir.Expression expression in node.expressions) {
|
||||
String value = expression.accept(this);
|
||||
if (value == null) return null;
|
||||
|
@ -78,7 +78,7 @@ class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
|
|||
|
||||
List<DartType> visitTypes(List<ir.DartType> types) {
|
||||
topLevel = false;
|
||||
return new List.generate(
|
||||
return List.generate(
|
||||
types.length, (int index) => types[index].accept(this));
|
||||
}
|
||||
|
||||
|
@ -196,13 +196,12 @@ class ConstantValuefier extends ir.ComputeOnceConstantVisitor<ConstantValue> {
|
|||
|
||||
@override
|
||||
ConstantValue defaultConstant(ir.Constant node) {
|
||||
throw new UnsupportedError(
|
||||
"Unexpected constant $node (${node.runtimeType}).");
|
||||
throw UnsupportedError("Unexpected constant $node (${node.runtimeType}).");
|
||||
}
|
||||
|
||||
@override
|
||||
ConstantValue visitUnevaluatedConstant(ir.UnevaluatedConstant node) {
|
||||
throw new UnsupportedError("Unexpected unevaluated constant $node.");
|
||||
throw UnsupportedError("Unexpected unevaluated constant $node.");
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -216,7 +215,7 @@ class ConstantValuefier extends ir.ComputeOnceConstantVisitor<ConstantValue> {
|
|||
ir.Procedure member = node.target;
|
||||
FunctionEntity function = elementMap.getMethod(member);
|
||||
DartType type = elementMap.getFunctionType(member.function);
|
||||
return new FunctionConstantValue(function, type);
|
||||
return FunctionConstantValue(function, type);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -226,7 +225,7 @@ class ConstantValuefier extends ir.ComputeOnceConstantVisitor<ConstantValue> {
|
|||
typeArguments.add(elementMap.getDartType(type));
|
||||
}
|
||||
FunctionConstantValue function = visitConstant(node.tearOffConstant);
|
||||
return new InstantiationConstantValue(typeArguments, function);
|
||||
return InstantiationConstantValue(typeArguments, function);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -238,7 +237,7 @@ class ConstantValuefier extends ir.ComputeOnceConstantVisitor<ConstantValue> {
|
|||
FieldEntity field = elementMap.getField(reference.asField);
|
||||
fields[field] = visitConstant(value);
|
||||
});
|
||||
return new ConstructedConstantValue(type, fields);
|
||||
return ConstructedConstantValue(type, fields);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue