| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 SourceString name = selector.name; | 357 SourceString name = selector.name; |
| 358 if (selector.kind == SelectorKind.OPERATOR | 358 if (selector.kind == SelectorKind.OPERATOR |
| 359 || selector.kind == SelectorKind.INDEX) { | 359 || selector.kind == SelectorKind.INDEX) { |
| 360 name = operatorNameToIdentifier(name); | 360 name = operatorNameToIdentifier(name); |
| 361 assert(name != selector.name); | 361 assert(name != selector.name); |
| 362 return getMappedOperatorName(name.slowToString()); | 362 return getMappedOperatorName(name.slowToString()); |
| 363 } | 363 } |
| 364 assert(name == operatorNameToIdentifier(name)); | 364 assert(name == operatorNameToIdentifier(name)); |
| 365 StringBuffer buffer = new StringBuffer(); | 365 StringBuffer buffer = new StringBuffer(); |
| 366 for (SourceString argumentName in selector.getOrderedNamedArguments()) { | 366 for (SourceString argumentName in selector.getOrderedNamedArguments()) { |
| 367 buffer.write(r'$'); | 367 buffer.write('\$${safeName(argumentName.slowToString())}'); |
| 368 argumentName.printOn(buffer); | |
| 369 } | 368 } |
| 370 String suffix = '\$${selector.argumentCount}$buffer'; | 369 String suffix = '\$${selector.argumentCount}$buffer'; |
| 371 // We don't mangle the closure invoking function name because it | 370 // We don't mangle the closure invoking function name because it |
| 372 // is generated by string concatenation in applyFunction from | 371 // is generated by string concatenation in applyFunction from |
| 373 // js_helper.dart. | 372 // js_helper.dart. |
| 374 if (selector.isClosureCall()) { | 373 if (selector.isClosureCall()) { |
| 375 return "${name.slowToString()}$suffix"; | 374 return "${name.slowToString()}$suffix"; |
| 376 } else { | 375 } else { |
| 377 String proposedName = privateName(selector.library, name); | 376 String proposedName = privateName(selector.library, name); |
| 378 return getMappedInstanceName('$proposedName$suffix'); | 377 return getMappedInstanceName('$proposedName$suffix'); |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 hash = hash ^ (hash >> 6); | 1124 hash = hash ^ (hash >> 6); |
| 1126 return hash; | 1125 return hash; |
| 1127 } | 1126 } |
| 1128 | 1127 |
| 1129 static int _finish(int hash) { | 1128 static int _finish(int hash) { |
| 1130 hash = _MASK & (hash + (((_MASK >> 3) & hash) << 3)); | 1129 hash = _MASK & (hash + (((_MASK >> 3) & hash) << 3)); |
| 1131 hash = hash & (hash >> 11); | 1130 hash = hash & (hash >> 11); |
| 1132 return _MASK & (hash + (((_MASK >> 15) & hash) << 15)); | 1131 return _MASK & (hash + (((_MASK >> 15) & hash) << 15)); |
| 1133 } | 1132 } |
| 1134 } | 1133 } |
| OLD | NEW |