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

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

Issue 1151163004: Implementation of null-aware operators. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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/resolution/members.dart ('k') | pkg/compiler/lib/src/resolution/semantic_visitor.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 e862c30e89d48e06c9562cbbe912bc9cf7e8b839..e903b10281c4876d4a240820099430f8b25c9f5d 100644
--- a/pkg/compiler/lib/src/resolution/operators.dart
+++ b/pkg/compiler/lib/src/resolution/operators.dart
@@ -66,6 +66,7 @@ enum BinaryOperatorKind {
XOR,
LOGICAL_AND,
LOGICAL_OR,
+ IF_NULL,
}
class BinaryOperator {
@@ -161,6 +162,10 @@ class BinaryOperator {
static const BinaryOperator LOGICAL_OR =
const _LogicalOperator(BinaryOperatorKind.LOGICAL_OR, '||');
+ /// The if-null ?? operator.
+ static const BinaryOperator IF_NULL =
+ const _LogicalOperator(BinaryOperatorKind.IF_NULL, '??');
+
static BinaryOperator parse(String value) {
switch (value) {
case '==': return EQ;
@@ -183,6 +188,7 @@ class BinaryOperator {
case '|': return OR;
case '&&': return LOGICAL_AND;
case '||': return LOGICAL_OR;
+ case '??': return IF_NULL;
default: return null;
}
}
@@ -211,6 +217,7 @@ class _LogicalOperator extends BinaryOperator {
enum AssignmentOperatorKind {
ASSIGN,
+ IF_NULL,
ADD,
SUB,
MUL,
@@ -244,6 +251,12 @@ class AssignmentOperator {
const AssignmentOperator._(AssignmentOperatorKind.ASSIGN, '=',
null, isUserDefinable: false);
+ /// The ??= operator.
+ static const AssignmentOperator IF_NULL =
+ const AssignmentOperator._(AssignmentOperatorKind.IF_NULL, '??=',
+ BinaryOperator.IF_NULL,
+ isUserDefinable: false);
+
/// The += assignment operator.
static const AssignmentOperator ADD =
const AssignmentOperator._(AssignmentOperatorKind.ADD, '+=',
@@ -302,6 +315,7 @@ class AssignmentOperator {
static AssignmentOperator parse(String value) {
switch (value) {
case '=': return ASSIGN;
+ case '??=': return IF_NULL;
case '*=': return MUL;
case '/=': return DIV;
case '%=': return MOD;
@@ -349,4 +363,4 @@ class IncDecOperator {
default: return null;
}
}
-}
+}
« no previous file with comments | « pkg/compiler/lib/src/resolution/members.dart ('k') | pkg/compiler/lib/src/resolution/semantic_visitor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698