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

Side by Side Diff: frog/library.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | frog/member_set.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 LibraryImport { 5 class LibraryImport {
6 final String prefix; 6 final String prefix;
7 final Library library; 7 final Library library;
8 final SourceSpan span; 8 final SourceSpan span;
9 LibraryImport(this.library, [this.prefix, this.span]); 9 LibraryImport(this.library, [this.prefix, this.span]);
10 } 10 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 world._addTopName(member); 95 world._addTopName(member);
96 } 96 }
97 } else { 97 } else {
98 var members = _privateMembers[member.name]; 98 var members = _privateMembers[member.name];
99 if (members == null) { 99 if (members == null) {
100 members = new MemberSet(member, isVar: true); 100 members = new MemberSet(member, isVar: true);
101 _privateMembers[member.name] = members; 101 _privateMembers[member.name] = members;
102 } else { 102 } else {
103 members.add(member); 103 members.add(member);
104 } 104 }
105 _makePrivateMembersUnique(member, members);
106 } 105 }
107 } else { 106 } else {
108 world._addMember(member); 107 world._addMember(member);
109 } 108 }
110 } 109 }
111 110
112 void _makePrivateMembersUnique(Member member, MemberSet members) {
113 // If the JS name in the member set is already unique, we simply
114 // copy the name to the new member.
115 if (members.jsnameUnique) {
116 member._jsname = members.jsname;
117 return;
118 }
119
120 // Run through the other libraries in the world and check if any
121 // of them has a clashing private member. If so, we rewrite this
122 // one and all other members in the set.
123 String name = members.name;
124 for (var lib in world.libraries.getValues()) {
125 if (lib !== this && lib._privateMembers.containsKey(name)) {
126 String uniqueName = '_${this.jsname}${members.jsname}';
127 members.jsname = uniqueName;
128 members.jsnameUnique = true;
129 members.members.forEach((each) { each._jsname = uniqueName; });
130 assert(member.jsname == members.jsname);
131 return;
132 }
133 }
134 }
135
136 // TODO(jimhug): Cache and share the types as interfaces! 111 // TODO(jimhug): Cache and share the types as interfaces!
137 Type getOrAddFunctionType(Element enclosingElement, String name, 112 Type getOrAddFunctionType(Element enclosingElement, String name,
138 FunctionDefinition func, MethodData data) { 113 FunctionDefinition func, MethodData data) {
139 // TODO(jimhug): This is redundant now that FunctionDef has type params. 114 // TODO(jimhug): This is redundant now that FunctionDef has type params.
140 final def = new FunctionTypeDefinition(func, null, func.span); 115 final def = new FunctionTypeDefinition(func, null, func.span);
141 final type = new DefinedType(name, this, def, false); 116 final type = new DefinedType(name, this, def, false);
142 type.addMethod(':call', func); 117 type.addMethod(':call', func);
143 var m = type.members[':call']; 118 var m = type.members[':call'];
144 m.enclosingElement = enclosingElement; 119 m.enclosingElement = enclosingElement;
145 m.resolve(); 120 m.resolve();
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 503
529 void visitFunctionDefinition(FunctionDefinition node) { 504 void visitFunctionDefinition(FunctionDefinition node) {
530 currentType.addMethod(node.name.name, node); 505 currentType.addMethod(node.name.name, node);
531 } 506 }
532 507
533 void visitFunctionTypeDefinition(FunctionTypeDefinition node) { 508 void visitFunctionTypeDefinition(FunctionTypeDefinition node) {
534 var type = library.addType(node.func.name.name, node, false); 509 var type = library.addType(node.func.name.name, node, false);
535 type.addMethod(':call', node.func); 510 type.addMethod(':call', node.func);
536 } 511 }
537 } 512 }
OLDNEW
« no previous file with comments | « no previous file | frog/member_set.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698