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

Unified Diff: pkg/compiler/lib/src/resolution/operators.dart

Issue 1070293004: Use UnaryOperator and BinaryOperator in ConstantSystem. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Reinsert from bad merge Created 5 years, 8 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 | « pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/operators.dart
diff --git a/pkg/compiler/lib/src/resolution/operators.dart b/pkg/compiler/lib/src/resolution/operators.dart
index 3207acaec082c2161cfd424e165b88d534ee95ec..e862c30e89d48e06c9562cbbe912bc9cf7e8b839 100644
--- a/pkg/compiler/lib/src/resolution/operators.dart
+++ b/pkg/compiler/lib/src/resolution/operators.dart
@@ -4,6 +4,8 @@
library dart2js.operators;
+import '../elements/elements.dart';
+
enum UnaryOperatorKind {
NOT,
NEGATE,
@@ -43,7 +45,6 @@ class UnaryOperator {
}
}
-
enum BinaryOperatorKind {
EQ,
NOT_EQ,
@@ -63,6 +64,8 @@ enum BinaryOperatorKind {
AND,
OR,
XOR,
+ LOGICAL_AND,
+ LOGICAL_OR,
}
class BinaryOperator {
@@ -71,7 +74,10 @@ class BinaryOperator {
const BinaryOperator._(this.kind, this.name);
+ /// `true` if this operator can be implemented through an `operator [name]`
+ /// method.
bool get isUserDefinable => true;
+
String get selectorName => name;
String toString() => name;
@@ -147,6 +153,14 @@ class BinaryOperator {
static const BinaryOperator XOR =
const BinaryOperator._(BinaryOperatorKind.XOR, '^');
+ /// The logical && operator.
+ static const BinaryOperator LOGICAL_AND =
+ const _LogicalOperator(BinaryOperatorKind.LOGICAL_AND, '&&');
+
+ /// The binary | operator.
+ static const BinaryOperator LOGICAL_OR =
+ const _LogicalOperator(BinaryOperatorKind.LOGICAL_OR, '||');
+
static BinaryOperator parse(String value) {
switch (value) {
case '==': return EQ;
@@ -167,12 +181,15 @@ class BinaryOperator {
case '&': return AND;
case '^': return XOR;
case '|': return OR;
+ case '&&': return LOGICAL_AND;
+ case '||': return LOGICAL_OR;
default: return null;
}
}
}
-/// The operator !=, which is not user definable operator but instead is a negation
+/// The operator !=, which is not user definable operator but instead is a
+/// negation of a call to user definable operator, namely ==.
class _NotEqualsOperator extends BinaryOperator {
const _NotEqualsOperator() : super._(BinaryOperatorKind.NOT_EQ, '!=');
@@ -181,6 +198,17 @@ class _NotEqualsOperator extends BinaryOperator {
String get selectorName => '==';
}
+/// The operators && and || which are not user definable operators but control
+/// structures.
+class _LogicalOperator extends BinaryOperator {
+ const _LogicalOperator(BinaryOperatorKind kind, String name)
+ : super._(kind, name);
+
+ bool get isUserDefinable => false;
+
+ String get selectorName => null;
+}
+
enum AssignmentOperatorKind {
ASSIGN,
ADD,
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/backend_ast_emitter.dart ('k') | pkg/compiler/lib/src/ssa/builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698