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

Unified Diff: pkg/compiler/lib/src/typechecker.dart

Issue 1220043005: dart2js send stats, includes: (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 months 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
Index: pkg/compiler/lib/src/typechecker.dart
diff --git a/pkg/compiler/lib/src/typechecker.dart b/pkg/compiler/lib/src/typechecker.dart
index 2d854a2e59e3aabcfca6a687929362a93ad6a576..caad6b4f10a39beea02b254ff7e4e075ceb10cd7 100644
--- a/pkg/compiler/lib/src/typechecker.dart
+++ b/pkg/compiler/lib/src/typechecker.dart
@@ -430,7 +430,7 @@ class TypeCheckerVisitor extends Visitor<DartType> {
if (result == null) {
compiler.internalError(node, 'Type is null.');
}
- return result;
+ return _record(node, result);
}
void checkTypePromotion(Node node, TypePromotion typePromotion,
@@ -1115,6 +1115,22 @@ class TypeCheckerVisitor extends Visitor<DartType> {
}
+ static bool _fyiShown = false;
+ DartType _record(Node node, DartType type) {
+ if (node is! Expression) return type;
+ if (compiler.computeAnalysisStats &&
+ executableContext != null &&
+ // TODO(sigmund): enable also in core libs.
+ !executableContext.library.isPlatformLibrary && !type.isDynamic) {
+ if (!_fyiShown) {
+ print('FYI computeAnalysisStats is on: caching types of expressions');
+ _fyiShown = true;
+ }
+ elements.typesCache[node] = type;
+ }
+ return type;
+ }
+
DartType visitSend(Send node) {
if (elements.isAssert(node)) {
return analyzeInvocation(node, const AssertAccess());
@@ -1689,6 +1705,17 @@ class TypeCheckerVisitor extends Visitor<DartType> {
SendSet initialization = definition;
DartType initializer = analyzeNonVoid(initialization.arguments.head);
checkAssignable(initialization.assignmentOperator, initializer, type);
+ // TODO(sigmund): explore inferring a type for `var` using the RHS (like
+ // DDC does), for example:
+ // if (node.type == null && node.modifiers.isVar &&
+ // !initializer.isDynamic) {
+ // var variable = elements[definition];
+ // if (variable != null) {
+ // var typePromotion = new TypePromotion(
+ // node, variable, initializer);
+ // registerKnownTypePromotion(typePromotion);
+ // }
+ // }
}
}
return const StatementType();

Powered by Google App Engine
This is Rietveld 408576698