Skip to content

Commit cc73b90

Browse files
rakudramacommit-bot@chromium.org
authored andcommitted
[dart2js] dart format --fix in inferrer/
Change-Id: I105784a65c1f4c0748bab157522af3bcc2aad066 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213862 Reviewed-by: Mayank Patke <[email protected]> Commit-Queue: Stephen Adams <[email protected]>
1 parent dffb06b commit cc73b90

17 files changed

+266
-277
lines changed

pkg/compiler/lib/src/inferrer/abstract_value_domain.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class AbstractBool {
3030

3131
/// A value of `Abstract.True` is used when the property is known _always_ to
3232
/// be true.
33-
static const AbstractBool True = const AbstractBool._(true);
33+
static const AbstractBool True = AbstractBool._(true);
3434

3535
/// A value of `Abstract.False` is used when the property is known _never_ to
3636
/// be true.
37-
static const AbstractBool False = const AbstractBool._(false);
37+
static const AbstractBool False = AbstractBool._(false);
3838

3939
/// A value of `Abstract.Maybe` is used when the property might or might not
4040
/// be true.
41-
static const AbstractBool Maybe = const AbstractBool._(null);
41+
static const AbstractBool Maybe = AbstractBool._(null);
4242

4343
static AbstractBool trueOrMaybe(bool value) => value ? True : Maybe;
4444

pkg/compiler/lib/src/inferrer/builder_kernel.dart

+76-80
Large diffs are not rendered by default.

pkg/compiler/lib/src/inferrer/inferrer_engine.dart

+51-57
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,15 @@ import 'types.dart';
4747
class InferrerEngine {
4848
/// A set of selector names that [List] implements, that we know return their
4949
/// 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)
6059
]);
6160

