Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/elements/elements.dart

Issue 11348067: Fix operator handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Handle []= properly Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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' as api_e; 10 import '../../compiler.dart' as api_e;
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 return const SourceString(r'operator$or'); 1854 return const SourceString(r'operator$or');
1855 } else if (identical(value, '-')) { 1855 } else if (identical(value, '-')) {
1856 return const SourceString(r'operator$sub'); 1856 return const SourceString(r'operator$sub');
1857 } else if (identical(value, 'unary-')) { 1857 } else if (identical(value, 'unary-')) {
1858 return const SourceString(r'operator$negate'); 1858 return const SourceString(r'operator$negate');
1859 } else { 1859 } else {
1860 return name; 1860 return name;
1861 } 1861 }
1862 } 1862 }
1863 1863
1864 static SourceString constructOperatorName(SourceString op, bool isUnary) { 1864 static SourceString constructOperatorNameOrNull(SourceString op,
1865 bool isUnary) {
1865 String value = op.stringValue; 1866 String value = op.stringValue;
1866 if ((value === '==') || 1867 if ((value === '==') ||
1867 (value === '~') || 1868 (value === '~') ||
1868 (value === '[]') || 1869 (value === '[]') ||
1869 (value === '[]=') || 1870 (value === '[]=') ||
1870 (value === '*') || 1871 (value === '*') ||
1871 (value === '/') || 1872 (value === '/') ||
1872 (value === '%') || 1873 (value === '%') ||
1873 (value === '~/') || 1874 (value === '~/') ||
1874 (value === '+') || 1875 (value === '+') ||
1875 (value === '<<') || 1876 (value === '<<') ||
1876 (value === '>>>') || 1877 (value === '>>>') ||
1877 (value === '>>') || 1878 (value === '>>') ||
1878 (value === '>=') || 1879 (value === '>=') ||
1879 (value === '>') || 1880 (value === '>') ||
1880 (value === '<=') || 1881 (value === '<=') ||
1881 (value === '<') || 1882 (value === '<') ||
1882 (value === '&') || 1883 (value === '&') ||
1883 (value === '^') || 1884 (value === '^') ||
1884 (value === '|')) { 1885 (value === '|')) {
1885 return op; 1886 return op;
1886 } else if (value === '-') { 1887 } else if (value === '-') {
1887 return isUnary ? const SourceString('unary-') : op; 1888 return isUnary ? const SourceString('unary-') : op;
1888 } else { 1889 } else {
1889 throw 'Unhandled operator: ${op.slowToString()}'; 1890 return null;
1890 } 1891 }
1891 } 1892 }
1892 1893
1893 static SourceString mapToUserOperator(SourceString op) { 1894 static SourceString constructOperatorName(SourceString op, bool isUnary) {
1895 SourceString operatorName = constructOperatorNameOrNull(op, isUnary);
1896 if (operatorName == null) throw 'Unhandled operator: ${op.slowToString()}';
1897 else return operatorName;
1898 }
1899
1900 static SourceString mapToUserOperatorOrNull(SourceString op) {
1894 String value = op.stringValue; 1901 String value = op.stringValue;
1895 1902
1896 if (identical(value, '!=')) return const SourceString('=='); 1903 if (identical(value, '!=')) return const SourceString('==');
1897 if (identical(value, '*=')) return const SourceString('*'); 1904 if (identical(value, '*=')) return const SourceString('*');
1898 if (identical(value, '/=')) return const SourceString('/'); 1905 if (identical(value, '/=')) return const SourceString('/');
1899 if (identical(value, '%=')) return const SourceString('%'); 1906 if (identical(value, '%=')) return const SourceString('%');
1900 if (identical(value, '~/=')) return const SourceString('~/'); 1907 if (identical(value, '~/=')) return const SourceString('~/');
1901 if (identical(value, '+=')) return const SourceString('+'); 1908 if (identical(value, '+=')) return const SourceString('+');
1902 if (identical(value, '-=')) return const SourceString('-'); 1909 if (identical(value, '-=')) return const SourceString('-');
1903 if (identical(value, '<<=')) return const SourceString('<<'); 1910 if (identical(value, '<<=')) return const SourceString('<<');
1904 if (identical(value, '>>=')) return const SourceString('>>'); 1911 if (identical(value, '>>=')) return const SourceString('>>');
1905 if (identical(value, '&=')) return const SourceString('&'); 1912 if (identical(value, '&=')) return const SourceString('&');
1906 if (identical(value, '^=')) return const SourceString('^'); 1913 if (identical(value, '^=')) return const SourceString('^');
1907 if (identical(value, '|=')) return const SourceString('|'); 1914 if (identical(value, '|=')) return const SourceString('|');
1908 1915
1909 throw 'Unhandled operator: ${op.slowToString()}'; 1916 return null;
1917 }
1918
1919 static SourceString mapToUserOperator(SourceString op) {
1920 SourceString userOperator = mapToUserOperatorOrNull(op);
1921 if (userOperator == null) throw 'Unhandled operator: ${op.slowToString()}';
1922 else return userOperator;
1910 } 1923 }
1911 1924
1912 static bool isNumberOrStringSupertype(Element element, Compiler compiler) { 1925 static bool isNumberOrStringSupertype(Element element, Compiler compiler) {
1913 LibraryElement coreLibrary = compiler.coreLibrary; 1926 LibraryElement coreLibrary = compiler.coreLibrary;
1914 return (element == coreLibrary.find(const SourceString('Comparable'))); 1927 return (element == coreLibrary.find(const SourceString('Comparable')));
1915 } 1928 }
1916 1929
1917 static bool isStringOnlySupertype(Element element, Compiler compiler) { 1930 static bool isStringOnlySupertype(Element element, Compiler compiler) {
1918 LibraryElement coreLibrary = compiler.coreLibrary; 1931 LibraryElement coreLibrary = compiler.coreLibrary;
1919 return element == coreLibrary.find(const SourceString('Pattern')); 1932 return element == coreLibrary.find(const SourceString('Pattern'));
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 2052
2040 MetadataAnnotation ensureResolved(Compiler compiler) { 2053 MetadataAnnotation ensureResolved(Compiler compiler) {
2041 if (resolutionState == STATE_NOT_STARTED) { 2054 if (resolutionState == STATE_NOT_STARTED) {
2042 compiler.resolver.resolveMetadataAnnotation(this); 2055 compiler.resolver.resolveMetadataAnnotation(this);
2043 } 2056 }
2044 return this; 2057 return this;
2045 } 2058 }
2046 2059
2047 String toString() => 'MetadataAnnotation($value, $resolutionState)'; 2060 String toString() => 'MetadataAnnotation($value, $resolutionState)';
2048 } 2061 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698