| 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 class Unparser implements Visitor { | 5 class Unparser implements Visitor { |
| 6 StringBuffer sb; | 6 StringBuffer sb; |
| 7 | 7 |
| 8 Unparser(); | 8 Unparser(); |
| 9 | 9 |
| 10 String unparse(Node node) { | 10 String unparse(Node node) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 79 |
| 80 visitFunctionDeclaration(FunctionDeclaration node) { | 80 visitFunctionDeclaration(FunctionDeclaration node) { |
| 81 visit(node.function); | 81 visit(node.function); |
| 82 } | 82 } |
| 83 | 83 |
| 84 visitFunctionExpression(FunctionExpression node) { | 84 visitFunctionExpression(FunctionExpression node) { |
| 85 if (node.returnType !== null) { | 85 if (node.returnType !== null) { |
| 86 visit(node.returnType); | 86 visit(node.returnType); |
| 87 sb.add(' '); | 87 sb.add(' '); |
| 88 } | 88 } |
| 89 visit(node.name); | 89 // TODO(antonm): that's a workaround as currently FunctionExpression |
| 90 // names are modelled with Send and it emits operator[] as only |
| 91 // operator, without [] which are expected to be emitted with |
| 92 // arguments. |
| 93 Send send = node.name.asSend(); |
| 94 if (send !== null) { |
| 95 assert(send is !SendSet); |
| 96 visit(send.receiver); |
| 97 visit(send.selector); |
| 98 } else { |
| 99 visit(node.name); |
| 100 } |
| 90 visit(node.parameters); | 101 visit(node.parameters); |
| 91 visit(node.body); | 102 visit(node.body); |
| 92 } | 103 } |
| 93 | 104 |
| 94 visitIdentifier(Identifier node) { | 105 visitIdentifier(Identifier node) { |
| 95 add(node.token.value); | 106 add(node.token.value); |
| 96 } | 107 } |
| 97 | 108 |
| 98 visitIf(If node) { | 109 visitIf(If node) { |
| 99 add(node.ifToken.value); | 110 add(node.ifToken.value); |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 sb.add(' '); | 443 sb.add(' '); |
| 433 } | 444 } |
| 434 visit(node.name); | 445 visit(node.name); |
| 435 if (node.typeParameters !== null) { | 446 if (node.typeParameters !== null) { |
| 436 visit(node.typeParameters); | 447 visit(node.typeParameters); |
| 437 } | 448 } |
| 438 visit(node.formals); | 449 visit(node.formals); |
| 439 add(node.endToken.value); | 450 add(node.endToken.value); |
| 440 } | 451 } |
| 441 } | 452 } |
| OLD | NEW |