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 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 addIdentifier(name); | 1536 addIdentifier(name); |
1537 } | 1537 } |
1538 | 1538 |
1539 @override | 1539 @override |
1540 void visitInterceptor(InterceptorConstantValue constant, [_]) { | 1540 void visitInterceptor(InterceptorConstantValue constant, [_]) { |
1541 addRoot(constant.dispatchedType.element.name); | 1541 addRoot(constant.dispatchedType.element.name); |
1542 add('methods'); | 1542 add('methods'); |
1543 } | 1543 } |
1544 | 1544 |
1545 @override | 1545 @override |
1546 void visitDummy(DummyConstantValue constant, [_]) { | 1546 void visitSynthetic(SyntheticConstantValue constant, [_]) { |
1547 add('dummy_receiver'); | 1547 switch (constant.kind) { |
| 1548 case SyntheticConstantKind.DUMMY_INTERCEPTOR: |
| 1549 add('dummy_receiver'); |
| 1550 break; |
| 1551 case SyntheticConstantKind.TYPEVARIABLE_REFERENCE: |
| 1552 add('type_variable_reference'); |
| 1553 break; |
| 1554 default: |
| 1555 compiler.internalError(compiler.currentElement, |
| 1556 "Unexpected SyntheticConstantValue"); |
| 1557 } |
1548 } | 1558 } |
1549 | 1559 |
1550 @override | 1560 @override |
1551 void visitDeferred(DeferredConstantValue constant, [_]) { | 1561 void visitDeferred(DeferredConstantValue constant, [_]) { |
1552 addRoot('Deferred'); | 1562 addRoot('Deferred'); |
1553 } | 1563 } |
1554 } | 1564 } |
1555 | 1565 |
1556 /** | 1566 /** |
1557 * Generates canonical hash values for [ConstantValue]s. | 1567 * Generates canonical hash values for [ConstantValue]s. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 return _hashString(4, name); | 1649 return _hashString(4, name); |
1640 } | 1650 } |
1641 | 1651 |
1642 @override | 1652 @override |
1643 int visitInterceptor(InterceptorConstantValue constant, [_]) { | 1653 int visitInterceptor(InterceptorConstantValue constant, [_]) { |
1644 String typeName = constant.dispatchedType.element.name; | 1654 String typeName = constant.dispatchedType.element.name; |
1645 return _hashString(5, typeName); | 1655 return _hashString(5, typeName); |
1646 } | 1656 } |
1647 | 1657 |
1648 @override | 1658 @override |
1649 visitDummy(DummyConstantValue constant, [_]) { | 1659 visitSynthetic(SyntheticConstantValue constant, [_]) { |
1650 compiler.internalError(NO_LOCATION_SPANNABLE, | 1660 switch (constant.kind) { |
1651 'DummyReceiverConstant should never be named and never be subconstant'); | 1661 case SyntheticConstantKind.TYPEVARIABLE_REFERENCE: |
| 1662 return constant.payload.hashCode; |
| 1663 default: |
| 1664 compiler.internalError(NO_LOCATION_SPANNABLE, |
| 1665 'SyntheticConstantValue should never be named and
' |
| 1666 'never be subconstant'); |
| 1667 return null; |
| 1668 } |
1652 } | 1669 } |
1653 | 1670 |
1654 @override | 1671 @override |
1655 int visitDeferred(DeferredConstantValue constant, [_]) { | 1672 int visitDeferred(DeferredConstantValue constant, [_]) { |
1656 int hash = constant.prefix.hashCode; | 1673 int hash = constant.prefix.hashCode; |
1657 return _combine(hash, _visit(constant.referenced)); | 1674 return _combine(hash, _visit(constant.referenced)); |
1658 } | 1675 } |
1659 | 1676 |
1660 int _hashString(int hash, String s) { | 1677 int _hashString(int hash, String s) { |
1661 int length = s.length; | 1678 int length = s.length; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 if (!first) { | 1792 if (!first) { |
1776 sb.write('_'); | 1793 sb.write('_'); |
1777 } | 1794 } |
1778 sb.write('_'); | 1795 sb.write('_'); |
1779 visit(parameter); | 1796 visit(parameter); |
1780 first = true; | 1797 first = true; |
1781 } | 1798 } |
1782 } | 1799 } |
1783 } | 1800 } |
1784 } | 1801 } |
OLD | NEW |