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

Unified Diff: frog/leg/elements/elements.dart

Issue 9284022: Operators. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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 | « frog/leg/compiler.dart ('k') | frog/leg/emitter.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: frog/leg/elements/elements.dart
===================================================================
--- frog/leg/elements/elements.dart (revision 3645)
+++ frog/leg/elements/elements.dart (working copy)
@@ -411,7 +411,7 @@
// instead of creating the name here?
SourceString name;
if (constructorName !== const SourceString('')) {
- name = new SourceString('$className.$constructorName');
+ name = Elements.constructConstructorName(className, constructorName);
} else {
name = className;
}
@@ -471,4 +471,37 @@
// foo() with foo a local or a parameter.
return element.isVariable() || element.isParameter();
}
+
+ static SourceString constructConstructorName(SourceString receiver,
+ SourceString selector) {
+ return new SourceString('$receiver\$$selector');
+ }
+
+ static SourceString constructOperatorName(SourceString receiver,
+ SourceString selector,
+ [bool isPrefix = false]) {
+ String str = selector.stringValue;
+ if (str === '==' || str === '!=') return Namer.OPERATOR_EQUALS;
+
+ if (str === '~') str = 'not';
+ else if (str === 'negate' || (str === '-' && isPrefix)) 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';
+ return new SourceString('$receiver\$$str');
+ }
}
« no previous file with comments | « frog/leg/compiler.dart ('k') | frog/leg/emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698