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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } else { | 113 } else { |
114 StringBuffer suffix = new StringBuffer(); | 114 StringBuffer suffix = new StringBuffer(); |
115 signature.forEachOptionalParameter((Element element) { | 115 signature.forEachOptionalParameter((Element element) { |
116 String jsName = JsNames.getValid(element.name.slowToString()); | 116 String jsName = JsNames.getValid(element.name.slowToString()); |
117 suffix.add('\$$jsName'); | 117 suffix.add('\$$jsName'); |
118 }); | 118 }); |
119 return '$methodName$suffix'; | 119 return '$methodName$suffix'; |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 String instanceMethodNameByArity(SourceString name, int arity) { | 123 String publicInstanceMethodNameByArity(SourceString name, int arity) { |
| 124 assert(!name.isPrivate()); |
124 return '${name.slowToString()}\$$arity'; | 125 return '${name.slowToString()}\$$arity'; |
125 } | 126 } |
126 | 127 |
127 String instanceMethodInvocationName(LibraryElement lib, SourceString name, | 128 String instanceMethodInvocationName(LibraryElement lib, SourceString name, |
128 Selector selector) { | 129 Selector selector) { |
129 // TODO(floitsch): mangle, while preserving uniqueness. | 130 // TODO(floitsch): mangle, while preserving uniqueness. |
130 StringBuffer buffer = new StringBuffer(); | 131 StringBuffer buffer = new StringBuffer(); |
131 List<SourceString> names = selector.getOrderedNamedArguments(); | 132 List<SourceString> names = selector.getOrderedNamedArguments(); |
132 for (SourceString argumentName in names) { | 133 for (SourceString argumentName in names) { |
133 buffer.add(@'$'); | 134 buffer.add(@'$'); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 303 } |
303 | 304 |
304 String safeName(String name) { | 305 String safeName(String name) { |
305 if (jsReserved.contains(name) || name.startsWith('\$')) { | 306 if (jsReserved.contains(name) || name.startsWith('\$')) { |
306 name = "\$$name"; | 307 name = "\$$name"; |
307 assert(!jsReserved.contains(name)); | 308 assert(!jsReserved.contains(name)); |
308 } | 309 } |
309 return name; | 310 return name; |
310 } | 311 } |
311 } | 312 } |
OLD | NEW |