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 /** | 5 /** |
| 6 * Assigns JavaScript identifiers to Dart variables, class-names and members. | 6 * Assigns JavaScript identifiers to Dart variables, class-names and members. |
| 7 */ | 7 */ |
| 8 class Namer { | 8 class Namer { |
| 9 final Compiler compiler; | 9 final Compiler compiler; |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 StringBuffer buffer = new StringBuffer(); | 56 StringBuffer buffer = new StringBuffer(); |
| 57 List<SourceString> names = selector.getOrderedNamedArguments(); | 57 List<SourceString> names = selector.getOrderedNamedArguments(); |
| 58 for (SourceString argumentName in names) { | 58 for (SourceString argumentName in names) { |
| 59 buffer.add(@'$'); | 59 buffer.add(@'$'); |
| 60 argumentName.printOn(buffer); | 60 argumentName.printOn(buffer); |
| 61 } | 61 } |
| 62 return '${privateName(lib, name)}\$${selector.argumentCount}$buffer'; | 62 return '${privateName(lib, name)}\$${selector.argumentCount}$buffer'; |
| 63 } | 63 } |
| 64 | 64 |
| 65 String instanceFieldName(LibraryElement lib, SourceString name) { | 65 String instanceFieldName(LibraryElement lib, SourceString name) { |
| 66 return privateName(lib, name); | 66 String proposedName = privateName(lib, name); |
| 67 if (jsReserved.contains(proposedName)) { | |
| 68 return '$proposedName\$'; | |
|
ngeoffray
2012/04/23 18:38:15
This code very much looks like JsName.getValid, sh
floitsch
2012/04/25 08:42:24
Thanks. Addressed in CL 10223002.
| |
| 69 } | |
| 70 return proposedName; | |
| 67 } | 71 } |
| 68 | 72 |
| 69 String setterName(LibraryElement lib, SourceString name) { | 73 String setterName(LibraryElement lib, SourceString name) { |
| 70 return 'set\$${privateName(lib, name)}'; | 74 return 'set\$${privateName(lib, name)}'; |
| 71 } | 75 } |
| 72 | 76 |
| 73 String getterName(LibraryElement lib, SourceString name) { | 77 String getterName(LibraryElement lib, SourceString name) { |
| 74 return 'get\$${privateName(lib, name)}'; | 78 return 'get\$${privateName(lib, name)}'; |
| 75 } | 79 } |
| 76 | 80 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 } | 209 } |
| 206 | 210 |
| 207 String safeName(String name) { | 211 String safeName(String name) { |
| 208 if (jsReserved.contains(name) || name.startsWith('\$')) { | 212 if (jsReserved.contains(name) || name.startsWith('\$')) { |
| 209 name = "\$$name"; | 213 name = "\$$name"; |
| 210 assert(!jsReserved.contains(name)); | 214 assert(!jsReserved.contains(name)); |
| 211 } | 215 } |
| 212 return name; | 216 return name; |
| 213 } | 217 } |
| 214 } | 218 } |
| OLD | NEW |