| 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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 * Returns the internal name used for an invocation mirror of this selector. | 435 * Returns the internal name used for an invocation mirror of this selector. |
| 436 */ | 436 */ |
| 437 String invocationMirrorInternalName(Selector selector) | 437 String invocationMirrorInternalName(Selector selector) |
| 438 => invocationName(selector); | 438 => invocationName(selector); |
| 439 | 439 |
| 440 String instanceFieldName(Element element) { | 440 String instanceFieldName(Element element) { |
| 441 String proposedName = privateName(element.getLibrary(), element.name); | 441 String proposedName = privateName(element.getLibrary(), element.name); |
| 442 return getMappedInstanceName(proposedName); | 442 return getMappedInstanceName(proposedName); |
| 443 } | 443 } |
| 444 | 444 |
| 445 String readTypeVariableName(TypeVariableElement element) { |
| 446 return '\$tv_${instanceFieldName(element)}'; |
| 447 } |
| 448 |
| 445 // Construct a new name for the element based on the library and class it is | 449 // Construct a new name for the element based on the library and class it is |
| 446 // in. The name here is not important, we just need to make sure it is | 450 // in. The name here is not important, we just need to make sure it is |
| 447 // unique. If we are minifying, we actually construct the name from the | 451 // unique. If we are minifying, we actually construct the name from the |
| 448 // minified versions of the class and instance names, but the result is | 452 // minified versions of the class and instance names, but the result is |
| 449 // minified once again, so that is not visible in the end result. | 453 // minified once again, so that is not visible in the end result. |
| 450 String shadowedFieldName(Element fieldElement) { | 454 String shadowedFieldName(Element fieldElement) { |
| 451 // Check for following situation: Native field ${fieldElement.name} has | 455 // Check for following situation: Native field ${fieldElement.name} has |
| 452 // fixed JSName ${fieldElement.nativeName()}, but a subclass shadows this | 456 // fixed JSName ${fieldElement.nativeName()}, but a subclass shadows this |
| 453 // name. We normally handle that by renaming the superclass field, but we | 457 // name. We normally handle that by renaming the superclass field, but we |
| 454 // can't do that because native fields have fixed JavaScript names. | 458 // can't do that because native fields have fixed JavaScript names. |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 if (!first) { | 1339 if (!first) { |
| 1336 sb.write('_'); | 1340 sb.write('_'); |
| 1337 } | 1341 } |
| 1338 sb.write('_'); | 1342 sb.write('_'); |
| 1339 visit(link.head); | 1343 visit(link.head); |
| 1340 first = true; | 1344 first = true; |
| 1341 } | 1345 } |
| 1342 } | 1346 } |
| 1343 } | 1347 } |
| 1344 } | 1348 } |
| OLD | NEW |