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 * Names are generated through three stages: | 10 * Names are generated through three stages: |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 void visitFunction(FunctionConstantValue constant, [_]) { | 1665 void visitFunction(FunctionConstantValue constant, [_]) { |
1666 add(constant.element.name); | 1666 add(constant.element.name); |
1667 } | 1667 } |
1668 | 1668 |
1669 @override | 1669 @override |
1670 void visitNull(NullConstantValue constant, [_]) { | 1670 void visitNull(NullConstantValue constant, [_]) { |
1671 add('null'); | 1671 add('null'); |
1672 } | 1672 } |
1673 | 1673 |
1674 @override | 1674 @override |
| 1675 void visitNonConstant(NonConstantValue constant, [_]) { |
| 1676 add('null'); |
| 1677 } |
| 1678 |
| 1679 @override |
1675 void visitInt(IntConstantValue constant, [_]) { | 1680 void visitInt(IntConstantValue constant, [_]) { |
1676 // No `addRoot` since IntConstants are always inlined. | 1681 // No `addRoot` since IntConstants are always inlined. |
1677 if (constant.primitiveValue < 0) { | 1682 if (constant.primitiveValue < 0) { |
1678 add('m${-constant.primitiveValue}'); | 1683 add('m${-constant.primitiveValue}'); |
1679 } else { | 1684 } else { |
1680 add('${constant.primitiveValue}'); | 1685 add('${constant.primitiveValue}'); |
1681 } | 1686 } |
1682 } | 1687 } |
1683 | 1688 |
1684 @override | 1689 @override |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1809 hash = _finish(constant.accept(this, null)); | 1814 hash = _finish(constant.accept(this, null)); |
1810 hashes[constant] = hash; | 1815 hashes[constant] = hash; |
1811 } | 1816 } |
1812 return hash; | 1817 return hash; |
1813 } | 1818 } |
1814 | 1819 |
1815 @override | 1820 @override |
1816 int visitNull(NullConstantValue constant, [_]) => 1; | 1821 int visitNull(NullConstantValue constant, [_]) => 1; |
1817 | 1822 |
1818 @override | 1823 @override |
| 1824 int visitNonConstant(NonConstantValue constant, [_]) => 1; |
| 1825 |
| 1826 @override |
1819 int visitBool(BoolConstantValue constant, [_]) { | 1827 int visitBool(BoolConstantValue constant, [_]) { |
1820 return constant.isTrue ? 2 : 3; | 1828 return constant.isTrue ? 2 : 3; |
1821 } | 1829 } |
1822 | 1830 |
1823 @override | 1831 @override |
1824 int visitFunction(FunctionConstantValue constant, [_]) { | 1832 int visitFunction(FunctionConstantValue constant, [_]) { |
1825 return _hashString(1, constant.element.name); | 1833 return _hashString(1, constant.element.name); |
1826 } | 1834 } |
1827 | 1835 |
1828 @override | 1836 @override |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 void addSuggestion(String original, String suggestion) { | 2054 void addSuggestion(String original, String suggestion) { |
2047 assert(!_suggestedNames.containsKey(original)); | 2055 assert(!_suggestedNames.containsKey(original)); |
2048 _suggestedNames[original] = suggestion; | 2056 _suggestedNames[original] = suggestion; |
2049 } | 2057 } |
2050 | 2058 |
2051 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); | 2059 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); |
2052 bool isSuggestion(String candidate) { | 2060 bool isSuggestion(String candidate) { |
2053 return _suggestedNames.containsValue(candidate); | 2061 return _suggestedNames.containsValue(candidate); |
2054 } | 2062 } |
2055 } | 2063 } |
OLD | NEW |