| 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 MinifyNamer extends Namer { | 10 class MinifyNamer extends Namer { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 if (suggestion != null && !usedNames.contains(suggestion)) { | 41 if (suggestion != null && !usedNames.contains(suggestion)) { |
| 42 freshName = suggestion; | 42 freshName = suggestion; |
| 43 } else { | 43 } else { |
| 44 freshName = _getUnusedName(proposedName, usedNames, | 44 freshName = _getUnusedName(proposedName, usedNames, |
| 45 suggestedNames.values); | 45 suggestedNames.values); |
| 46 } | 46 } |
| 47 usedNames.add(freshName); | 47 usedNames.add(freshName); |
| 48 return freshName; | 48 return freshName; |
| 49 } | 49 } |
| 50 | 50 |
| 51 String getClosureVariableName(String _, int id) { |
| 52 if (id < ALPHABET_CHARACTERS) { |
| 53 return new String.fromCharCodes([_letterNumber(id)]); |
| 54 } |
| 55 // Fall back to a slightly longer name. |
| 56 String basename = _disambiguateMember(null, 'closure'); |
| 57 return '${basename}_$id'; |
| 58 } |
| 59 |
| 51 // From issue 7554. These should not be used on objects (as instance | 60 // From issue 7554. These should not be used on objects (as instance |
| 52 // variables) because they clash with names from the DOM. However, it is | 61 // variables) because they clash with names from the DOM. However, it is |
| 53 // OK to use them as fields, as we only access fields directly if we know | 62 // OK to use them as fields, as we only access fields directly if we know |
| 54 // the receiver type. | 63 // the receiver type. |
| 55 static const List<String> _reservedNativeProperties = const <String>[ | 64 static const List<String> _reservedNativeProperties = const <String>[ |
| 56 'Q', 'a', 'b', 'c', 'd', 'e', 'f', 'r', 'x', 'y', 'z', | 65 'Q', 'a', 'b', 'c', 'd', 'e', 'f', 'r', 'x', 'y', 'z', |
| 57 // 2-letter: | 66 // 2-letter: |
| 58 'ch', 'cx', 'cy', 'db', 'dx', 'dy', 'fr', 'fx', 'fy', 'go', 'id', 'k1', | 67 'ch', 'cx', 'cy', 'db', 'dx', 'dy', 'fr', 'fx', 'fy', 'go', 'id', 'k1', |
| 59 'k2', 'k3', 'k4', 'r1', 'r2', 'rx', 'ry', 'x1', 'x2', 'y1', 'y2', | 68 'k2', 'k3', 'k4', 'r1', 'r2', 'rx', 'ry', 'x1', 'x2', 'y1', 'y2', |
| 60 // 3-letter: | 69 // 3-letter: |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 _BoxFieldNamingScope(Local box, _FieldNamingRegistry registry) : | 444 _BoxFieldNamingScope(Local box, _FieldNamingRegistry registry) : |
| 436 super.rootScope(box, registry); | 445 super.rootScope(box, registry); |
| 437 | 446 |
| 438 bool containsField(_) => true; | 447 bool containsField(_) => true; |
| 439 | 448 |
| 440 String operator[](Element field) { | 449 String operator[](Element field) { |
| 441 if (!names.containsKey(field)) add(field); | 450 if (!names.containsKey(field)) add(field); |
| 442 return names[field]; | 451 return names[field]; |
| 443 } | 452 } |
| 444 } | 453 } |
| OLD | NEW |