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

Unified Diff: frog/world.dart

Issue 9656003: Fix for issue with incorrectly renamed private names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: x Created 8 years, 9 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 | « frog/minfrog ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/world.dart
diff --git a/frog/world.dart b/frog/world.dart
index 67e7e191069c2c9ee73a9c77701e935e4209d314..bb77aa16aee0bd957c1b641aaa49a12dcd0311a3 100644
--- a/frog/world.dart
+++ b/frog/world.dart
@@ -410,6 +410,7 @@ class World {
void runCompilationPhases() {
final lib = withTiming('first pass', () => processDartScript());
withTiming('resolve top level', resolveAll);
+ withTiming('privatization', () { makePrivateMembersUnique(lib); });
if (experimentalAwaitPhase != null) {
withTiming('await translation', experimentalAwaitPhase);
}
@@ -488,6 +489,36 @@ class World {
}
}
+ makePrivateMembersUnique(Library rootLib) {
+ var usedNames = new Set<String>();
+ process(lib) {
+ for (var name in lib._privateMembers.getKeys()) {
+ if (usedNames.contains(name)) {
+ var members = lib._privateMembers[name];
+ String uniqueName = '_${lib.jsname}${members.jsname}';
+ members.jsname = uniqueName;
+ for (var member in members.members) {
+ member._jsname = uniqueName;
+ }
+ } else {
+ usedNames.add(name);
+ }
+ }
+ }
+
+ // Visit libraries in pre-order of imports.
+ var visited = new Set<Library>();
+ visit(lib) {
+ if (visited.contains(lib)) return;
+ visited.add(lib);
+ process(lib);
+ for (var import in lib.imports) {
+ visit(import.library);
+ }
+ }
+ visit(rootLib);
+ }
+
findMainMethod(Library lib) {
var main = lib.lookup('main', lib.span);
if (main == null) {
« no previous file with comments | « frog/minfrog ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698