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 implements ClosureNamer { | 10 class Namer implements ClosureNamer { |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 } else if (Elements.isStaticOrTopLevel(element)) { | 576 } else if (Elements.isStaticOrTopLevel(element)) { |
| 577 if (element.isMember()) { | 577 if (element.isMember()) { |
| 578 ClassElement enclosingClass = element.getEnclosingClass(); | 578 ClassElement enclosingClass = element.getEnclosingClass(); |
| 579 name = "${enclosingClass.name.slowToString()}_" | 579 name = "${enclosingClass.name.slowToString()}_" |
| 580 "${element.name.slowToString()}"; | 580 "${element.name.slowToString()}"; |
| 581 } else { | 581 } else { |
| 582 name = element.name.slowToString().replaceAll('+', '_'); | 582 name = element.name.slowToString().replaceAll('+', '_'); |
| 583 } | 583 } |
| 584 } else if (element.isLibrary()) { | 584 } else if (element.isLibrary()) { |
| 585 LibraryElement library = element; | 585 LibraryElement library = element; |
| 586 name = library.getLibraryOrScriptName(); | 586 name = library.getLibraryName(); |
|
ahe
2013/10/10 11:47:53
This change doesn't seem correct, as this method m
| |
| 587 if (name.contains('.')) { | 587 if (name.contains('.')) { |
| 588 // For libraries that have a library tag, we use the last part | 588 // For libraries that have a library tag, we use the last part |
| 589 // of the fully qualified name as their base name. For all other | 589 // of the fully qualified name as their base name. For all other |
| 590 // libraries, we use the first part of their filename. | 590 // libraries, we use the first part of their filename. |
| 591 name = library.hasLibraryName() | 591 name = library.hasLibraryName() |
| 592 ? name.substring(name.lastIndexOf('.') + 1) | 592 ? name.substring(name.lastIndexOf('.') + 1) |
| 593 : name.substring(0, name.indexOf('.')); | 593 : name.substring(0, name.indexOf('.')); |
| 594 } | 594 } |
| 595 } else { | 595 } else { |
| 596 name = element.name.slowToString(); | 596 name = element.name.slowToString(); |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 String globalObjectFor(Element element) { | 834 String globalObjectFor(Element element) { |
| 835 if (isPropertyOfCurrentIsolate(element)) return CURRENT_ISOLATE; | 835 if (isPropertyOfCurrentIsolate(element)) return CURRENT_ISOLATE; |
| 836 LibraryElement library = element.getLibrary(); | 836 LibraryElement library = element.getLibrary(); |
| 837 if (library == compiler.interceptorsLibrary) return 'J'; | 837 if (library == compiler.interceptorsLibrary) return 'J'; |
| 838 if (library.isInternalLibrary) return 'H'; | 838 if (library.isInternalLibrary) return 'H'; |
| 839 if (library.isPlatformLibrary) { | 839 if (library.isPlatformLibrary) { |
| 840 if ('${library.canonicalUri}' == 'dart:html') return 'W'; | 840 if ('${library.canonicalUri}' == 'dart:html') return 'W'; |
| 841 return 'P'; | 841 return 'P'; |
| 842 } | 842 } |
| 843 return userGlobalObjects[ | 843 return userGlobalObjects[ |
| 844 library.getLibraryOrScriptName().hashCode % userGlobalObjects.length]; | 844 library.getLibraryName().hashCode % userGlobalObjects.length]; |
|
ahe
2013/10/10 11:47:53
I think we need to keep getLibraryOrScriptName. Ot
| |
| 845 } | 845 } |
| 846 | 846 |
| 847 jsAst.PropertyAccess elementAccess(Element element) { | 847 jsAst.PropertyAccess elementAccess(Element element) { |
| 848 String name = getNameX(element); | 848 String name = getNameX(element); |
| 849 return new jsAst.PropertyAccess.field( | 849 return new jsAst.PropertyAccess.field( |
| 850 new jsAst.VariableUse(globalObjectFor(element)), | 850 new jsAst.VariableUse(globalObjectFor(element)), |
| 851 name); | 851 name); |
| 852 } | 852 } |
| 853 | 853 |
| 854 String getLazyInitializerName(Element element) { | 854 String getLazyInitializerName(Element element) { |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1379 if (!first) { | 1379 if (!first) { |
| 1380 sb.write('_'); | 1380 sb.write('_'); |
| 1381 } | 1381 } |
| 1382 sb.write('_'); | 1382 sb.write('_'); |
| 1383 visit(link.head); | 1383 visit(link.head); |
| 1384 first = true; | 1384 first = true; |
| 1385 } | 1385 } |
| 1386 } | 1386 } |
| 1387 } | 1387 } |
| 1388 } | 1388 } |
| OLD | NEW |