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 part of dart_backend; | 5 part of dart_backend; |
6 | 6 |
7 class LocalPlaceholder { | 7 class LocalPlaceholder { |
8 final String identifier; | 8 final String identifier; |
9 final Set<Node> nodes; | 9 final Set<Node> nodes; |
10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); | 10 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 void makeElementPlaceholder(Node node, Element element) { | 338 void makeElementPlaceholder(Node node, Element element) { |
339 assert(node != null); | 339 assert(node != null); |
340 assert(element != null); | 340 assert(element != null); |
341 LibraryElement library = element.library; | 341 LibraryElement library = element.library; |
342 if (identical(element, mainFunction)) return; | 342 if (identical(element, mainFunction)) return; |
343 if (library.isDartCore) return; | 343 if (library.isDartCore) return; |
344 | 344 |
345 if (library.isPlatformLibrary && !element.isTopLevel) { | 345 if (library.isPlatformLibrary && !element.isTopLevel) { |
346 return; | 346 return; |
347 } | 347 } |
| 348 |
| 349 ClassElement cls = element.enclosingClass; |
| 350 if (cls != null && cls.isEnumClass) { |
| 351 // Enums and enum values cannot be changed, since the semantics of |
| 352 // `toString` is defined by the names of the declarations. |
| 353 return; |
| 354 } |
| 355 |
348 if (element.isGetter || element.isSetter) { | 356 if (element.isGetter || element.isSetter) { |
349 element = (element as FunctionElement).abstractField; | 357 element = (element as FunctionElement).abstractField; |
350 } | 358 } |
351 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node); | 359 elementNodes.putIfAbsent(element, () => new Set<Node>()).add(node); |
352 } | 360 } |
353 | 361 |
354 /// Marks [node] to be renamed per-library if it names an instance member | 362 /// Marks [node] to be renamed per-library if it names an instance member |
355 /// and has a private name. | 363 /// and has a private name. |
356 void tryMakePrivateIdentifier(Node node, Element element) { | 364 void tryMakePrivateIdentifier(Node node, Element element) { |
357 if (node is Identifier && | 365 if (node is Identifier && |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 702 |
695 visitBlock(Block node) { | 703 visitBlock(Block node) { |
696 for (Node statement in node.statements.nodes) { | 704 for (Node statement in node.statements.nodes) { |
697 if (statement is VariableDefinitions) { | 705 if (statement is VariableDefinitions) { |
698 makeVarDeclarationTypePlaceholder(statement); | 706 makeVarDeclarationTypePlaceholder(statement); |
699 } | 707 } |
700 } | 708 } |
701 node.visitChildren(this); | 709 node.visitChildren(this); |
702 } | 710 } |
703 } | 711 } |
OLD | NEW |