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

Unified Diff: lib/compiler/implementation/typechecker.dart

Issue 9958009: Implement cascaded calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 8 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
« no previous file with comments | « lib/compiler/implementation/tree/visitors.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/typechecker.dart
diff --git a/lib/compiler/implementation/typechecker.dart b/lib/compiler/implementation/typechecker.dart
index a579b1172d3093ddbdf17af6096b78c53350f5e6..6f3dacc53efd2b0cb66bd92c10d575c63b3a8a22 100644
--- a/lib/compiler/implementation/typechecker.dart
+++ b/lib/compiler/implementation/typechecker.dart
@@ -178,6 +178,8 @@ class TypeCheckerVisitor implements Visitor<Type> {
Type expectedReturnType;
ClassElement currentClass;
+ Link<Type> cascadeTypes = const EmptyLink<Type>();
+
Type intType;
Type doubleType;
Type boolType;
@@ -252,10 +254,31 @@ class TypeCheckerVisitor implements Visitor<Type> {
checkAssignable(condition, boolType, analyze(condition));
}
+ void pushCascadeType(Type type) {
+ cascadeTypes = cascadeTypes.prepend(type);
+ }
+
+ void popCascadeType() {
+ Type type = cascadeTypes.head;
+ cascadeTypes = cascadeTypes.tail;
+ return type;
+ }
+
Type visitBlock(Block node) {
return analyze(node.statements);
}
+ Type visitCascade(Cascade node) {
+ analyze(node.expression);
+ return popCascadeType();
+ }
+
+ Type visitCascadeReceiver(CascadeReceiver node) {
+ Type type = analyze(node.expression);
+ pushCascadeType(type);
+ return type;
+ }
+
Type visitClassNode(ClassNode node) {
fail(node);
}
« no previous file with comments | « lib/compiler/implementation/tree/visitors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698