OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class ResolvedVisitor<R> implements Visitor<R> { |
| 6 TreeElements elements; |
| 7 |
| 8 ResolvedVisitor(this.elements); |
| 9 |
| 10 R visitSend(Send node) { |
| 11 if (node.isSuperCall) { |
| 12 return visitSuperSend(node); |
| 13 } else if (node.isOperator) { |
| 14 return visitOperatorSend(node); |
| 15 } else if (node.isPropertyAccess) { |
| 16 return visitGetterSend(node); |
| 17 } else if (Elements.isClosureSend(node, elements)) { |
| 18 return visitClosureSend(node); |
| 19 } else { |
| 20 Element element = elements[node]; |
| 21 if (element === null) { |
| 22 // Example: f() with 'f' unbound. |
| 23 // This can only happen inside an instance method. |
| 24 return visitDynamicSend(node); |
| 25 } else if (element.kind == ElementKind.CLASS) { |
| 26 internalError("Cannot generate code for send", node: node); |
| 27 } else if (element.isInstanceMember()) { |
| 28 // Example: f() with 'f' bound to instance method. |
| 29 return visitDynamicSend(node); |
| 30 } else if (element.kind === ElementKind.FOREIGN) { |
| 31 return visitForeignSend(node); |
| 32 } else if (!element.isInstanceMember()) { |
| 33 // Example: A.f() or f() with 'f' bound to a static function. |
| 34 // Also includes new A() or new A.named() which is treated like a |
| 35 // static call to a factory. |
| 36 return visitStaticSend(node); |
| 37 } else { |
| 38 internalError("Cannot generate code for send", node: node); |
| 39 } |
| 40 } |
| 41 } |
| 42 |
| 43 abstract R visitSuperSend(Send node); |
| 44 abstract R visitOperatorSend(Send node); |
| 45 abstract R visitGetterSend(Send node); |
| 46 abstract R visitClosureSend(Send node); |
| 47 abstract R visitDynamicSend(Send node); |
| 48 abstract R visitForeignSend(Send node); |
| 49 abstract R visitStaticSend(Send node); |
| 50 |
| 51 abstract void internalError(String reason, [Node node]); |
| 52 } |
OLD | NEW |