Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: pkg/compiler/lib/src/inferrer/closure_tracer.dart

Issue 1498643002: Minor cleanup in inferrer folder (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/debug.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/inferrer/closure_tracer.dart
diff --git a/pkg/compiler/lib/src/inferrer/closure_tracer.dart b/pkg/compiler/lib/src/inferrer/closure_tracer.dart
index aa780019e9329697e9f0048db53f3a720a555147..b7d1ef7b71ea50a90d9d896e64df8b0250f314e6 100644
--- a/pkg/compiler/lib/src/inferrer/closure_tracer.dart
+++ b/pkg/compiler/lib/src/inferrer/closure_tracer.dart
@@ -2,11 +2,20 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-part of type_graph_inferrer;
+library compiler.src.inferrer.closure_tracer;
+
+import '../types/types.dart' show TypeMask;
+import '../common/names.dart' show Names;
+import '../elements/elements.dart';
+import '../universe/selector.dart' show Selector;
+import 'node_tracer.dart';
+import 'type_graph_nodes.dart';
+import 'debug.dart' as debug;
+
class ClosureTracerVisitor extends TracerVisitor<ApplyableTypeInformation> {
final Iterable<FunctionElement> tracedElements;
- final List<CallSiteTypeInformation> callsToAnalyze =
+ final List<CallSiteTypeInformation> _callsToAnalyze =
new List<CallSiteTypeInformation>();
ClosureTracerVisitor(this.tracedElements, tracedType, inferrer)
@@ -15,7 +24,7 @@ class ClosureTracerVisitor extends TracerVisitor<ApplyableTypeInformation> {
void run() {
analyze();
if (!continueAnalyzing) return;
- callsToAnalyze.forEach(analyzeCall);
+ _callsToAnalyze.forEach(_analyzeCall);
for(FunctionElement e in tracedElements) {
e.functionSignature.forEachParameter((Element parameter) {
ElementTypeInformation info =
@@ -25,18 +34,18 @@ class ClosureTracerVisitor extends TracerVisitor<ApplyableTypeInformation> {
}
}
- void tagAsFunctionApplyTarget([String reason]) {
+ void _tagAsFunctionApplyTarget([String reason]) {
tracedType.mightBePassedToFunctionApply = true;
- if (_VERBOSE) {
+ if (debug.VERBOSE) {
print("Closure $tracedType might be passed to apply: $reason");
}
}
- void registerCallForLaterAnalysis(CallSiteTypeInformation info) {
- callsToAnalyze.add(info);
+ void _registerCallForLaterAnalysis(CallSiteTypeInformation info) {
+ _callsToAnalyze.add(info);
}
- void analyzeCall(CallSiteTypeInformation info) {
+ void _analyzeCall(CallSiteTypeInformation info) {
Selector selector = info.selector;
TypeMask mask = info.mask;
tracedElements.forEach((FunctionElement functionElement) {
@@ -46,15 +55,17 @@ class ClosureTracerVisitor extends TracerVisitor<ApplyableTypeInformation> {
});
}
+ @override
visitClosureCallSiteTypeInformation(ClosureCallSiteTypeInformation info) {
super.visitClosureCallSiteTypeInformation(info);
if (info.closure == currentUser) {
- registerCallForLaterAnalysis(info);
+ _registerCallForLaterAnalysis(info);
} else {
bailout('Passed to a closure');
}
}
+ @override
visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) {
super.visitStaticCallSiteTypeInformation(info);
Element called = info.calledElement;
@@ -70,23 +81,22 @@ class ClosureTracerVisitor extends TracerVisitor<ApplyableTypeInformation> {
&& inferrer.types.getInferredTypeOf(called) == currentUser) {
// This node can be a closure call as well. For example, `foo()`
// where `foo` is a getter.
- registerCallForLaterAnalysis(info);
+ _registerCallForLaterAnalysis(info);
}
- if (checkIfFunctionApply(called) &&
+ if (_checkIfFunctionApply(called) &&
info.arguments != null &&
info.arguments.contains(currentUser)) {
- tagAsFunctionApplyTarget("static call");
+ _tagAsFunctionApplyTarget("static call");
}
}
- bool checkIfCurrentUser(element) {
- return inferrer.types.getInferredTypeOf(element) == currentUser;
- }
+ bool _checkIfCurrentUser(element) =>
+ inferrer.types.getInferredTypeOf(element) == currentUser;
- bool checkIfFunctionApply(element) {
- return compiler.functionApplyMethod == element;
- }
+ bool _checkIfFunctionApply(element) =>
+ compiler.functionApplyMethod == element;
+ @override
visitDynamicCallSiteTypeInformation(DynamicCallSiteTypeInformation info) {
super.visitDynamicCallSiteTypeInformation(info);
if (info.selector.isCall) {
@@ -94,11 +104,11 @@ class ClosureTracerVisitor extends TracerVisitor<ApplyableTypeInformation> {
if (!info.targets.every((element) => element.isFunction)) {
bailout('Passed to a closure');
}
- if (info.targets.any(checkIfFunctionApply)) {
- tagAsFunctionApplyTarget("dynamic call");
+ if (info.targets.any(_checkIfFunctionApply)) {
+ _tagAsFunctionApplyTarget("dynamic call");
}
- } else if (info.targets.any((element) => checkIfCurrentUser(element))) {
- registerCallForLaterAnalysis(info);
+ } else if (info.targets.any((element) => _checkIfCurrentUser(element))) {
+ _registerCallForLaterAnalysis(info);
}
} else if (info.selector.isGetter &&
info.selector.memberName == Names.call) {
@@ -112,6 +122,7 @@ class StaticTearOffClosureTracerVisitor extends ClosureTracerVisitor {
StaticTearOffClosureTracerVisitor(tracedElement, tracedType, inferrer)
: super([tracedElement], tracedType, inferrer);
+ @override
visitStaticCallSiteTypeInformation(StaticCallSiteTypeInformation info) {
super.visitStaticCallSiteTypeInformation(info);
if (info.calledElement == tracedElements.first
« no previous file with comments | « no previous file | pkg/compiler/lib/src/inferrer/debug.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698