Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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() { | |
| 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(); |
|
floitsch
2012/01/18 15:22:14
add selector.asIdentifier() !== null ?
karlklose
2012/01/18 16:36:09
Done.
| |
| 233 } | 251 } |
| 234 bool get isOperator() => selector is Operator; | 252 bool get isOperator() => selector is Operator; |
| 235 bool get isPropertyAccess() => argumentsNode === null; | 253 bool get isPropertyAccess() => argumentsNode === null; |
| 236 bool get isFunctionObjectInvocation() => selector === null; | 254 bool get isFunctionObjectInvocation() => selector === null; |
| 237 bool get isPrefix() => argumentsNode is Prefix; | 255 bool get isPrefix() => argumentsNode is Prefix; |
| 238 bool get isPostfix() => argumentsNode is Postfix; | 256 bool get isPostfix() => argumentsNode is Postfix; |
| 239 bool get isIndex() => | 257 bool get isIndex() => |
| 240 isOperator && selector.asOperator().source.stringValue === '[]'; | 258 isOperator && selector.asOperator().source.stringValue === '[]'; |
| 241 | 259 |
| 242 Token getBeginToken() { | 260 Token getBeginToken() { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 * | 532 * |
| 515 * A NodeList can only occur at the end and holds named parameters. | 533 * A NodeList can only occur at the end and holds named parameters. |
| 516 */ | 534 */ |
| 517 final NodeList parameters; | 535 final NodeList parameters; |
| 518 | 536 |
| 519 final Statement body; | 537 final Statement body; |
| 520 final TypeAnnotation returnType; | 538 final TypeAnnotation returnType; |
| 521 final Modifiers modifiers; | 539 final Modifiers modifiers; |
| 522 final NodeList initializers; | 540 final NodeList initializers; |
| 523 | 541 |
| 542 int _cachedParameterCount; | |
| 543 | |
| 544 int parameterCount() { | |
| 545 if (_cachedParameterCount === null) { | |
| 546 _cachedParameterCount = 0; | |
| 547 for (Link l = parameters._nodes; !l.isEmpty(); l = l.tail) { | |
| 548 _cachedParameterCount++; | |
| 549 } | |
| 550 } | |
| 551 return _cachedParameterCount; | |
| 552 } | |
| 553 | |
| 524 FunctionExpression(this.name, this.parameters, this.body, this.returnType, | 554 FunctionExpression(this.name, this.parameters, this.body, this.returnType, |
| 525 this.modifiers, this.initializers); | 555 this.modifiers, this.initializers); |
| 526 | 556 |
| 527 FunctionExpression asFunctionExpression() => this; | 557 FunctionExpression asFunctionExpression() => this; |
| 528 | 558 |
| 529 accept(Visitor visitor) => visitor.visitFunctionExpression(this); | 559 accept(Visitor visitor) => visitor.visitFunctionExpression(this); |
| 530 | 560 |
| 531 visitChildren(Visitor visitor) { | 561 visitChildren(Visitor visitor) { |
| 532 if (name !== null) name.accept(visitor); | 562 if (name !== null) name.accept(visitor); |
| 533 if (parameters !== null) parameters.accept(visitor); | 563 if (parameters !== null) parameters.accept(visitor); |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1255 | 1285 |
| 1256 visitChildren(Visitor visitor) { | 1286 visitChildren(Visitor visitor) { |
| 1257 formals.accept(visitor); | 1287 formals.accept(visitor); |
| 1258 block.accept(visitor); | 1288 block.accept(visitor); |
| 1259 } | 1289 } |
| 1260 | 1290 |
| 1261 Token getBeginToken() => catchKeyword; | 1291 Token getBeginToken() => catchKeyword; |
| 1262 | 1292 |
| 1263 Token getEndToken() => block.getEndToken(); | 1293 Token getEndToken() => block.getEndToken(); |
| 1264 } | 1294 } |
| OLD | NEW |