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/call_structure.dart' show CallStructure; | 8 import '../universe/call_structure.dart' show CallStructure; |
9 import '../universe/selector.dart' show Selector, SelectorKind; | 9 import '../universe/selector.dart' show Selector, SelectorKind; |
10 | 10 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 /// The binary | operator. | 182 /// The binary | operator. |
183 static const BinaryOperator LOGICAL_OR = | 183 static const BinaryOperator LOGICAL_OR = |
184 const _LogicalOperator(BinaryOperatorKind.LOGICAL_OR, '||'); | 184 const _LogicalOperator(BinaryOperatorKind.LOGICAL_OR, '||'); |
185 | 185 |
186 /// The if-null ?? operator. | 186 /// The if-null ?? operator. |
187 static const BinaryOperator IF_NULL = | 187 static const BinaryOperator IF_NULL = |
188 const _IfNullOperator(BinaryOperatorKind.IF_NULL, '??'); | 188 const _IfNullOperator(BinaryOperatorKind.IF_NULL, '??'); |
189 | 189 |
190 static BinaryOperator parse(String value) { | 190 static BinaryOperator parse(String value) { |
191 switch (value) { | 191 switch (value) { |
| 192 case '&&': |
| 193 return LOGICAL_AND; |
| 194 case '||': |
| 195 return LOGICAL_OR; |
| 196 case '??': |
| 197 return IF_NULL; |
| 198 default: |
| 199 return parseUserDefinable(value); |
| 200 } |
| 201 } |
| 202 |
| 203 static BinaryOperator parseUserDefinable(String value) { |
| 204 switch (value) { |
192 case '==': | 205 case '==': |
193 return EQ; | 206 return EQ; |
194 case '!=': | 207 case '!=': |
195 return NOT_EQ; | 208 return NOT_EQ; |
196 case '[]': | 209 case '[]': |
197 return INDEX; | 210 return INDEX; |
198 case '*': | 211 case '*': |
199 return MUL; | 212 return MUL; |
200 case '/': | 213 case '/': |
201 return DIV; | 214 return DIV; |
(...skipping 16 matching lines...) Expand all Loading... |
218 case '<=': | 231 case '<=': |
219 return LTEQ; | 232 return LTEQ; |
220 case '<': | 233 case '<': |
221 return LT; | 234 return LT; |
222 case '&': | 235 case '&': |
223 return AND; | 236 return AND; |
224 case '^': | 237 case '^': |
225 return XOR; | 238 return XOR; |
226 case '|': | 239 case '|': |
227 return OR; | 240 return OR; |
228 case '&&': | |
229 return LOGICAL_AND; | |
230 case '||': | |
231 return LOGICAL_OR; | |
232 case '??': | |
233 return IF_NULL; | |
234 default: | 241 default: |
235 return null; | 242 return null; |
236 } | 243 } |
237 } | 244 } |
238 | 245 |
239 // ignore: MISSING_RETURN | 246 // ignore: MISSING_RETURN |
240 static BinaryOperator fromKind(BinaryOperatorKind kind) { | 247 static BinaryOperator fromKind(BinaryOperatorKind kind) { |
241 switch (kind) { | 248 switch (kind) { |
242 case BinaryOperatorKind.EQ: | 249 case BinaryOperatorKind.EQ: |
243 return EQ; | 250 return EQ; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // ignore: MISSING_RETURN | 509 // ignore: MISSING_RETURN |
503 static IncDecOperator fromKind(IncDecOperatorKind kind) { | 510 static IncDecOperator fromKind(IncDecOperatorKind kind) { |
504 switch (kind) { | 511 switch (kind) { |
505 case IncDecOperatorKind.INC: | 512 case IncDecOperatorKind.INC: |
506 return INC; | 513 return INC; |
507 case IncDecOperatorKind.DEC: | 514 case IncDecOperatorKind.DEC: |
508 return DEC; | 515 return DEC; |
509 } | 516 } |
510 } | 517 } |
511 } | 518 } |
OLD | NEW |