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