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

Side by Side Diff: lib/compiler/implementation/dart_backend/placeholder_collector.dart

Issue 10837343: Unify private names treatment. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
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 LocalPlaceholder implements Hashable { 5 class LocalPlaceholder implements Hashable {
6 final String identifier; 6 final String identifier;
7 final Set<Node> nodes; 7 final Set<Node> nodes;
8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); 8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>();
9 int hashCode() => identifier.hashCode(); 9 int hashCode() => identifier.hashCode();
10 String toString() => 10 String toString() =>
(...skipping 16 matching lines...) Expand all
27 } 27 }
28 } 28 }
29 29
30 visitDynamicSend(Send node) { 30 visitDynamicSend(Send node) {
31 tryRenamePrivateSelector(node); 31 tryRenamePrivateSelector(node);
32 } 32 }
33 33
34 visitGetterSend(Send node) { 34 visitGetterSend(Send node) {
35 final element = elements[node]; 35 final element = elements[node];
36 // element === null means dynamic property access. 36 // element === null means dynamic property access.
37 if (element === null || element.isInstanceMember()) { 37 if (element === null || element.isMember()) {
Roman 2012/08/21 07:34:17 We didn't rename static fields before, why should
38 tryRenamePrivateSelector(node); 38 tryRenamePrivateSelector(node);
39 return; 39 return;
40 } 40 }
41 // We don't want to rename non top-level element access 41 // We don't want to rename non top-level element access
42 // unless it's a local variable. 42 // unless it's a local variable.
43 if (element.isPrefix()) { 43 if (element.isPrefix()) {
44 // Node is prefix part in case of source 'lib.somesetter = 5;' 44 // Node is prefix part in case of source 'lib.somesetter = 5;'
45 collector.makeNullPlaceholder(node); 45 collector.makeNullPlaceholder(node);
46 return; 46 return;
47 } else if (!element.isTopLevel()) { 47 } else if (!element.isTopLevel()) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 visit(Node node) => (node === null) ? null : node.accept(this); 292 visit(Node node) => (node === null) ? null : node.accept(this);
293 293
294 visitNode(Node node) { node.visitChildren(this); } // We must go deeper. 294 visitNode(Node node) { node.visitChildren(this); } // We must go deeper.
295 295
296 visitSend(Send send) { 296 visitSend(Send send) {
297 new SendVisitor(this, treeElements).visitSend(send); 297 new SendVisitor(this, treeElements).visitSend(send);
298 send.visitChildren(this); 298 send.visitChildren(this);
299 } 299 }
300 300
301 visitSendSet(SendSet send) { 301 visitSendSet(SendSet send) {
302 if (send.selector is Identifier) {
303 tryMakePrivateIdentifier(send.selector.asIdentifier());
304 }
302 final element = treeElements[send]; 305 final element = treeElements[send];
303 if (element !== null) { 306 if (element !== null) {
304 if (element.isInstanceMember()) { 307 if (element.isTopLevel()) {
305 tryMakePrivateIdentifier(send.selector.asIdentifier());
306 } else if (element.isTopLevel()) {
307 assert(element is VariableElement || element.isSetter()); 308 assert(element is VariableElement || element.isSetter());
308 makeElementPlaceholder(send.selector, element); 309 makeElementPlaceholder(send.selector, element);
309 } else { 310 } else {
310 assert(send.selector is Identifier); 311 assert(send.selector is Identifier);
311 tryMakeLocalPlaceholder(element, send.selector); 312 tryMakeLocalPlaceholder(element, send.selector);
312 } 313 }
313 } 314 }
314 send.visitChildren(this); 315 send.visitChildren(this);
315 } 316 }
316 317
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 visit(node.defaultClause.typeArguments); 424 visit(node.defaultClause.typeArguments);
424 } 425 }
425 } 426 }
426 427
427 visitTypedef(Typedef node) { 428 visitTypedef(Typedef node) {
428 assert(currentElement is TypedefElement); 429 assert(currentElement is TypedefElement);
429 makeElementPlaceholder(node.name, currentElement); 430 makeElementPlaceholder(node.name, currentElement);
430 node.visitChildren(this); 431 node.visitChildren(this);
431 } 432 }
432 } 433 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698