Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #library('elements'); | 5 #library('elements'); |
| 6 | 6 |
| 7 #import('dart:uri'); | 7 #import('dart:uri'); |
| 8 | 8 |
| 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. | 9 // TODO(ahe): Rename prefix to 'api' when VM bug is fixed. |
| 10 #import('../../compiler.dart', prefix: 'api_e'); | 10 #import('../../compiler.dart', prefix: 'api_e'); |
| (...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1749 return isLocal(element); | 1749 return isLocal(element); |
| 1750 } | 1750 } |
| 1751 | 1751 |
| 1752 static SourceString constructConstructorName(SourceString receiver, | 1752 static SourceString constructConstructorName(SourceString receiver, |
| 1753 SourceString selector) { | 1753 SourceString selector) { |
| 1754 String r = receiver.slowToString(); | 1754 String r = receiver.slowToString(); |
| 1755 String s = selector.slowToString(); | 1755 String s = selector.slowToString(); |
| 1756 return new SourceString('$r\$$s'); | 1756 return new SourceString('$r\$$s'); |
| 1757 } | 1757 } |
| 1758 | 1758 |
| 1759 static const SourceString OPERATOR_EQUALS = | 1759 static SourceString constructOperatorName(SourceString op, bool isUnary) { |
| 1760 const SourceString(r'operator$eq'); | 1760 String value = op.stringValue; |
| 1761 | 1761 if ((value === '==') || |
| 1762 static SourceString constructOperatorName(SourceString selector, | 1762 (value === '~') || |
| 1763 bool isUnary) { | 1763 (value === '[]') || |
| 1764 String str = selector.stringValue; | 1764 (value === '[]=') || |
| 1765 if (str === '==' || str === '!=') return OPERATOR_EQUALS; | 1765 (value === '*') || |
| 1766 | 1766 (value === '/') || |
| 1767 if (str === '~') { | 1767 (value === '%') || |
| 1768 str = 'not'; | 1768 (value === '~/') || |
| 1769 } else if (str === '-' && isUnary) { | 1769 (value === '+') || |
| 1770 // TODO(ahe): Return something like 'unary -'. | 1770 (value === '<<') || |
| 1771 return const SourceString('negate'); | 1771 (value === '>>>') || |
| 1772 } else if (str === '[]') { | 1772 (value === '>>') || |
| 1773 str = 'index'; | 1773 (value === '>=') || |
| 1774 } else if (str === '[]=') { | 1774 (value === '>') || |
| 1775 str = 'indexSet'; | 1775 (value === '<=') || |
| 1776 } else if (str === '*' || str === '*=') { | 1776 (value === '<') || |
| 1777 str = 'mul'; | 1777 (value === '&') || |
| 1778 } else if (str === '/' || str === '/=') { | 1778 (value === '^') || |
| 1779 str = 'div'; | 1779 (value === '|')) { |
| 1780 } else if (str === '%' || str === '%=') { | 1780 return op; |
|
erikcorry
2012/10/17 12:46:39
Having property names that are not valid identifie
ahe
2012/11/12 13:22:09
Done.
| |
| 1781 str = 'mod'; | 1781 } else if (value === '-') { |
| 1782 } else if (str === '~/' || str === '~/=') { | 1782 return isUnary ? const SourceString('unary -') : op; |
| 1783 str = 'tdiv'; | |
| 1784 } else if (str === '+' || str === '+=') { | |
| 1785 str = 'add'; | |
| 1786 } else if (str === '-' || str === '-=') { | |
| 1787 str = 'sub'; | |
| 1788 } else if (str === '<<' || str === '<<=') { | |
| 1789 str = 'shl'; | |
| 1790 } else if (str === '>>' || str === '>>=') { | |
| 1791 str = 'shr'; | |
| 1792 } else if (str === '>=') { | |
| 1793 str = 'ge'; | |
| 1794 } else if (str === '>') { | |
| 1795 str = 'gt'; | |
| 1796 } else if (str === '<=') { | |
| 1797 str = 'le'; | |
| 1798 } else if (str === '<') { | |
| 1799 str = 'lt'; | |
| 1800 } else if (str === '&' || str === '&=') { | |
| 1801 str = 'and'; | |
| 1802 } else if (str === '^' || str === '^=') { | |
| 1803 str = 'xor'; | |
| 1804 } else if (str === '|' || str === '|=') { | |
| 1805 str = 'or'; | |
| 1806 } else if (selector == const SourceString('negate')) { | |
| 1807 // TODO(ahe): Remove this case: Legacy support for pre-0.11 spec. | |
| 1808 return selector; | |
| 1809 } else if (str === '?') { | |
| 1810 return selector; | |
| 1811 } else { | 1783 } else { |
| 1812 throw new Exception('Unhandled selector: ${selector.slowToString()}'); | 1784 throw 'Unhandled operator: ${op.slowToString()}'; |
| 1813 } | 1785 } |
| 1814 return new SourceString('operator\$$str'); | |
| 1815 } | 1786 } |
| 1816 | 1787 |
| 1817 static SourceString mapToUserOperator(SourceString op) { | 1788 static SourceString mapToUserOperator(SourceString op) { |
| 1818 String value = op.stringValue; | 1789 String value = op.stringValue; |
| 1819 | 1790 |
| 1820 if (value === '!=') return const SourceString('=='); | 1791 if (value === '!=') return const SourceString('=='); |
| 1821 if (value === '*=') return const SourceString('*'); | 1792 if (value === '*=') return const SourceString('*'); |
| 1822 if (value === '/=') return const SourceString('/'); | 1793 if (value === '/=') return const SourceString('/'); |
| 1823 if (value === '%=') return const SourceString('%'); | 1794 if (value === '%=') return const SourceString('%'); |
| 1824 if (value === '~/=') return const SourceString('~/'); | 1795 if (value === '~/=') return const SourceString('~/'); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1963 | 1934 |
| 1964 MetadataAnnotation ensureResolved(Compiler compiler) { | 1935 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 1965 if (resolutionState == STATE_NOT_STARTED) { | 1936 if (resolutionState == STATE_NOT_STARTED) { |
| 1966 compiler.resolver.resolveMetadataAnnotation(this); | 1937 compiler.resolver.resolveMetadataAnnotation(this); |
| 1967 } | 1938 } |
| 1968 return this; | 1939 return this; |
| 1969 } | 1940 } |
| 1970 | 1941 |
| 1971 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 1942 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 1972 } | 1943 } |
| OLD | NEW |