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

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

Issue 10870066: Support unary - operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix unparser to handle that negate is no longer a keyword. 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 3ff6006c457cc11f9b32c7b810cd65cf7b8707e0..f94f9cb6586478dca4ea32f9f9a4592d2305f55e 100644
--- a/dart/lib/compiler/implementation/elements/elements.dart
+++ b/dart/lib/compiler/implementation/elements/elements.dart
@@ -1463,35 +1463,57 @@ class Elements {
static const SourceString OPERATOR_EQUALS =
const SourceString(@'operator$eq');
- static SourceString constructOperatorName(SourceString receiver,
- SourceString selector,
- [bool isUnary = false]) {
+ static SourceString constructOperatorName(SourceString selector,
+ bool isUnary) {
String str = selector.stringValue;
if (str === '==' || str === '!=') return OPERATOR_EQUALS;
- 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 {
+ 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 {
throw new Exception('Unhandled selector: ${selector.slowToString()}');
}
- return new SourceString('$receiver\$$str');
+ return new SourceString('operator\$$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