Chromium Code Reviews| 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 |
|
karlklose
2015/04/17 13:27:38
I don't think they are usually called control-stru
|
| +/// 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, |