| 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 name = element.name.slowToString(); | 309 name = element.name.slowToString(); |
| 310 } | 310 } |
| 311 } else if (element.isLibrary()) { | 311 } else if (element.isLibrary()) { |
| 312 name = LIBRARY_PREFIX; | 312 name = LIBRARY_PREFIX; |
| 313 } else { | 313 } else { |
| 314 name = element.name.slowToString(); | 314 name = element.name.slowToString(); |
| 315 } | 315 } |
| 316 return name; | 316 return name; |
| 317 } | 317 } |
| 318 | 318 |
| 319 String getSpecializedName(Element element, Collection<ClassElement> classes) { |
| 320 StringBuffer buffer = new StringBuffer(getName(element)); |
| 321 for (ClassElement cls in classes) { |
| 322 buffer.add(getName(cls)); |
| 323 } |
| 324 return buffer.toString(); |
| 325 } |
| 326 |
| 319 String getBailoutName(Element element) { | 327 String getBailoutName(Element element) { |
| 320 String name = bailoutNames[element]; | 328 String name = bailoutNames[element]; |
| 321 if (name != null) return name; | 329 if (name != null) return name; |
| 322 bool global = !element.isInstanceMember(); | 330 bool global = !element.isInstanceMember(); |
| 323 String unminifiedName = '${getName(element)}\$bailout'; | 331 String unminifiedName = '${getName(element)}\$bailout'; |
| 324 if (global) { | 332 if (global) { |
| 325 name = getMappedGlobalName(unminifiedName); | 333 name = getMappedGlobalName(unminifiedName); |
| 326 } else { | 334 } else { |
| 327 name = unminifiedName; | 335 name = unminifiedName; |
| 328 int i = 0; | 336 int i = 0; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 } | 439 } |
| 432 | 440 |
| 433 String safeName(String name) { | 441 String safeName(String name) { |
| 434 if (jsReserved.contains(name) || name.startsWith('\$')) { | 442 if (jsReserved.contains(name) || name.startsWith('\$')) { |
| 435 name = "\$$name"; | 443 name = "\$$name"; |
| 436 assert(!jsReserved.contains(name)); | 444 assert(!jsReserved.contains(name)); |
| 437 } | 445 } |
| 438 return name; | 446 return name; |
| 439 } | 447 } |
| 440 } | 448 } |
| OLD | NEW |