@@ -47,16 +47,15 @@ import 'types.dart';
47
47
class InferrerEngine {
48
48
/// A set of selector names that [List] implements, that we know return their
49
49
/// element type.
50
- final Set <Selector > returnsListElementTypeSet =
51
- new Set <Selector >.from (< Selector > [
52
- new Selector .getter (const PublicName ('first' )),
53
- new Selector .getter (const PublicName ('last' )),
54
- new Selector .getter (const PublicName ('single' )),
55
- new Selector .call (const PublicName ('singleWhere' ), CallStructure .ONE_ARG ),
56
- new Selector .call (const PublicName ('elementAt' ), CallStructure .ONE_ARG ),
57
- new Selector .index (),
58
- new Selector .call (const PublicName ('removeAt' ), CallStructure .ONE_ARG ),
59
- new Selector .call (const PublicName ('removeLast' ), CallStructure .NO_ARGS )
50
+ final Set <Selector > returnsListElementTypeSet = Set <Selector >.from (< Selector > [
51
+ Selector .getter (const PublicName ('first' )),
52
+ Selector .getter (const PublicName ('last' )),
53
+ Selector .getter (const PublicName ('single' )),
54
+ Selector .call (const PublicName ('singleWhere' ), CallStructure .ONE_ARG ),
55
+ Selector .call (const PublicName ('elementAt' ), CallStructure .ONE_ARG ),
56
+ Selector .index (),
57
+ Selector .call (const PublicName ('removeAt' ), CallStructure .ONE_ARG ),
58
+ Selector .call (const PublicName ('removeLast' ), CallStructure .NO_ARGS )
60
59
]);
61
60
62
61
/// The [JClosedWorld] on which inference reasoning is based.
@@ -91,12 +90,12 @@ class InferrerEngine {
91
90
final CompilerOutput _compilerOutput;
92
91
93
92
final Set <ConstructorEntity > _generativeConstructorsExposingThis =
94
- new Set <ConstructorEntity >();
93
+ Set <ConstructorEntity >();
95
94
96
95
/// Data computed internally within elements, like the type-mask of a send a
97
96
/// list allocation, or a for-in loop.
98
97
final Map <MemberEntity , GlobalTypeInferenceElementData > _memberData =
99
- new Map <MemberEntity , GlobalTypeInferenceElementData >();
98
+ Map <MemberEntity , GlobalTypeInferenceElementData >();
100
99
101
100
ElementEnvironment get _elementEnvironment => closedWorld.elementEnvironment;
102
101
@@ -117,8 +116,8 @@ class InferrerEngine {
117
116
this .mainElement,
118
117
this .globalLocalsMap,
119
118
this .inferredDataBuilder)
120
- : this .types = new TypeSystem (closedWorld,
121
- new KernelTypeSystemStrategy (closedWorld, globalLocalsMap));
119
+ : this .types = TypeSystem (closedWorld,
120
+ KernelTypeSystemStrategy (closedWorld, globalLocalsMap));
122
121
123
122
/// Applies [f] to all elements in the universe that match [selector] and
124
123
/// [mask] . If [f] returns false, aborts the iteration.
@@ -132,7 +131,7 @@ class InferrerEngine {
132
131
133
132
// TODO(johnniwinther): Make this private again.
134
133
GlobalTypeInferenceElementData dataOfMember (MemberEntity element) =>
135
- _memberData[element] ?? = new KernelGlobalTypeInferenceElementData ();
134
+ _memberData[element] ?? = KernelGlobalTypeInferenceElementData ();
136
135
137
136
/// Update [sideEffects] with the side effects of [callee] being
138
137
/// called with [selector] .
@@ -254,7 +253,7 @@ class InferrerEngine {
254
253
if (info.analyzed) return ;
255
254
info.analyzed = true ;
256
255
257
- ListTracerVisitor tracer = new ListTracerVisitor (info, this );
256
+ ListTracerVisitor tracer = ListTracerVisitor (info, this );
258
257
bool succeeded = tracer.run ();
259
258
if (! succeeded) return ;
260
259
@@ -274,7 +273,7 @@ class InferrerEngine {
274
273
if (info.analyzed) return ;
275
274
info.analyzed = true ;
276
275
277
- SetTracerVisitor tracer = new SetTracerVisitor (info, this );
276
+ SetTracerVisitor tracer = SetTracerVisitor (info, this );
278
277
bool succeeded = tracer.run ();
279
278
if (! succeeded) return ;
280
279
@@ -290,7 +289,7 @@ class InferrerEngine {
290
289
void analyzeMapAndEnqueue (MapTypeInformation info) {
291
290
if (info.analyzed) return ;
292
291
info.analyzed = true ;
293
- MapTracerVisitor tracer = new MapTracerVisitor (info, this );
292
+ MapTracerVisitor tracer = MapTracerVisitor (info, this );
294
293
295
294
bool succeeded = tracer.run ();
296
295
if (! succeeded) return ;
@@ -319,7 +318,7 @@ class InferrerEngine {
319
318
void _runOverAllElements () {
320
319
metrics.analyze.measure (_analyzeAllElements);
321
320
TypeGraphDump dump =
322
- debug.PRINT_GRAPH ? new TypeGraphDump (_compilerOutput, this ) : null ;
321
+ debug.PRINT_GRAPH ? TypeGraphDump (_compilerOutput, this ) : null ;
323
322
324
323
dump? .beforeAnalysis ();
325
324
_buildWorkQueue ();
@@ -341,7 +340,7 @@ class InferrerEngine {
341
340
analyzeMapAndEnqueue (info);
342
341
});
343
342
344
- Set <FunctionEntity > bailedOutOn = new Set <FunctionEntity >();
343
+ Set <FunctionEntity > bailedOutOn = Set <FunctionEntity >();
345
344
346
345
// Trace closures to potentially infer argument types.
347
346
types.allocatedClosures.forEach ((dynamic info) {
@@ -384,7 +383,7 @@ class InferrerEngine {
384
383
385
384
if (info is ClosureTypeInformation ) {
386
385
Iterable <FunctionEntity > elements = [info.closure];
387
- trace (elements, new ClosureTracerVisitor (elements, info, this ));
386
+ trace (elements, ClosureTracerVisitor (elements, info, this ));
388
387
} else if (info is CallSiteTypeInformation ) {
389
388
if (info is StaticCallSiteTypeInformation &&
390
389
info.selector != null &&
@@ -398,18 +397,18 @@ class InferrerEngine {
398
397
FunctionEntity callMethod = _lookupCallMethod (cls);
399
398
assert (callMethod != null , failedAt (cls));
400
399
Iterable <FunctionEntity > elements = [callMethod];
401
- trace (elements, new ClosureTracerVisitor (elements, info, this ));
400
+ trace (elements, ClosureTracerVisitor (elements, info, this ));
402
401
} else {
403
402
// We only are interested in functions here, as other targets
404
403
// of this closure call are not a root to trace but an intermediate
405
404
// for some other function.
406
- Iterable <FunctionEntity > elements = new List <FunctionEntity >.from (
405
+ Iterable <FunctionEntity > elements = List <FunctionEntity >.from (
407
406
info.callees.where ((e) => e.isFunction));
408
- trace (elements, new ClosureTracerVisitor (elements, info, this ));
407
+ trace (elements, ClosureTracerVisitor (elements, info, this ));
409
408
}
410
409
} else if (info is MemberTypeInformation ) {
411
410
trace (< FunctionEntity > [info.member],
412
- new StaticTearOffClosureTracerVisitor (info.member, info, this ));
411
+ StaticTearOffClosureTracerVisitor (info.member, info, this ));
413
412
} else if (info is ParameterTypeInformation ) {
414
413
failedAt (
415
414
NO_LOCATION_SPANNABLE , 'Unexpected closure allocation info $info ' );
@@ -421,7 +420,7 @@ class InferrerEngine {
421
420
// Reset all nodes that use lists/maps that have been inferred, as well
422
421
// as nodes that use elements fetched from these lists/maps. The
423
422
// workset for a new run of the analysis will be these nodes.
424
- Set <TypeInformation > seenTypes = new Set <TypeInformation >();
423
+ Set <TypeInformation > seenTypes = Set <TypeInformation >();
425
424
while (! _workQueue.isEmpty) {
426
425
TypeInformation info = _workQueue.remove ();
427
426
if (seenTypes.contains (info)) continue ;
@@ -595,7 +594,7 @@ class InferrerEngine {
595
594
// of the type graph and do not drop any flow edges.
596
595
AbstractValue refinedType =
597
596
abstractValueDomain.computeAbstractValueForConstant (value);
598
- type = new NarrowTypeInformation (
597
+ type = NarrowTypeInformation (
599
598
abstractValueDomain, type, refinedType);
600
599
types.allocatedTypes.add (type);
601
600
}
@@ -630,7 +629,7 @@ class InferrerEngine {
630
629
/// Visits [body] to compute the [TypeInformation] node for [member] .
631
630
TypeInformation _computeMemberTypeInformation (
632
631
MemberEntity member, ir.Node body) {
633
- KernelTypeGraphBuilder visitor = new KernelTypeGraphBuilder (
632
+ KernelTypeGraphBuilder visitor = KernelTypeGraphBuilder (
634
633
_options,
635
634
closedWorld,
636
635
this ,
@@ -753,7 +752,7 @@ class InferrerEngine {
753
752
/// added to the work queue.
754
753
void updateParameterInputs (TypeInformation caller, MemberEntity callee,
755
754
ArgumentsTypes arguments, Selector selector,
756
- {bool remove, bool addToQueue: true }) {
755
+ {bool remove, bool addToQueue = true }) {
757
756
if (callee.name == Identifiers .noSuchMethod_) return ;
758
757
if (callee.isField) {
759
758
if (selector.isSetter) {
@@ -855,7 +854,7 @@ class InferrerEngine {
855
854
/// should be present and a default type for each parameter should exist.
856
855
TypeInformation getDefaultTypeOfParameter (Local parameter) {
857
856
return _defaultTypeOfParameter.putIfAbsent (parameter, () {
858
- return new PlaceholderTypeInformation (
857
+ return PlaceholderTypeInformation (
859
858
abstractValueDomain, types.currentMember);
860
859
});
861
860
}
@@ -927,7 +926,7 @@ class InferrerEngine {
927
926
ArgumentsTypes arguments,
928
927
SideEffectsBuilder sideEffectsBuilder,
929
928
bool inLoop) {
930
- CallSiteTypeInformation info = new StaticCallSiteTypeInformation (
929
+ CallSiteTypeInformation info = StaticCallSiteTypeInformation (
931
930
abstractValueDomain,
932
931
types.currentMember,
933
932
node,
@@ -988,7 +987,7 @@ class InferrerEngine {
988
987
_updateSideEffects (sideEffectsBuilder, selector, callee);
989
988
});
990
989
991
- CallSiteTypeInformation info = new DynamicCallSiteTypeInformation (
990
+ CallSiteTypeInformation info = DynamicCallSiteTypeInformation (
992
991
abstractValueDomain,
993
992
types.currentMember,
994
993
callType,
@@ -1008,8 +1007,8 @@ class InferrerEngine {
1008
1007
/// Registers a call to await with an expression of type [argumentType] as
1009
1008
/// argument.
1010
1009
TypeInformation registerAwait (ir.Node node, TypeInformation argument) {
1011
- AwaitTypeInformation info = new AwaitTypeInformation (
1012
- abstractValueDomain, types.currentMember, node);
1010
+ AwaitTypeInformation info =
1011
+ AwaitTypeInformation ( abstractValueDomain, types.currentMember, node);
1013
1012
info.addInput (argument);
1014
1013
types.allocatedTypes.add (info);
1015
1014
return info;
@@ -1018,8 +1017,8 @@ class InferrerEngine {
1018
1017
/// Registers a call to yield with an expression of type [argumentType] as
1019
1018
/// argument.
1020
1019
TypeInformation registerYield (ir.Node node, TypeInformation argument) {
1021
- YieldTypeInformation info = new YieldTypeInformation (
1022
- abstractValueDomain, types.currentMember, node);
1020
+ YieldTypeInformation info =
1021
+ YieldTypeInformation ( abstractValueDomain, types.currentMember, node);
1023
1022
info.addInput (argument);
1024
1023
types.allocatedTypes.add (info);
1025
1024
return info;
@@ -1040,7 +1039,7 @@ class InferrerEngine {
1040
1039
SideEffectsBuilder sideEffectsBuilder,
1041
1040
{bool inLoop}) {
1042
1041
sideEffectsBuilder.setAllSideEffectsAndDependsOnSomething ();
1043
- CallSiteTypeInformation info = new ClosureCallSiteTypeInformation (
1042
+ CallSiteTypeInformation info = ClosureCallSiteTypeInformation (
1044
1043
abstractValueDomain,
1045
1044
types.currentMember,
1046
1045
node,
@@ -1149,21 +1148,21 @@ class InferrerEngine {
1149
1148
if (info != null ) return info;
1150
1149
1151
1150
TypeInformation receiverType =
1152
- new IndirectParameterTypeInformation (abstractValueDomain, 'receiver' );
1151
+ IndirectParameterTypeInformation (abstractValueDomain, 'receiver' );
1153
1152
List <TypeInformation > positional = [];
1154
1153
for (int i = 0 ; i < structure.positionalArgumentCount; i++ ) {
1155
1154
positional
1156
- .add (new IndirectParameterTypeInformation (abstractValueDomain, '$i ' ));
1155
+ .add (IndirectParameterTypeInformation (abstractValueDomain, '$i ' ));
1157
1156
}
1158
1157
Map <String , TypeInformation > named = {};
1159
1158
if (structure.namedArgumentCount > 0 ) {
1160
1159
for (var name in structure.namedArguments) {
1161
1160
named[name] =
1162
- new IndirectParameterTypeInformation (abstractValueDomain, name);
1161
+ IndirectParameterTypeInformation (abstractValueDomain, name);
1163
1162
}
1164
1163
}
1165
1164
1166
- info = _sharedCalls[selector] = new DynamicCallSiteTypeInformation (
1165
+ info = _sharedCalls[selector] = DynamicCallSiteTypeInformation (
1167
1166
abstractValueDomain,
1168
1167
null ,
1169
1168
CallType .indirectAccess,
@@ -1295,18 +1294,13 @@ class KernelTypeSystemStrategy implements TypeSystemStrategy {
1295
1294
MemberTypeInformation memberTypeInformation =
1296
1295
types.getInferredTypeOfMember (member);
1297
1296
if (isClosure) {
1298
- return new ParameterTypeInformation .localFunction (
1297
+ return ParameterTypeInformation .localFunction (
1299
1298
abstractValueDomain, memberTypeInformation, parameter, type, member);
1300
1299
} else if (member.isInstanceMember) {
1301
- return new ParameterTypeInformation .instanceMember (
1302
- abstractValueDomain,
1303
- memberTypeInformation,
1304
- parameter,
1305
- type,
1306
- member,
1307
- new ParameterInputs ());
1300
+ return ParameterTypeInformation .instanceMember (abstractValueDomain,
1301
+ memberTypeInformation, parameter, type, member, ParameterInputs ());
1308
1302
} else {
1309
- return new ParameterTypeInformation .static (
1303
+ return ParameterTypeInformation .static (
1310
1304
abstractValueDomain, memberTypeInformation, parameter, type, member);
1311
1305
}
1312
1306
}
@@ -1317,26 +1311,26 @@ class KernelTypeSystemStrategy implements TypeSystemStrategy {
1317
1311
if (member.isField) {
1318
1312
FieldEntity field = member;
1319
1313
DartType type = _elementEnvironment.getFieldType (field);
1320
- return new FieldTypeInformation (abstractValueDomain, field, type);
1314
+ return FieldTypeInformation (abstractValueDomain, field, type);
1321
1315
} else if (member.isGetter) {
1322
1316
FunctionEntity getter = member;
1323
1317
DartType type = _elementEnvironment.getFunctionType (getter);
1324
- return new GetterTypeInformation (abstractValueDomain, getter, type);
1318
+ return GetterTypeInformation (abstractValueDomain, getter, type);
1325
1319
} else if (member.isSetter) {
1326
1320
FunctionEntity setter = member;
1327
- return new SetterTypeInformation (abstractValueDomain, setter);
1321
+ return SetterTypeInformation (abstractValueDomain, setter);
1328
1322
} else if (member.isFunction) {
1329
1323
FunctionEntity method = member;
1330
1324
DartType type = _elementEnvironment.getFunctionType (method);
1331
- return new MethodTypeInformation (abstractValueDomain, method, type);
1325
+ return MethodTypeInformation (abstractValueDomain, method, type);
1332
1326
} else {
1333
1327
ConstructorEntity constructor = member;
1334
1328
if (constructor.isFactoryConstructor) {
1335
1329
DartType type = _elementEnvironment.getFunctionType (constructor);
1336
- return new FactoryConstructorTypeInformation (
1330
+ return FactoryConstructorTypeInformation (
1337
1331
abstractValueDomain, constructor, type);
1338
1332
} else {
1339
- return new GenerativeConstructorTypeInformation (
1333
+ return GenerativeConstructorTypeInformation (
1340
1334
abstractValueDomain, constructor);
1341
1335
}
1342
1336
}
@@ -1383,7 +1377,7 @@ class KernelGlobalTypeInferenceElementData
1383
1377
() => abstractValueDomain.readAbstractValueFromDataSource (source),
1384
1378
emptyAsNull: true );
1385
1379
source.end (tag);
1386
- return new KernelGlobalTypeInferenceElementData .internal (
1380
+ return KernelGlobalTypeInferenceElementData .internal (
1387
1381
sendMap, iteratorMap, currentMap, moveNextMap);
1388
1382
});
1389
1383
}
0 commit comments