Chromium Code Reviews| 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 final Renamer renamer; | 6 final Renamer renamer; |
| 7 StringBuffer sb; | 7 StringBuffer sb; |
| 8 | 8 |
| 9 Unparser([this.renamer = const Renamer()]); | 9 Unparser([this.renamer = const Renamer()]); |
| 10 | 10 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 // names are modelled with Send and it emits operator[] as only | 100 // names are modelled with Send and it emits operator[] as only |
| 101 // operator, without [] which are expected to be emitted with | 101 // operator, without [] which are expected to be emitted with |
| 102 // arguments. | 102 // arguments. |
| 103 if (node.name is Send) { | 103 if (node.name is Send) { |
| 104 Send send = node.name; | 104 Send send = node.name; |
| 105 assert(send is !SendSet); | 105 assert(send is !SendSet); |
| 106 visit(send.receiver); | 106 visit(send.receiver); |
| 107 if (!send.isOperator) { | 107 if (!send.isOperator) { |
| 108 // Looks like a factory method. | 108 // Looks like a factory method. |
| 109 sb.add('.'); | 109 sb.add('.'); |
| 110 } else { | |
| 111 if (send.selector.token.stringValue === 'negate') sb.add(' '); | |
|
ahe
2012/08/02 13:39:39
if (send.selector.token.kind === KEYWORD_TOKEN) ..
Anton Muhin
2012/08/06 09:20:09
Done.
| |
| 110 } | 112 } |
| 111 visit(send.selector); | 113 visit(send.selector); |
| 112 } else { | 114 } else { |
| 113 visit(node.name); | 115 visit(node.name); |
| 114 } | 116 } |
| 115 visit(node.parameters); | 117 visit(node.parameters); |
| 116 visit(node.initializers); | 118 visit(node.initializers); |
| 117 visit(node.body); | 119 visit(node.body); |
| 118 } | 120 } |
| 119 | 121 |
| 120 visitIdentifier(Identifier node) { | 122 visitIdentifier(Identifier node) { |
| 121 String newName = renamer.renameIdentifier(node); | 123 String newName = renamer.renameIdentifier(node); |
| 122 if (newName == null) { | 124 if (newName === null) { |
| 123 add(node.token.value); | 125 add(node.token.value); |
| 124 } else { | 126 } else { |
| 125 sb.add(newName); | 127 sb.add(newName); |
| 126 } | 128 } |
| 127 } | 129 } |
| 128 | 130 |
| 129 visitIf(If node) { | 131 visitIf(If node) { |
| 130 add(node.ifToken.value); | 132 add(node.ifToken.value); |
| 131 visit(node.condition); | 133 visit(node.condition); |
| 132 visit(node.thenPart); | 134 visit(node.thenPart); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 sb.add(' '); | 515 sb.add(' '); |
| 514 } | 516 } |
| 515 visit(node.name); | 517 visit(node.name); |
| 516 if (node.typeParameters !== null) { | 518 if (node.typeParameters !== null) { |
| 517 visit(node.typeParameters); | 519 visit(node.typeParameters); |
| 518 } | 520 } |
| 519 visit(node.formals); | 521 visit(node.formals); |
| 520 add(node.endToken.value); | 522 add(node.endToken.value); |
| 521 } | 523 } |
| 522 } | 524 } |
| OLD | NEW |