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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/elements/elements.dart
diff --git a/sdk/lib/_internal/compiler/implementation/elements/elements.dart b/sdk/lib/_internal/compiler/implementation/elements/elements.dart
index fbdc8ca869b2c28100bb168594afdfa5b2fb45bf..2942c4ea586b1235abdd7ac49149ffbb1586df51 100644
--- a/sdk/lib/_internal/compiler/implementation/elements/elements.dart
+++ b/sdk/lib/_internal/compiler/implementation/elements/elements.dart
@@ -1861,7 +1861,8 @@ class Elements {
}
}
- static SourceString constructOperatorName(SourceString op, bool isUnary) {
+ static SourceString constructOperatorNameOrNull(SourceString op,
+ bool isUnary) {
String value = op.stringValue;
if ((value === '==') ||
(value === '~') ||
@@ -1886,11 +1887,17 @@ class Elements {
} else if (value === '-') {
return isUnary ? const SourceString('unary-') : op;
} else {
- throw 'Unhandled operator: ${op.slowToString()}';
+ return null;
}
}
- static SourceString mapToUserOperator(SourceString op) {
+ static SourceString constructOperatorName(SourceString op, bool isUnary) {
+ SourceString operatorName = constructOperatorNameOrNull(op, isUnary);
+ if (operatorName == null) throw 'Unhandled operator: ${op.slowToString()}';
+ else return operatorName;
+ }
+
+ static SourceString mapToUserOperatorOrNull(SourceString op) {
String value = op.stringValue;
if (identical(value, '!=')) return const SourceString('==');
@@ -1906,7 +1913,13 @@ class Elements {
if (identical(value, '^=')) return const SourceString('^');
if (identical(value, '|=')) return const SourceString('|');
- throw 'Unhandled operator: ${op.slowToString()}';
+ return null;
+ }
+
+ static SourceString mapToUserOperator(SourceString op) {
+ SourceString userOperator = mapToUserOperatorOrNull(op);
+ if (userOperator == null) throw 'Unhandled operator: ${op.slowToString()}';
+ else return userOperator;
}
static bool isNumberOrStringSupertype(Element element, Compiler compiler) {

Powered by Google App Engine
This is Rietveld 408576698