| OLD | NEW |
| 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 abstract class Visitor<R> { | 5 abstract class Visitor<R> { |
| 6 const Visitor(); | 6 const Visitor(); |
| 7 | 7 |
| 8 abstract R visitNode(Node node); | 8 abstract R visitNode(Node node); |
| 9 | 9 |
| 10 R visitBlock(Block node) => visitStatement(node); | 10 R visitBlock(Block node) => visitStatement(node); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 return argumentsNode.getEndToken(); | 331 return argumentsNode.getEndToken(); |
| 332 } | 332 } |
| 333 if (selector != null) return selector.getEndToken(); | 333 if (selector != null) return selector.getEndToken(); |
| 334 return receiver.getBeginToken(); | 334 return receiver.getBeginToken(); |
| 335 } | 335 } |
| 336 | 336 |
| 337 Send copyWithReceiver(Node newReceiver) { | 337 Send copyWithReceiver(Node newReceiver) { |
| 338 assert(receiver == null); | 338 assert(receiver == null); |
| 339 return new Send(newReceiver, selector, argumentsNode); | 339 return new Send(newReceiver, selector, argumentsNode); |
| 340 } | 340 } |
| 341 | |
| 342 /** | |
| 343 * Returns the type annotation of a connstructor call in an object | |
| 344 * instantiation. | |
| 345 */ | |
| 346 TypeAnnotation getTypeAnnotation() { | |
| 347 if (selector is TypeAnnotation) { | |
| 348 return selector; | |
| 349 } else if (selector is Send) { | |
| 350 Send selectorSend = selector; | |
| 351 if (selectorSend.receiver is TypeAnnotation) { | |
| 352 return selectorSend.receiver; | |
| 353 } | |
| 354 } | |
| 355 return null; | |
| 356 } | |
| 357 } | 341 } |
| 358 | 342 |
| 359 class Postfix extends NodeList { | 343 class Postfix extends NodeList { |
| 360 Postfix() : super(null, const Link<Node>()); | 344 Postfix() : super(null, const Link<Node>()); |
| 361 Postfix.singleton(Node argument) : super.singleton(argument); | 345 Postfix.singleton(Node argument) : super.singleton(argument); |
| 362 } | 346 } |
| 363 | 347 |
| 364 class Prefix extends NodeList { | 348 class Prefix extends NodeList { |
| 365 Prefix() : super(null, const Link<Node>()); | 349 Prefix() : super(null, const Link<Node>()); |
| 366 Prefix.singleton(Node argument) : super.singleton(argument); | 350 Prefix.singleton(Node argument) : super.singleton(argument); |
| (...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 * argument). | 2001 * argument). |
| 2018 * | 2002 * |
| 2019 * TODO(ahe): This method is controversial, the team needs to discuss | 2003 * TODO(ahe): This method is controversial, the team needs to discuss |
| 2020 * if top-level methods are acceptable and what naming conventions to | 2004 * if top-level methods are acceptable and what naming conventions to |
| 2021 * use. | 2005 * use. |
| 2022 */ | 2006 */ |
| 2023 initializerDo(Node node, f(Node node)) { | 2007 initializerDo(Node node, f(Node node)) { |
| 2024 SendSet send = node.asSendSet(); | 2008 SendSet send = node.asSendSet(); |
| 2025 if (send != null) return f(send.arguments.head); | 2009 if (send != null) return f(send.arguments.head); |
| 2026 } | 2010 } |
| OLD | NEW |