6261
/// The [JClosedWorld] on which inference reasoning is based.
@@ -91,12 +90,12 @@ class InferrerEngine {
9190
final CompilerOutput _compilerOutput;
9291

9392
final Set<ConstructorEntity> _generativeConstructorsExposingThis =
94-
new Set<ConstructorEntity>();
93+
Set<ConstructorEntity>();
9594

9695
/// Data computed internally within elements, like the type-mask of a send a
9796
/// list allocation, or a for-in loop.
9897
final Map<MemberEntity, GlobalTypeInferenceElementData> _memberData =
99-
new Map<MemberEntity, GlobalTypeInferenceElementData>();
98+
Map<MemberEntity, GlobalTypeInferenceElementData>();
10099

101100
ElementEnvironment get _elementEnvironment => closedWorld.elementEnvironment;
102101

@@ -117,8 +116,8 @@ class InferrerEngine {
117116
this.mainElement,
118117
this.globalLocalsMap,
119118
this.inferredDataBuilder)
120-
: this.types = new TypeSystem(closedWorld,
121-
new KernelTypeSystemStrategy(closedWorld, globalLocalsMap));
119+
: this.types = TypeSystem(closedWorld,
120+
KernelTypeSystemStrategy(closedWorld, globalLocalsMap));
122121

123122
/// Applies [f] to all elements in the universe that match [selector] and
124123
/// [mask]. If [f] returns false, aborts the iteration.
@@ -132,7 +131,7 @@ class InferrerEngine {
132131

133132
// TODO(johnniwinther): Make this private again.
134133
GlobalTypeInferenceElementData dataOfMember(MemberEntity element) =>
135-
_memberData[element] ??= new KernelGlobalTypeInferenceElementData();
134+
_memberData[element] ??= KernelGlobalTypeInferenceElementData();
136135

137136
/// Update [sideEffects] with the side effects of [callee] being
138137
/// called with [selector].
@@ -254,7 +253,7 @@ class InferrerEngine {
254253
if (info.analyzed) return;
255254
info.analyzed = true;
256255

257-
ListTracerVisitor tracer = new ListTracerVisitor(info, this);
256+
ListTracerVisitor tracer = ListTracerVisitor(info, this);
258257
bool succeeded = tracer.run();
259258
if (!succeeded) return;
260259

@@ -274,7 +273,7 @@ class InferrerEngine {
274273
if (info.analyzed) return;
275274
info.analyzed = true;
276275

277-
SetTracerVisitor tracer = new SetTracerVisitor(info, this);
276+
SetTracerVisitor tracer = SetTracerVisitor(info, this);
278277
bool succeeded = tracer.run();
279278
if (!succeeded) return;
280279

@@ -290,7 +289,7 @@ class InferrerEngine {
290289
void analyzeMapAndEnqueue(MapTypeInformation info) {
291290
if (info.analyzed) return;
292291
info.analyzed = true;
293-
MapTracerVisitor tracer = new MapTracerVisitor(info, this);
292+
MapTracerVisitor tracer = MapTracerVisitor(info, this);
294293

295294
bool succeeded = tracer.run();
296295
if (!succeeded) return;
@@ -319,7 +318,7 @@ class InferrerEngine {
319318
void _runOverAllElements() {
320319
metrics.analyze.measure(_analyzeAllElements);
321320
TypeGraphDump dump =
322-
debug.PRINT_GRAPH ? new TypeGraphDump(_compilerOutput, this) : null;
321+
debug.PRINT_GRAPH ? TypeGraphDump(_compilerOutput, this) : null;
323322

324323
dump?.beforeAnalysis();
325324
_buildWorkQueue();
@@ -341,7 +340,7 @@ class InferrerEngine {
341340
analyzeMapAndEnqueue(info);
342341
});
343342

344-
Set<FunctionEntity> bailedOutOn = new Set<FunctionEntity>();
343+
Set<FunctionEntity> bailedOutOn = Set<FunctionEntity>();
345344

346345
// Trace closures to potentially infer argument types.
347346
types.allocatedClosures.forEach((dynamic info) {
@@ -384,7 +383,7 @@ class InferrerEngine {
384383

385384
if (info is ClosureTypeInformation) {
386385
Iterable<FunctionEntity> elements = [info.closure];
387-
trace(elements, new ClosureTracerVisitor(elements, info, this));
386+
trace(elements, ClosureTracerVisitor(elements, info, this));
388387
} else if (info is CallSiteTypeInformation) {
389388
if (info is StaticCallSiteTypeInformation &&
390389
info.selector != null &&
@@ -398,18 +397,18 @@ class InferrerEngine {
398397
FunctionEntity callMethod = _lookupCallMethod(cls);
399398
assert(callMethod != null, failedAt(cls));
400399
Iterable<FunctionEntity> elements = [callMethod];
401-
trace(elements, new ClosureTracerVisitor(elements, info, this));
400+
trace(elements, ClosureTracerVisitor(elements, info, this));
402401
} else {
403402
// We only are interested in functions here, as other targets
404403
// of this closure call are not a root to trace but an intermediate
405404
// for some other function.
406-
Iterable<FunctionEntity> elements = new List<FunctionEntity>.from(
405+
Iterable<FunctionEntity> elements = List<FunctionEntity>.from(
407406
info.callees.where((e) => e.isFunction));
408-
trace(elements, new ClosureTracerVisitor(elements, info, this));
407+
trace(elements, ClosureTracerVisitor(elements, info, this));
409408
}
410409
} else if (info is MemberTypeInformation) {
411410
trace(<FunctionEntity>[info.member],
412-
new StaticTearOffClosureTracerVisitor(info.member, info, this));
411+
StaticTearOffClosureTracerVisitor(info.member, info, this));
413412
} else if (info is ParameterTypeInformation) {
414413
failedAt(
415414
NO_LOCATION_SPANNABLE, 'Unexpected closure allocation info $info');
@@ -421,7 +420,7 @@ class InferrerEngine {
421420
// Reset all nodes that use lists/maps that have been inferred, as well
422421
// as nodes that use elements fetched from these lists/maps. The
423422
// 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>();
425424
while (!_workQueue.isEmpty) {
426425
TypeInformation info = _workQueue.remove();
427426
if (seenTypes.contains(info)) continue;
@@ -595,7 +594,7 @@ class InferrerEngine {
595594
// of the type graph and do not drop any flow edges.
596595
AbstractValue refinedType =
597596
abstractValueDomain.computeAbstractValueForConstant(value);
598-
type = new NarrowTypeInformation(
597+
type = NarrowTypeInformation(
599598
abstractValueDomain, type, refinedType);
600599
types.allocatedTypes.add(type);
601600
}
@@ -630,7 +629,7 @@ class InferrerEngine {
630629
/// Visits [body] to compute the [TypeInformation] node for [member].
631630
TypeInformation _computeMemberTypeInformation(
632631
MemberEntity member, ir.Node body) {
633-
KernelTypeGraphBuilder visitor = new KernelTypeGraphBuilder(
632+
KernelTypeGraphBuilder visitor = KernelTypeGraphBuilder(
634633
_options,
635634
closedWorld,
636635
this,
@@ -753,7 +752,7 @@ class InferrerEngine {
753752
/// added to the work queue.
754753
void updateParameterInputs(TypeInformation caller, MemberEntity callee,
755754
ArgumentsTypes arguments, Selector selector,
756-
{bool remove, bool addToQueue: true}) {
755+
{bool remove, bool addToQueue = true}) {
757756
if (callee.name == Identifiers.noSuchMethod_) return;
758757
if (callee.isField) {
759758
if (selector.isSetter) {
@@ -855,7 +854,7 @@ class InferrerEngine {
855854
/// should be present and a default type for each parameter should exist.
856855
TypeInformation getDefaultTypeOfParameter(Local parameter) {
857856
return _defaultTypeOfParameter.putIfAbsent(parameter, () {
858-
return new PlaceholderTypeInformation(
857+
return PlaceholderTypeInformation(
859858
abstractValueDomain, types.currentMember);
860859
});
861860
}
@@ -927,7 +926,7 @@ class InferrerEngine {
927926
ArgumentsTypes arguments,
928927
SideEffectsBuilder sideEffectsBuilder,
929928
bool inLoop) {
930-
CallSiteTypeInformation info = new StaticCallSiteTypeInformation(
929+
CallSiteTypeInformation info = StaticCallSiteTypeInformation(
931930
abstractValueDomain,
932931
types.currentMember,
933932
node,
@@ -988,7 +987,7 @@ class InferrerEngine {
988987
_updateSideEffects(sideEffectsBuilder, selector, callee);
989988
});
990989

991-
CallSiteTypeInformation info = new DynamicCallSiteTypeInformation(
990+
CallSiteTypeInformation info = DynamicCallSiteTypeInformation(
992991
abstractValueDomain,
993992
types.currentMember,
994993
callType,
@@ -1008,8 +1007,8 @@ class InferrerEngine {
10081007
/// Registers a call to await with an expression of type [argumentType] as
10091008
/// argument.
10101009
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);
10131012
info.addInput(argument);
10141013
types.allocatedTypes.add(info);
10151014
return info;
@@ -1018,8 +1017,8 @@ class InferrerEngine {
10181017
/// Registers a call to yield with an expression of type [argumentType] as
10191018
/// argument.
10201019
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);
10231022
info.addInput(argument);
10241023
types.allocatedTypes.add(info);
10251024
return info;
@@ -1040,7 +1039,7 @@ class InferrerEngine {
10401039
SideEffectsBuilder sideEffectsBuilder,
10411040
{bool inLoop}) {
10421041
sideEffectsBuilder.setAllSideEffectsAndDependsOnSomething();
1043-
CallSiteTypeInformation info = new ClosureCallSiteTypeInformation(
1042+
CallSiteTypeInformation info = ClosureCallSiteTypeInformation(
10441043
abstractValueDomain,
10451044
types.currentMember,
10461045
node,
@@ -1149,21 +1148,21 @@ class InferrerEngine {
11491148
if (info != null) return info;
11501149

11511150
TypeInformation receiverType =
1152-
new IndirectParameterTypeInformation(abstractValueDomain, 'receiver');
1151+
IndirectParameterTypeInformation(abstractValueDomain, 'receiver');
11531152
List<TypeInformation> positional = [];
11541153
for (int i = 0; i < structure.positionalArgumentCount; i++) {
11551154
positional
1156-
.add(new IndirectParameterTypeInformation(abstractValueDomain, '$i'));
1155+
.add(IndirectParameterTypeInformation(abstractValueDomain, '$i'));
11571156
}
11581157
Map<String, TypeInformation> named = {};
11591158
if (structure.namedArgumentCount > 0) {
11601159
for (var name in structure.namedArguments) {
11611160
named[name] =
1162-
new IndirectParameterTypeInformation(abstractValueDomain, name);
1161+
IndirectParameterTypeInformation(abstractValueDomain, name);
11631162
}
11641163
}
11651164

1166-
info = _sharedCalls[selector] = new DynamicCallSiteTypeInformation(
1165+
info = _sharedCalls[selector] = DynamicCallSiteTypeInformation(
11671166
abstractValueDomain,
11681167
null,
11691168
CallType.indirectAccess,
@@ -1295,18 +1294,13 @@ class KernelTypeSystemStrategy implements TypeSystemStrategy {
12951294
MemberTypeInformation memberTypeInformation =
12961295
types.getInferredTypeOfMember(member);
12971296
if (isClosure) {
1298-
return new ParameterTypeInformation.localFunction(
1297+
return ParameterTypeInformation.localFunction(
12991298
abstractValueDomain, memberTypeInformation, parameter, type, member);
13001299
} 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());
13081302
} else {
1309-
return new ParameterTypeInformation.static(
1303+
return ParameterTypeInformation.static(
13101304
abstractValueDomain, memberTypeInformation, parameter, type, member);
13111305
}
13121306
}
@@ -1317,26 +1311,26 @@ class KernelTypeSystemStrategy implements TypeSystemStrategy {
13171311
if (member.isField) {
13181312
FieldEntity field = member;
13191313
DartType type = _elementEnvironment.getFieldType(field);
1320-
return new FieldTypeInformation(abstractValueDomain, field, type);
1314+
return FieldTypeInformation(abstractValueDomain, field, type);
13211315
} else if (member.isGetter) {
13221316
FunctionEntity getter = member;
13231317
DartType type = _elementEnvironment.getFunctionType(getter);
1324-
return new GetterTypeInformation(abstractValueDomain, getter, type);
1318+
return GetterTypeInformation(abstractValueDomain, getter, type);
13251319
} else if (member.isSetter) {
13261320
FunctionEntity setter = member;
1327-
return new SetterTypeInformation(abstractValueDomain, setter);
1321+
return SetterTypeInformation(abstractValueDomain, setter);
13281322
} else if (member.isFunction) {
13291323
FunctionEntity method = member;
13301324
DartType type = _elementEnvironment.getFunctionType(method);
1331-
return new MethodTypeInformation(abstractValueDomain, method, type);
1325+
return MethodTypeInformation(abstractValueDomain, method, type);
13321326
} else {
13331327
ConstructorEntity constructor = member;
13341328
if (constructor.isFactoryConstructor) {
13351329
DartType type = _elementEnvironment.getFunctionType(constructor);
1336-
return new FactoryConstructorTypeInformation(
1330+
return FactoryConstructorTypeInformation(
13371331
abstractValueDomain, constructor, type);
13381332
} else {
1339-
return new GenerativeConstructorTypeInformation(
1333+
return GenerativeConstructorTypeInformation(
13401334
abstractValueDomain, constructor);
13411335
}
13421336
}
@@ -1383,7 +1377,7 @@ class KernelGlobalTypeInferenceElementData
13831377
() => abstractValueDomain.readAbstractValueFromDataSource(source),
13841378
emptyAsNull: true);
13851379
source.end(tag);
1386-
return new KernelGlobalTypeInferenceElementData.internal(
1380+
return KernelGlobalTypeInferenceElementData.internal(
13871381
sendMap, iteratorMap, currentMap, moveNextMap);
13881382
});
13891383
}

pkg/compiler/lib/src/inferrer/list_tracer.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'type_graph_nodes.dart';
1515
/// A set of selector names that [List] implements, that we know do not
1616
/// change the element type of the list, or let the list escape to code
1717
/// that might change the element type.
18-
Set<String> okListSelectorsSet = new Set<String>.from(const <String>[
18+
Set<String> okListSelectorsSet = Set<String>.from(const <String>[
1919
// From Object.
2020
'==',
2121
'hashCode',
@@ -75,7 +75,7 @@ Set<String> okListSelectorsSet = new Set<String>.from(const <String>[
7575
'checkGrowable',
7676
]);
7777

78-
Set<String> doNotChangeLengthSelectorsSet = new Set<String>.from(const <String>[
78+
Set<String> doNotChangeLengthSelectorsSet = Set<String>.from(const <String>[
7979
// From Object.
8080
'==',
8181
'hashCode',
@@ -131,7 +131,7 @@ Set<String> doNotChangeLengthSelectorsSet = new Set<String>.from(const <String>[
131131

132132
class ListTracerVisitor extends TracerVisitor {
133133
// The [Set] of found assignments to the list.
134-
Set<TypeInformation> inputs = new Setlet<TypeInformation>();
134+
Set<TypeInformation> inputs = Setlet<TypeInformation>();
135135
bool callsGrowableMethod = false;
136136

137137
ListTracerVisitor(tracedType, inferrer) : super(tracedType, inferrer);

0 commit comments

Comments
 (0)