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

Side by Side Diff: frog/leg/tree/nodes.dart

Issue 9243011: Implement named constructors and resolving of redirecting constructors and super-initializers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 11 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 interface Visitor<R> { 5 interface Visitor<R> {
6 R visitBlock(Block node); 6 R visitBlock(Block node);
7 R visitBreakStatement(BreakStatement node); 7 R visitBreakStatement(BreakStatement node);
8 R visitCatchBlock(CatchBlock node); 8 R visitCatchBlock(CatchBlock node);
9 R visitClassNode(ClassNode node); 9 R visitClassNode(ClassNode node);
10 R visitConditional(Conditional node); 10 R visitConditional(Conditional node);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 accept(Visitor visitor) => visitor.visitSend(this); 219 accept(Visitor visitor) => visitor.visitSend(this);
220 220
221 visitChildren(Visitor visitor) { 221 visitChildren(Visitor visitor) {
222 if (receiver !== null) receiver.accept(visitor); 222 if (receiver !== null) receiver.accept(visitor);
223 if (selector !== null) selector.accept(visitor); 223 if (selector !== null) selector.accept(visitor);
224 if (argumentsNode !== null) argumentsNode.accept(visitor); 224 if (argumentsNode !== null) argumentsNode.accept(visitor);
225 } 225 }
226 226
227 int argumentCount() => argumentsNode.length(); 227 int argumentCount() => argumentsNode.length();
228 228
229 bool get isSuperConstructorCall() {
ngeoffray 2012/01/19 08:56:12 I don't really like these methods being here, as t
karlklose 2012/01/19 13:51:24 Done.
230 return (receiver === null &&
231 selector.asIdentifier() !== null &&
232 selector.asIdentifier().isSuper()) ||
233 (receiver !== null &&
234 receiver.asIdentifier() !== null &&
235 receiver.asIdentifier().isSuper() &&
236 selector.asIdentifier() !== null);
237 }
238 bool get isConstructorRedirect() {
239 return (receiver === null &&
240 selector.asIdentifier() !== null &&
241 selector.asIdentifier().isThis()) ||
242 (receiver !== null &&
243 receiver.asIdentifier() !== null &&
244 receiver.asIdentifier().isThis() &&
245 selector.asIdentifier() !== null);
246 }
229 bool get isSuperCall() { 247 bool get isSuperCall() {
230 return receiver !== null && 248 return receiver !== null &&
231 receiver.asIdentifier() !== null && 249 receiver.asIdentifier() !== null &&
232 receiver.asIdentifier().isSuper(); 250 receiver.asIdentifier().isSuper() &&
251 selector.asIdentifier() !== null;
ngeoffray 2012/01/19 08:56:12 I think you're allowed to do super[2]. Checking if
karlklose 2012/01/19 13:51:24 Done.
233 } 252 }
234 bool get isOperator() => selector is Operator; 253 bool get isOperator() => selector is Operator;
235 bool get isPropertyAccess() => argumentsNode === null; 254 bool get isPropertyAccess() => argumentsNode === null;
236 bool get isFunctionObjectInvocation() => selector === null; 255 bool get isFunctionObjectInvocation() => selector === null;
237 bool get isPrefix() => argumentsNode is Prefix; 256 bool get isPrefix() => argumentsNode is Prefix;
238 bool get isPostfix() => argumentsNode is Postfix; 257 bool get isPostfix() => argumentsNode is Postfix;
239 bool get isIndex() => 258 bool get isIndex() =>
240 isOperator && selector.asOperator().source.stringValue === '[]'; 259 isOperator && selector.asOperator().source.stringValue === '[]';
241 260
242 Token getBeginToken() { 261 Token getBeginToken() {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 * 533 *
515 * A NodeList can only occur at the end and holds named parameters. 534 * A NodeList can only occur at the end and holds named parameters.
516 */ 535 */
517 final NodeList parameters; 536 final NodeList parameters;
518 537
519 final Statement body; 538 final Statement body;
520 final TypeAnnotation returnType; 539 final TypeAnnotation returnType;
521 final Modifiers modifiers; 540 final Modifiers modifiers;
522 final NodeList initializers; 541 final NodeList initializers;
523 542
543 int _cachedParameterCount;
ngeoffray 2012/01/19 08:56:12 Like I said in the resolver, I think this belongs
karlklose 2012/01/19 13:51:24 Done.
544
545 int parameterCount() {
546 if (_cachedParameterCount === null) {
547 _cachedParameterCount = 0;
548 for (Link l = parameters._nodes; !l.isEmpty(); l = l.tail) {
549 _cachedParameterCount++;
550 }
551 }
552 return _cachedParameterCount;
553 }
554
524 FunctionExpression(this.name, this.parameters, this.body, this.returnType, 555 FunctionExpression(this.name, this.parameters, this.body, this.returnType,
525 this.modifiers, this.initializers); 556 this.modifiers, this.initializers);
526 557
527 FunctionExpression asFunctionExpression() => this; 558 FunctionExpression asFunctionExpression() => this;
528 559
529 accept(Visitor visitor) => visitor.visitFunctionExpression(this); 560 accept(Visitor visitor) => visitor.visitFunctionExpression(this);
530 561
531 visitChildren(Visitor visitor) { 562 visitChildren(Visitor visitor) {
532 if (name !== null) name.accept(visitor); 563 if (name !== null) name.accept(visitor);
533 if (parameters !== null) parameters.accept(visitor); 564 if (parameters !== null) parameters.accept(visitor);
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 1286
1256 visitChildren(Visitor visitor) { 1287 visitChildren(Visitor visitor) {
1257 formals.accept(visitor); 1288 formals.accept(visitor);
1258 block.accept(visitor); 1289 block.accept(visitor);
1259 } 1290 }
1260 1291
1261 Token getBeginToken() => catchKeyword; 1292 Token getBeginToken() => catchKeyword;
1262 1293
1263 Token getEndToken() => block.getEndToken(); 1294 Token getEndToken() => block.getEndToken();
1264 } 1295 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698