Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.operators; | 5 library dart2js.operators; |
| 6 | 6 |
| 7 import '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
| 8 import '../universe/universe.dart'; | 8 import '../universe/universe.dart'; |
| 9 | 9 |
| 10 enum UnaryOperatorKind { | 10 enum UnaryOperatorKind { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 /// The logical && operator. | 163 /// The logical && operator. |
| 164 static const BinaryOperator LOGICAL_AND = | 164 static const BinaryOperator LOGICAL_AND = |
| 165 const _LogicalOperator(BinaryOperatorKind.LOGICAL_AND, '&&'); | 165 const _LogicalOperator(BinaryOperatorKind.LOGICAL_AND, '&&'); |
| 166 | 166 |
| 167 /// The binary | operator. | 167 /// The binary | operator. |
| 168 static const BinaryOperator LOGICAL_OR = | 168 static const BinaryOperator LOGICAL_OR = |
| 169 const _LogicalOperator(BinaryOperatorKind.LOGICAL_OR, '||'); | 169 const _LogicalOperator(BinaryOperatorKind.LOGICAL_OR, '||'); |
| 170 | 170 |
| 171 /// The if-null ?? operator. | 171 /// The if-null ?? operator. |
| 172 static const BinaryOperator IF_NULL = | 172 static const BinaryOperator IF_NULL = |
| 173 const _LogicalOperator(BinaryOperatorKind.IF_NULL, '??'); | 173 const _IfNullOperator(BinaryOperatorKind.IF_NULL, '??'); |
| 174 | 174 |
| 175 static BinaryOperator parse(String value) { | 175 static BinaryOperator parse(String value) { |
| 176 switch (value) { | 176 switch (value) { |
| 177 case '==': return EQ; | 177 case '==': return EQ; |
| 178 case '!=': return NOT_EQ; | 178 case '!=': return NOT_EQ; |
| 179 case '[]': return INDEX; | 179 case '[]': return INDEX; |
| 180 case '*': return MUL; | 180 case '*': return MUL; |
| 181 case '/': return DIV; | 181 case '/': return DIV; |
| 182 case '%': return MOD; | 182 case '%': return MOD; |
| 183 case '~/': return IDIV; | 183 case '~/': return IDIV; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 214 /// structures. | 214 /// structures. |
| 215 class _LogicalOperator extends BinaryOperator { | 215 class _LogicalOperator extends BinaryOperator { |
| 216 const _LogicalOperator(BinaryOperatorKind kind, String name) | 216 const _LogicalOperator(BinaryOperatorKind kind, String name) |
| 217 : super._(kind, name); | 217 : super._(kind, name); |
| 218 | 218 |
| 219 bool get isUserDefinable => false; | 219 bool get isUserDefinable => false; |
| 220 | 220 |
| 221 String get selectorName => null; | 221 String get selectorName => null; |
| 222 } | 222 } |
| 223 | 223 |
| 224 /// The operators ?? is not user definable. | |
| 225 class _IfNullOperator extends BinaryOperator { | |
|
Siggi Cherem (dart-lang)
2015/05/28 02:15:34
technically this cleanup is not needed for this CL
Johnni Winther
2015/05/29 10:23:24
Acknowledged.
| |
| 226 const _IfNullOperator(BinaryOperatorKind kind, String name) | |
| 227 : super._(kind, name); | |
| 228 | |
| 229 bool get isUserDefinable => false; | |
| 230 | |
| 231 String get selectorName => '??'; | |
| 232 } | |
| 233 | |
| 224 enum AssignmentOperatorKind { | 234 enum AssignmentOperatorKind { |
| 225 ASSIGN, | 235 ASSIGN, |
| 226 IF_NULL, | 236 IF_NULL, |
| 227 ADD, | 237 ADD, |
| 228 SUB, | 238 SUB, |
| 229 MUL, | 239 MUL, |
| 230 DIV, | 240 DIV, |
| 231 IDIV, | 241 IDIV, |
| 232 MOD, | 242 MOD, |
| 233 SHL, | 243 SHL, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 const IncDecOperator._(IncDecOperatorKind.DEC, '--', BinaryOperator.SUB); | 373 const IncDecOperator._(IncDecOperatorKind.DEC, '--', BinaryOperator.SUB); |
| 364 | 374 |
| 365 static IncDecOperator parse(String value) { | 375 static IncDecOperator parse(String value) { |
| 366 switch (value) { | 376 switch (value) { |
| 367 case '++': return INC; | 377 case '++': return INC; |
| 368 case '--': return DEC; | 378 case '--': return DEC; |
| 369 default: return null; | 379 default: return null; |
| 370 } | 380 } |
| 371 } | 381 } |
| 372 } | 382 } |
| OLD | NEW |