| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 234 } |
| 235 bool get isOperator() => selector is Operator; | 235 bool get isOperator() => selector is Operator; |
| 236 bool get isPropertyAccess() => argumentsNode === null; | 236 bool get isPropertyAccess() => argumentsNode === null; |
| 237 bool get isFunctionObjectInvocation() => selector === null; | 237 bool get isFunctionObjectInvocation() => selector === null; |
| 238 bool get isPrefix() => argumentsNode is Prefix; | 238 bool get isPrefix() => argumentsNode is Prefix; |
| 239 bool get isPostfix() => argumentsNode is Postfix; | 239 bool get isPostfix() => argumentsNode is Postfix; |
| 240 bool get isIndex() => | 240 bool get isIndex() => |
| 241 isOperator && selector.asOperator().source.stringValue === '[]'; | 241 isOperator && selector.asOperator().source.stringValue === '[]'; |
| 242 | 242 |
| 243 Token getBeginToken() { | 243 Token getBeginToken() { |
| 244 if (isPrefix && !isIndex) return selector.getBeginToken(); |
| 244 return firstBeginToken(receiver, selector); | 245 return firstBeginToken(receiver, selector); |
| 245 } | 246 } |
| 246 | 247 |
| 247 Token getEndToken() { | 248 Token getEndToken() { |
| 248 Token token; | 249 if (isPrefix) return firstBeginToken(receiver, selector); |
| 249 if (argumentsNode !== null) token = argumentsNode.getEndToken(); | 250 if (argumentsNode !== null) return argumentsNode.getEndToken(); |
| 250 if (token !== null) return token; | 251 if (selector !== null) return selector.getEndToken(); |
| 251 if (selector !== null) { | |
| 252 return selector.getEndToken(); | |
| 253 } | |
| 254 return receiver.getBeginToken(); | 252 return receiver.getBeginToken(); |
| 255 } | 253 } |
| 256 | 254 |
| 257 Send copyWithReceiver(Node receiver) { | 255 Send copyWithReceiver(Node receiver) { |
| 258 return new Send(receiver, selector, argumentsNode); | 256 return new Send(receiver, selector, argumentsNode); |
| 259 } | 257 } |
| 260 } | 258 } |
| 261 | 259 |
| 262 class Postfix extends NodeList { | 260 class Postfix extends NodeList { |
| 263 // TODO(floitsch): pass const EmptyLink<Node>() to super. | 261 // TODO(floitsch): pass const EmptyLink<Node>() to super. |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1443 | 1441 |
| 1444 visitChildren(Visitor visitor) { | 1442 visitChildren(Visitor visitor) { |
| 1445 formals.accept(visitor); | 1443 formals.accept(visitor); |
| 1446 block.accept(visitor); | 1444 block.accept(visitor); |
| 1447 } | 1445 } |
| 1448 | 1446 |
| 1449 Token getBeginToken() => catchKeyword; | 1447 Token getBeginToken() => catchKeyword; |
| 1450 | 1448 |
| 1451 Token getEndToken() => block.getEndToken(); | 1449 Token getEndToken() => block.getEndToken(); |
| 1452 } | 1450 } |
| OLD | NEW |