Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: lib/compiler/implementation/tree/unparser.dart

Issue 10383311: Support proper unparse of is and is!. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 final bool printDebugInfo; 7 final bool printDebugInfo;
8 8
9 Unparser([this.printDebugInfo = false]); 9 Unparser([this.printDebugInfo = false]);
10 10
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 visit(node.expression); 177 visit(node.expression);
178 } 178 }
179 if (node.endToken !== null) add(node.endToken.value); 179 if (node.endToken !== null) add(node.endToken.value);
180 } 180 }
181 181
182 182
183 unparseSendPart(Send node) { 183 unparseSendPart(Send node) {
184 if (node.isPrefix) { 184 if (node.isPrefix) {
185 visit(node.selector); 185 visit(node.selector);
186 } 186 }
187 if (node.receiver !== null) { 187 if (node.receiver !== null) {
ahe 2012/05/24 09:30:52 How about this: Operator op = node.selector.a
Anton Muhin 2012/05/24 14:15:12 Done with following changes: 1) == 'is' instead o
188 visit(node.receiver); 188 visit(node.receiver);
189 if (node.selector is !Operator) sb.add('.'); 189 if (node.selector is !Operator) sb.add('.');
190 } 190 }
191 if (!node.isPrefix) { 191 if (!node.isPrefix) {
192 visit(node.selector); 192 visit(node.selector);
193 } 193 }
194 } 194 }
195 195
196 visitSend(Send node) { 196 visitSend(Send node) {
197 // Special case. Simple expr is T is represented as Send(expr, 'is', T),
Anton Muhin 2012/05/23 19:41:11 this is rather ugly. I try to emit expr is! Type
ahe 2012/05/24 09:30:52 This is the result of an allergic reaction to http
ahe 2012/05/24 09:30:52 Extra space after period.
ahe 2012/05/24 09:30:52 I suggest that you put code snippets in [:...:], f
Anton Muhin 2012/05/24 14:15:12 I see, still prefixing a type with negation looks
Anton Muhin 2012/05/24 14:15:12 Now obsolete. So you don't use two spaces after p
Anton Muhin 2012/05/24 14:15:12 Now obsolete, but will do next time. On 2012/05/2
198 // while expr is! T is represented as Send(expr, 'is', Send.prefix('!', T)).
199 if (node.isOperator && node.selector.token.value.stringValue == 'is') {
200 visit(node.receiver);
201 sb.add(' is');
202 bool notForm = node.arguments.head is Send;
203 if (notForm) sb.add('!');
204 sb.add(' ');
205 if (notForm) {
206 visit(node.arguments.head.receiver);
207 } else {
208 visit(node.argumentsNode);
209 }
210
211 return;
212 }
213
197 unparseSendPart(node); 214 unparseSendPart(node);
198 visit(node.argumentsNode); 215 visit(node.argumentsNode);
199 } 216 }
200 217
201 visitSendSet(SendSet node) { 218 visitSendSet(SendSet node) {
202 unparseSendPart(node); 219 unparseSendPart(node);
203 add(node.assignmentOperator.token.value); 220 add(node.assignmentOperator.token.value);
204 visit(node.argumentsNode); 221 visit(node.argumentsNode);
205 } 222 }
206 223
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 sb.add(' '); 420 sb.add(' ');
404 } 421 }
405 visit(node.name); 422 visit(node.name);
406 if (node.typeParameters !== null) { 423 if (node.typeParameters !== null) {
407 visit(node.typeParameters); 424 visit(node.typeParameters);
408 } 425 }
409 visit(node.formals); 426 visit(node.formals);
410 add(node.endToken.value); 427 add(node.endToken.value);
411 } 428 }
412 } 429 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698