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

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

Issue 10905211: Clean up operator names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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
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 dc70d0f39b13d28cea2c6ccf8e5451055e4058fe..6c834088b858e0501543131927da9619d0e2223c 100644
--- a/dart/lib/compiler/implementation/elements/elements.dart
+++ b/dart/lib/compiler/implementation/elements/elements.dart
@@ -1756,62 +1756,33 @@ class Elements {
return new SourceString('$r\$$s');
}
- static const SourceString OPERATOR_EQUALS =
- const SourceString(r'operator$eq');
-
- static SourceString constructOperatorName(SourceString selector,
- bool isUnary) {
- 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 === '?') {
- return selector;
+ static SourceString constructOperatorName(SourceString op, bool isUnary) {
+ String value = op.stringValue;
+ if ((value === '==') ||
+ (value === '~') ||
+ (value === '[]') ||
+ (value === '[]=') ||
+ (value === '*') ||
+ (value === '/') ||
+ (value === '%') ||
+ (value === '~/') ||
+ (value === '+') ||
+ (value === '<<') ||
+ (value === '>>>') ||
+ (value === '>>') ||
+ (value === '>=') ||
+ (value === '>') ||
+ (value === '<=') ||
+ (value === '<') ||
+ (value === '&') ||
+ (value === '^') ||
+ (value === '|')) {
+ 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.
+ } else if (value === '-') {
+ return isUnary ? const SourceString('unary -') : op;
} else {
- throw new Exception('Unhandled selector: ${selector.slowToString()}');
+ throw 'Unhandled operator: ${op.slowToString()}';
}
- return new SourceString('operator\$$str');
}
static SourceString mapToUserOperator(SourceString op) {

Powered by Google App Engine
This is Rietveld 408576698