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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/tree/visitors.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class TypeCheckerTask extends CompilerTask { 5 class TypeCheckerTask extends CompilerTask {
6 TypeCheckerTask(Compiler compiler) : super(compiler); 6 TypeCheckerTask(Compiler compiler) : super(compiler);
7 String get name() => "Type checker"; 7 String get name() => "Type checker";
8 8
9 static final bool LOG_FAILURES = false; 9 static final bool LOG_FAILURES = false;
10 10
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 class TypeCheckerVisitor implements Visitor<Type> { 172 class TypeCheckerVisitor implements Visitor<Type> {
173 final Compiler compiler; 173 final Compiler compiler;
174 final TreeElements elements; 174 final TreeElements elements;
175 Node lastSeenNode; 175 Node lastSeenNode;
176 final Types types; 176 final Types types;
177 177
178 Type expectedReturnType; 178 Type expectedReturnType;
179 ClassElement currentClass; 179 ClassElement currentClass;
180 180
181 Link<Type> cascadeTypes = const EmptyLink<Type>();
182
181 Type intType; 183 Type intType;
182 Type doubleType; 184 Type doubleType;
183 Type boolType; 185 Type boolType;
184 Type stringType; 186 Type stringType;
185 Type objectType; 187 Type objectType;
186 Type listType; 188 Type listType;
187 189
188 TypeCheckerVisitor(Compiler this.compiler, TreeElements this.elements, 190 TypeCheckerVisitor(Compiler this.compiler, TreeElements this.elements,
189 Types this.types) { 191 Types this.types) {
190 intType = lookupType(Types.INT, compiler, types); 192 intType = lookupType(Types.INT, compiler, types);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 checkAssignable(Node node, Type s, Type t) { 247 checkAssignable(Node node, Type s, Type t) {
246 if (!types.isAssignable(s, t)) { 248 if (!types.isAssignable(s, t)) {
247 reportTypeWarning(node, MessageKind.NOT_ASSIGNABLE, [s, t]); 249 reportTypeWarning(node, MessageKind.NOT_ASSIGNABLE, [s, t]);
248 } 250 }
249 } 251 }
250 252
251 checkCondition(Expression condition) { 253 checkCondition(Expression condition) {
252 checkAssignable(condition, boolType, analyze(condition)); 254 checkAssignable(condition, boolType, analyze(condition));
253 } 255 }
254 256
257 void pushCascadeType(Type type) {
258 cascadeTypes = cascadeTypes.prepend(type);
259 }
260
261 void popCascadeType() {
262 Type type = cascadeTypes.head;
263 cascadeTypes = cascadeTypes.tail;
264 return type;
265 }
266
255 Type visitBlock(Block node) { 267 Type visitBlock(Block node) {
256 return analyze(node.statements); 268 return analyze(node.statements);
257 } 269 }
258 270
271 Type visitCascade(Cascade node) {
272 analyze(node.expression);
273 return popCascadeType();
274 }
275
276 Type visitCascadeReceiver(CascadeReceiver node) {
277 Type type = analyze(node.expression);
278 pushCascadeType(type);
279 return type;
280 }
281
259 Type visitClassNode(ClassNode node) { 282 Type visitClassNode(ClassNode node) {
260 fail(node); 283 fail(node);
261 } 284 }
262 285
263 Type visitDoWhile(DoWhile node) { 286 Type visitDoWhile(DoWhile node) {
264 StatementType bodyType = analyze(node.body); 287 StatementType bodyType = analyze(node.body);
265 checkCondition(node.condition); 288 checkCondition(node.condition);
266 return bodyType.join(StatementType.NOT_RETURNING); 289 return bodyType.join(StatementType.NOT_RETURNING);
267 } 290 }
268 291
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 730 }
708 731
709 visitCatchBlock(CatchBlock node) { 732 visitCatchBlock(CatchBlock node) {
710 fail(node); 733 fail(node);
711 } 734 }
712 735
713 visitTypedef(Typedef node) { 736 visitTypedef(Typedef node) {
714 fail(node); 737 fail(node);
715 } 738 }
716 } 739 }
OLDNEW
« 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