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

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: Proof-of-concept implementation of cascade Created 8 years, 9 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: lib/compiler/implementation/typechecker.dart
diff --git a/lib/compiler/implementation/typechecker.dart b/lib/compiler/implementation/typechecker.dart
index 11ba1ee98ed0a6b5b955afa72898735a494c67ed..7d63fc041e0dd173418a56e7d32443f1eb52da5b 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);
}
« frog/tests/leg_only/src/CascadeTest.dart ('K') | « lib/compiler/implementation/tree/visitors.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698