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

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

Issue 266913017: Convert property methods into getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 6 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 unified diff | Download patch | Annotate | Revision Log
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 part of dart_backend; 5 part of dart_backend;
6 6
7 Comparator get _compareNodes => 7 Comparator get _compareNodes =>
8 compareBy((n) => n.getBeginToken().charOffset); 8 compareBy((n) => n.getBeginToken().charOffset);
9 9
10 typedef String _Renamer(Renamable renamable); 10 typedef String _Renamer(Renamable renamable);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 result.write(','); 99 result.write(',');
100 result.write(renameType(link.head, renameElement)); 100 result.write(renameType(link.head, renameElement));
101 } 101 }
102 result.write('>'); 102 result.write('>');
103 } 103 }
104 return result.toString(); 104 return result.toString();
105 } 105 }
106 106
107 String renameConstructor(Element element, ConstructorPlaceholder placeholder, 107 String renameConstructor(Element element, ConstructorPlaceholder placeholder,
108 Function renameString, Function renameElement) { 108 Function renameString, Function renameElement) {
109 assert(element.isConstructor()); 109 assert(element.isConstructor);
110 StringBuffer result = new StringBuffer(); 110 StringBuffer result = new StringBuffer();
111 String name = element.name; 111 String name = element.name;
112 if (element.name != '') { 112 if (element.name != '') {
113 // Named constructor or factory. Is there a more reliable way to check 113 // Named constructor or factory. Is there a more reliable way to check
114 // this case? 114 // this case?
115 if (!placeholder.isRedirectingCall) { 115 if (!placeholder.isRedirectingCall) {
116 result.write(renameType(placeholder.type, renameElement)); 116 result.write(renameType(placeholder.type, renameElement));
117 result.write('.'); 117 result.write('.');
118 } 118 }
119 if (!element.getLibrary().isPlatformLibrary) { 119 if (!element.library.isPlatformLibrary) {
120 name = renameString(element.getLibrary(), name); 120 name = renameString(element.library, name);
121 } 121 }
122 result.write(name); 122 result.write(name);
123 } else { 123 } else {
124 assert(!placeholder.isRedirectingCall); 124 assert(!placeholder.isRedirectingCall);
125 result.write(renameType(placeholder.type, renameElement)); 125 result.write(renameType(placeholder.type, renameElement));
126 } 126 }
127 return result.toString(); 127 return result.toString();
128 } 128 }
129 129
130 Function makeElementRenamer(rename, generateUniqueName) => (element) { 130 Function makeElementRenamer(rename, generateUniqueName) => (element) {
131 assert(Elements.isErroneousElement(element) || 131 assert(Elements.isErroneousElement(element) ||
132 Elements.isStaticOrTopLevel(element) || 132 Elements.isStaticOrTopLevel(element) ||
133 element is TypeVariableElement); 133 element is TypeVariableElement);
134 // TODO(smok): We may want to reuse class static field and method names. 134 // TODO(smok): We may want to reuse class static field and method names.
135 String originalName = element.name; 135 String originalName = element.name;
136 LibraryElement library = element.getLibrary(); 136 LibraryElement library = element.library;
137 if (identical(element.getLibrary(), compiler.coreLibrary)) { 137 if (identical(element.library, compiler.coreLibrary)) {
138 return originalName; 138 return originalName;
139 } 139 }
140 if (library.isPlatformLibrary) { 140 if (library.isPlatformLibrary) {
141 assert(element.isTopLevel()); 141 assert(element.isTopLevel);
142 if (reexportingLibraries.containsKey(element)) { 142 if (reexportingLibraries.containsKey(element)) {
143 library = reexportingLibraries[element]; 143 library = reexportingLibraries[element];
144 } 144 }
145 if (!library.isInternalLibrary) { 145 if (!library.isInternalLibrary) {
146 final prefix = 146 final prefix =
147 imports.putIfAbsent(library, () => generateUniqueName('p')); 147 imports.putIfAbsent(library, () => generateUniqueName('p'));
148 return '$prefix.$originalName'; 148 return '$prefix.$originalName';
149 } 149 }
150 } 150 }
151 151
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 sortedForEach(placeholderCollector.elementNodes, 251 sortedForEach(placeholderCollector.elementNodes,
252 (Element element, Set<Node> nodes) { 252 (Element element, Set<Node> nodes) {
253 renameNodes(nodes, (_) => renameElement(element)); 253 renameNodes(nodes, (_) => renameElement(element));
254 }); 254 });
255 255
256 // Rename locals. 256 // Rename locals.
257 sortedForEach(placeholderCollector.functionScopes, 257 sortedForEach(placeholderCollector.functionScopes,
258 (functionElement, functionScope) { 258 (functionElement, functionScope) {
259 Set<LocalPlaceholder> placeholders = functionScope.localPlaceholders; 259 Set<LocalPlaceholder> placeholders = functionScope.localPlaceholders;
260 Set<String> memberIdentifiers = new Set<String>(); 260 Set<String> memberIdentifiers = new Set<String>();
261 if (functionElement.getEnclosingClass() != null) { 261 if (functionElement.enclosingClass != null) {
262 functionElement.getEnclosingClass().forEachMember( 262 functionElement.enclosingClass.forEachMember(
263 (enclosingClass, member) { 263 (enclosingClass, member) {
264 memberIdentifiers.add(member.name); 264 memberIdentifiers.add(member.name);
265 }); 265 });
266 } 266 }
267 Set<String> usedLocalIdentifiers = new Set<String>(); 267 Set<String> usedLocalIdentifiers = new Set<String>();
268 for (LocalPlaceholder placeholder in placeholders) { 268 for (LocalPlaceholder placeholder in placeholders) {
269 String nextId = 269 String nextId =
270 conservativeGenerator(placeholder.identifier, (name) => 270 conservativeGenerator(placeholder.identifier, (name) =>
271 functionScope.parameterIdentifiers.contains(name) 271 functionScope.parameterIdentifiers.contains(name)
272 || usedTopLevelOrMemberIdentifiers.contains(name) 272 || usedTopLevelOrMemberIdentifiers.contains(name)
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 MinifyingGenerator(); 354 MinifyingGenerator();
355 355
356 String generate(bool isForbidden(String name)) { 356 String generate(bool isForbidden(String name)) {
357 String result; 357 String result;
358 do { 358 do {
359 result = generateMiniId(index++); 359 result = generateMiniId(index++);
360 } while (isForbidden(result)); 360 } while (isForbidden(result));
361 return result; 361 return result;
362 } 362 }
363 } 363 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698