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

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

Issue 15959017: Fix issue with dart2dart translation of parameters (collision risk). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart b/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
index 5ad2230e0e0a6eea382f4bde4fafa0191718864e..a936b7d5a5c4f777b72edd7e930db9ed8f5e85c1 100644
--- a/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
+++ b/sdk/lib/_internal/compiler/implementation/dart_backend/renamer.dart
@@ -167,20 +167,24 @@ void renamePlaceholders(
// A function that takes original identifier name and generates a new unique
// identifier.
Function generateUniqueName;
+
+ Set<String> allNamedParameterIdentifiers = new Set<String>();
+ for (var functionScope in placeholderCollector.functionScopes.values) {
+ allNamedParameterIdentifiers.addAll(functionScope.parameterIdentifiers);
+ }
+
if (compiler.enableMinification) {
MinifyingGenerator generator = new MinifyingGenerator();
Set<String> forbiddenIdentifiers = new Set<String>.from(['main']);
forbiddenIdentifiers.addAll(Keyword.keywords.keys);
forbiddenIdentifiers.addAll(fixedMemberNames);
generateUniqueName = (_) =>
- generator.generate(forbiddenIdentifiers.contains);
+ generator.generate((name) =>
+ forbiddenIdentifiers.contains(name)
+ || allNamedParameterIdentifiers.contains(name));
rename = makeRenamer(generateUniqueName);
renameElement = makeElementRenamer(rename, generateUniqueName);
- Set<String> allParameterIdentifiers = new Set<String>();
- for (var functionScope in placeholderCollector.functionScopes.values) {
- allParameterIdentifiers.addAll(functionScope.parameterIdentifiers);
- }
// Build a sorted (by usage) list of local nodes that will be renamed to
// the same identifier. So the top-used local variables in all functions
// will be renamed first and will all share the same new identifier.
@@ -209,10 +213,7 @@ void renamePlaceholders(
renameElement(elementRenamable.element);
String memberRenamer(MemberRenamable memberRenamable) =>
generator.generate(forbiddenIdentifiers.contains);
- String localRenamer(LocalRenamable localRenamable) =>
- generator.generate((name) =>
- allParameterIdentifiers.contains(name)
- || forbiddenIdentifiers.contains(name));
+ Function localRenamer = generateUniqueName;
Anton Muhin 2013/05/31 08:50:23 maybe drop this local altogether?
kasperl 2013/05/31 08:51:57 I think I'll keep it for consistency with the othe
List<Renamable> renamables = [];
placeholderCollector.elementNodes.forEach(
(Element element, Set<Node> nodes) {
@@ -239,7 +240,9 @@ void renamePlaceholders(
usedTopLevelOrMemberIdentifiers.addAll(fixedMemberNames);
generateUniqueName = (originalName) {
String newName = conservativeGenerator(
- originalName, usedTopLevelOrMemberIdentifiers.contains);
+ originalName, (name) =>
+ usedTopLevelOrMemberIdentifiers.contains(name)
Anton Muhin 2013/05/31 08:50:23 why this change, only stylistic or am i missing so
kasperl 2013/05/31 08:51:57 I'm adding the allNamedParameterIdentifiers check
+ || allNamedParameterIdentifiers.contains(name));
usedTopLevelOrMemberIdentifiers.add(newName);
return newName;
};
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_backend/placeholder_collector.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698