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

Unified Diff: lib/compiler/implementation/dart_backend/renamer.dart

Issue 10834416: Rename elements after sorting. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/dart_backend/backend.dart ('k') | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/dart_backend/renamer.dart
diff --git a/lib/compiler/implementation/dart_backend/renamer.dart b/lib/compiler/implementation/dart_backend/renamer.dart
index 6cb47f76933ce788de7d7a7ba4b5556e60b75b84..eb4f24dac54ac3909d5dd7e41fca9358a7f8911e 100644
--- a/lib/compiler/implementation/dart_backend/renamer.dart
+++ b/lib/compiler/implementation/dart_backend/renamer.dart
@@ -50,35 +50,38 @@ void renamePlaceholders(
() => generateUniqueName(originalName));
}
- placeholderCollector.nullNodes.forEach((Node node) {
+ for (Node node in placeholderCollector.nullNodes) {
renames[node] = '';
- });
- placeholderCollector.unresolvedNodes.forEach((Node node) {
+ }
+ for (Node node in placeholderCollector.unresolvedNodes) {
Roman 2012/08/21 07:59:46 Should we use sortedForEach here too? Otherwise it
Anton Muhin 2012/08/21 10:15:26 Okay. I'll implement somewhat suboptimal solution
renames[node] = generateUniqueName('Unresolved');
+ }
+
+ sortedForEach(mapping, f) {
Roman 2012/08/21 07:59:46 Great method, but can you please make it more read
Anton Muhin 2012/08/21 10:15:26 Done.
+ for (final e in sortElements(mapping.getKeys())) f(e, mapping[e]);
+ }
+
+ sortedForEach(placeholderCollector.elementNodes, (element, nodes) {
+ String newName = renameElement(element);
+ for (Node node in nodes) {
+ renames[node] = newName;
+ }
});
- placeholderCollector.elementNodes.forEach(
- (Element element, Set<Node> nodes) {
- String renamedElement = renameElement(element);
- nodes.forEach((Node node) {
- renames[node] = renamedElement;
- });
+ sortedForEach(placeholderCollector.localPlaceholders,
+ (element, placeholders) {
+ // TODO(smok): Check for conflicts with class fields and take usages
+ // into account.
+ for (LocalPlaceholder placeholder in placeholders) {
+ for (Node node in placeholder.nodes) {
+ renames[node] = placeholder.identifier;
+ }
+ }
});
- placeholderCollector.localPlaceholders.forEach(
- (FunctionElement element, Set<LocalPlaceholder> localPlaceholders) {
- // TODO(smok): Check for conflicts with class fields and take usages
- // into account.
- localPlaceholders.forEach((LocalPlaceholder placeholder) {
- placeholder.nodes.forEach((Node node) {
- renames[node] = placeholder.identifier;
- });
- });
- });
- placeholderCollector.privateNodes.forEach(
- (LibraryElement library, Set<Identifier> nodes) {
- nodes.forEach((Identifier node) {
- renames[node] =
- renamePrivateIdentifier(library, node.source.slowToString());
- });
+ sortedForEach(placeholderCollector.privateNodes, (library, nodes) {
+ for (Node node in nodes) {
+ renames[node] =
+ renamePrivateIdentifier(library, node.source.slowToString());
+ }
});
}
« no previous file with comments | « lib/compiler/implementation/dart_backend/backend.dart ('k') | tests/compiler/dart2js/unparser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698