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

Unified Diff: dart/lib/compiler/implementation/elements/elements.dart

Issue 10892005: Revert "Support unary - operator." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/lib/interceptors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/lib/compiler/implementation/elements/elements.dart
diff --git a/dart/lib/compiler/implementation/elements/elements.dart b/dart/lib/compiler/implementation/elements/elements.dart
index f94f9cb6586478dca4ea32f9f9a4592d2305f55e..3ff6006c457cc11f9b32c7b810cd65cf7b8707e0 100644
--- a/dart/lib/compiler/implementation/elements/elements.dart
+++ b/dart/lib/compiler/implementation/elements/elements.dart
@@ -1463,57 +1463,35 @@ class Elements {
static const SourceString OPERATOR_EQUALS =
const SourceString(@'operator$eq');
- static SourceString constructOperatorName(SourceString selector,
- bool isUnary) {
+ static SourceString constructOperatorName(SourceString receiver,
+ SourceString selector,
+ [bool isUnary = false]) {
String str = selector.stringValue;
if (str === '==' || str === '!=') return OPERATOR_EQUALS;
- if (str === '~') {
- str = 'not';
- } else if (str === '-' && isUnary) {
- // TODO(ahe): Return something like 'unary -'.
- return const SourceString('negate');
- } else if (str === '[]') {
- str = 'index';
- } else if (str === '[]=') {
- str = 'indexSet';
- } else if (str === '*' || str === '*=') {
- str = 'mul';
- } else if (str === '/' || str === '/=') {
- str = 'div';
- } else if (str === '%' || str === '%=') {
- str = 'mod';
- } else if (str === '~/' || str === '~/=') {
- str = 'tdiv';
- } else if (str === '+' || str === '+=') {
- str = 'add';
- } else if (str === '-' || str === '-=') {
- str = 'sub';
- } else if (str === '<<' || str === '<<=') {
- str = 'shl';
- } else if (str === '>>' || str === '>>=') {
- str = 'shr';
- } else if (str === '>=') {
- str = 'ge';
- } else if (str === '>') {
- str = 'gt';
- } else if (str === '<=') {
- str = 'le';
- } else if (str === '<') {
- str = 'lt';
- } else if (str === '&' || str === '&=') {
- str = 'and';
- } else if (str === '^' || str === '^=') {
- str = 'xor';
- } else if (str === '|' || str === '|=') {
- str = 'or';
- } else if (selector == const SourceString('negate')) {
- // TODO(ahe): Remove this case: Legacy support for pre-0.11 spec.
- return selector;
- } else {
+ if (str === '~') str = 'not';
+ else if (str === 'negate' || (str === '-' && isUnary)) str = 'negate';
+ else if (str === '[]') str = 'index';
+ else if (str === '[]=') str = 'indexSet';
+ else if (str === '*' || str === '*=') str = 'mul';
+ else if (str === '/' || str === '/=') str = 'div';
+ else if (str === '%' || str === '%=') str = 'mod';
+ else if (str === '~/' || str === '~/=') str = 'tdiv';
+ else if (str === '+' || str === '+=') str = 'add';
+ else if (str === '-' || str === '-=') str = 'sub';
+ else if (str === '<<' || str === '<<=') str = 'shl';
+ else if (str === '>>' || str === '>>=') str = 'shr';
+ else if (str === '>=') str = 'ge';
+ else if (str === '>') str = 'gt';
+ else if (str === '<=') str = 'le';
+ else if (str === '<') str = 'lt';
+ else if (str === '&' || str === '&=') str = 'and';
+ else if (str === '^' || str === '^=') str = 'xor';
+ else if (str === '|' || str === '|=') str = 'or';
+ else {
throw new Exception('Unhandled selector: ${selector.slowToString()}');
}
- return new SourceString('operator\$$str');
+ return new SourceString('$receiver\$$str');
}
static bool isStringSupertype(Element element, Compiler compiler) {
« no previous file with comments | « no previous file | dart/lib/compiler/implementation/lib/interceptors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698