Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 8 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
| 9 */ | 9 */ |
| 10 class Namer { | 10 class Namer { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 // TODO(floitsch): mangle, while preserving uniqueness. | 158 // TODO(floitsch): mangle, while preserving uniqueness. |
| 159 StringBuffer buffer = new StringBuffer(); | 159 StringBuffer buffer = new StringBuffer(); |
| 160 List<SourceString> names = selector.getOrderedNamedArguments(); | 160 List<SourceString> names = selector.getOrderedNamedArguments(); |
| 161 for (SourceString argumentName in names) { | 161 for (SourceString argumentName in names) { |
| 162 buffer.add(r'$'); | 162 buffer.add(r'$'); |
| 163 argumentName.printOn(buffer); | 163 argumentName.printOn(buffer); |
| 164 } | 164 } |
| 165 return '${privateName(lib, name)}\$${selector.argumentCount}$buffer'; | 165 return '${privateName(lib, name)}\$${selector.argumentCount}$buffer'; |
| 166 } | 166 } |
| 167 | 167 |
| 168 /** | |
| 169 * Returns the internal name used for an invocation mirror of this selector. | |
| 170 */ | |
| 171 String invocationMirrorInternalName(Selector selector) { | |
| 172 String nameString = selector.name.slowToString(); | |
|
ngeoffray
2012/12/06 22:51:54
Remove this line.
Johnni Winther
2012/12/11 14:23:04
Removed in https://codereview.chromium.org/1141528
| |
| 173 if (selector.isGetter()) { | |
| 174 return getterName(selector.library, selector.name); | |
| 175 } else if (selector.isSetter()) { | |
| 176 return setterName(selector.library, selector.name); | |
| 177 } else { | |
| 178 return instanceMethodInvocationName( | |
| 179 selector.library, selector.name, selector); | |
| 180 } | |
| 181 } | |
| 182 | |
| 168 String instanceFieldName(LibraryElement libraryElement, SourceString name) { | 183 String instanceFieldName(LibraryElement libraryElement, SourceString name) { |
| 169 String proposedName = privateName(libraryElement, name); | 184 String proposedName = privateName(libraryElement, name); |
| 170 return safeName(proposedName); | 185 return safeName(proposedName); |
| 171 } | 186 } |
| 172 | 187 |
| 173 String shadowedFieldName(Element fieldElement) { | 188 String shadowedFieldName(Element fieldElement) { |
| 174 ClassElement cls = fieldElement.getEnclosingClass(); | 189 ClassElement cls = fieldElement.getEnclosingClass(); |
| 175 LibraryElement libraryElement = fieldElement.getLibrary(); | 190 LibraryElement libraryElement = fieldElement.getLibrary(); |
| 176 String libName = getName(libraryElement); | 191 String libName = getName(libraryElement); |
| 177 String clsName = getName(cls); | 192 String clsName = getName(cls); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 } | 372 } |
| 358 | 373 |
| 359 String safeName(String name) { | 374 String safeName(String name) { |
| 360 if (jsReserved.contains(name) || name.startsWith('\$')) { | 375 if (jsReserved.contains(name) || name.startsWith('\$')) { |
| 361 name = "\$$name"; | 376 name = "\$$name"; |
| 362 assert(!jsReserved.contains(name)); | 377 assert(!jsReserved.contains(name)); |
| 363 } | 378 } |
| 364 return name; | 379 return name; |
| 365 } | 380 } |
| 366 } | 381 } |
| OLD | NEW |