| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 const UnaryOperator(UnaryOperatorKind.COMPLEMENT, '~', '~'); | 42 const UnaryOperator(UnaryOperatorKind.COMPLEMENT, '~', '~'); |
| 43 | 43 |
| 44 static UnaryOperator parse(String value) { | 44 static UnaryOperator parse(String value) { |
| 45 switch (value) { | 45 switch (value) { |
| 46 case '!': return NOT; | 46 case '!': return NOT; |
| 47 case '-': return NEGATE; | 47 case '-': return NEGATE; |
| 48 case '~': return COMPLEMENT; | 48 case '~': return COMPLEMENT; |
| 49 default: return null; | 49 default: return null; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 |
| 53 static UnaryOperator fromKind(UnaryOperatorKind kind) { |
| 54 switch (kind) { |
| 55 case UnaryOperatorKind.NOT: return NOT; |
| 56 case UnaryOperatorKind.NEGATE: return NEGATE; |
| 57 case UnaryOperatorKind.COMPLEMENT: return COMPLEMENT; |
| 58 } |
| 59 } |
| 52 } | 60 } |
| 53 | 61 |
| 54 enum BinaryOperatorKind { | 62 enum BinaryOperatorKind { |
| 55 EQ, | 63 EQ, |
| 56 NOT_EQ, | 64 NOT_EQ, |
| 57 INDEX, | 65 INDEX, |
| 58 ADD, | 66 ADD, |
| 59 SUB, | 67 SUB, |
| 60 MUL, | 68 MUL, |
| 61 DIV, | 69 DIV, |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 case '<': return LT; | 199 case '<': return LT; |
| 192 case '&': return AND; | 200 case '&': return AND; |
| 193 case '^': return XOR; | 201 case '^': return XOR; |
| 194 case '|': return OR; | 202 case '|': return OR; |
| 195 case '&&': return LOGICAL_AND; | 203 case '&&': return LOGICAL_AND; |
| 196 case '||': return LOGICAL_OR; | 204 case '||': return LOGICAL_OR; |
| 197 case '??': return IF_NULL; | 205 case '??': return IF_NULL; |
| 198 default: return null; | 206 default: return null; |
| 199 } | 207 } |
| 200 } | 208 } |
| 209 |
| 210 static BinaryOperator fromKind(BinaryOperatorKind kind) { |
| 211 switch (kind) { |
| 212 case BinaryOperatorKind.EQ: return EQ; |
| 213 case BinaryOperatorKind.NOT_EQ: return NOT_EQ; |
| 214 case BinaryOperatorKind.INDEX: return INDEX; |
| 215 case BinaryOperatorKind.MUL: return MUL; |
| 216 case BinaryOperatorKind.DIV: return DIV; |
| 217 case BinaryOperatorKind.MOD: return MOD; |
| 218 case BinaryOperatorKind.IDIV: return IDIV; |
| 219 case BinaryOperatorKind.ADD: return ADD; |
| 220 case BinaryOperatorKind.SUB: return SUB; |
| 221 case BinaryOperatorKind.SHL: return SHL; |
| 222 case BinaryOperatorKind.SHR: return SHR; |
| 223 case BinaryOperatorKind.GTEQ: return GTEQ; |
| 224 case BinaryOperatorKind.GT: return GT; |
| 225 case BinaryOperatorKind.LTEQ: return LTEQ; |
| 226 case BinaryOperatorKind.LT: return LT; |
| 227 case BinaryOperatorKind.AND: return AND; |
| 228 case BinaryOperatorKind.XOR: return XOR; |
| 229 case BinaryOperatorKind.OR: return OR; |
| 230 case BinaryOperatorKind.LOGICAL_AND: return LOGICAL_AND; |
| 231 case BinaryOperatorKind.LOGICAL_OR: return LOGICAL_OR; |
| 232 case BinaryOperatorKind.IF_NULL: return IF_NULL; |
| 233 } |
| 234 } |
| 201 } | 235 } |
| 202 | 236 |
| 203 /// The operator !=, which is not user definable operator but instead is a | 237 /// The operator !=, which is not user definable operator but instead is a |
| 204 /// negation of a call to user definable operator, namely ==. | 238 /// negation of a call to user definable operator, namely ==. |
| 205 class _NotEqualsOperator extends BinaryOperator { | 239 class _NotEqualsOperator extends BinaryOperator { |
| 206 const _NotEqualsOperator() : super._(BinaryOperatorKind.NOT_EQ, '!='); | 240 const _NotEqualsOperator() : super._(BinaryOperatorKind.NOT_EQ, '!='); |
| 207 | 241 |
| 208 bool get isUserDefinable => false; | 242 bool get isUserDefinable => false; |
| 209 | 243 |
| 210 String get selectorName => '=='; | 244 String get selectorName => '=='; |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 const IncDecOperator._(IncDecOperatorKind.DEC, '--', BinaryOperator.SUB); | 407 const IncDecOperator._(IncDecOperatorKind.DEC, '--', BinaryOperator.SUB); |
| 374 | 408 |
| 375 static IncDecOperator parse(String value) { | 409 static IncDecOperator parse(String value) { |
| 376 switch (value) { | 410 switch (value) { |
| 377 case '++': return INC; | 411 case '++': return INC; |
| 378 case '--': return DEC; | 412 case '--': return DEC; |
| 379 default: return null; | 413 default: return null; |
| 380 } | 414 } |
| 381 } | 415 } |
| 382 } | 416 } |
| OLD | NEW |