Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library fasta.operators; | |
| 6 | |
| 7 /// The user-definable operators in Dart. | |
| 8 /// | |
| 9 /// The names have been chosen to represent their normal semantic meaning. | |
| 10 enum Operator { | |
| 11 Add, | |
|
Lasse Reichstein Nielsen
2017/02/08 13:15:45
Using UpperCamelCase is usually reserved for types
ahe
2017/02/08 14:03:37
I've been using CamelCase to avoid conflicts with
| |
| 12 BitwiseAnd, | |
|
ahe
2017/02/08 11:49:22
Note: I'm using "bitwise" prefix here because I th
Lasse Reichstein Nielsen
2017/02/08 13:15:46
Acknowledged.
| |
| 13 BitwiseNot, | |
| 14 BitwiseOr, | |
| 15 BitwiseXor, | |
| 16 Divide, | |
| 17 Equals, | |
| 18 GreaterThan, | |
| 19 GreaterThanEquals, | |
| 20 Index, | |
| 21 IndexSet, | |
| 22 LeftShift, | |
| 23 LessThan, | |
| 24 LessThanEquals, | |
| 25 Multiply, | |
| 26 Percent, | |
|
Lasse Reichstein Nielsen
2017/02/08 13:15:46
Should be Modulo
ahe
2017/02/08 14:03:37
Done.
| |
| 27 RightShift, | |
| 28 Subtract, | |
| 29 TruncatingDivide, | |
| 30 UnaryMinus, | |
| 31 } | |
| 32 | |
| 33 Operator fromString(String string) { | |
| 34 if (identical("+", string)) return Operator.Add; | |
| 35 if (identical("&", string)) return Operator.BitwiseAnd; | |
| 36 if (identical("~", string)) return Operator.BitwiseNot; | |
| 37 if (identical("|", string)) return Operator.BitwiseOr; | |
| 38 if (identical("^", string)) return Operator.BitwiseXor; | |
| 39 if (identical("/", string)) return Operator.Divide; | |
| 40 if (identical("==", string)) return Operator.Equals; | |
| 41 if (identical(">", string)) return Operator.GreaterThan; | |
| 42 if (identical(">=", string)) return Operator.GreaterThanEquals; | |
| 43 if (identical("[]", string)) return Operator.Index; | |
| 44 if (identical("[]=", string)) return Operator.IndexSet; | |
| 45 if (identical("<<", string)) return Operator.LeftShift; | |
| 46 if (identical("<", string)) return Operator.LessThan; | |
| 47 if (identical("<=", string)) return Operator.LessThanEquals; | |
| 48 if (identical("*", string)) return Operator.Multiply; | |
| 49 if (identical("%", string)) return Operator.Percent; | |
| 50 if (identical(">>", string)) return Operator.RightShift; | |
| 51 if (identical("-", string)) return Operator.Subtract; | |
| 52 if (identical("~/", string)) return Operator.TruncatingDivide; | |
| 53 if (identical("unary-", string)) return Operator.UnaryMinus; | |
|
Lasse Reichstein Nielsen
2017/02/08 13:15:45
Would a hash-map possibly be more efficient than l
ahe
2017/02/08 14:03:37
I'm concerned about performance here as well. My t
| |
| 54 return null; | |
| 55 } | |
| OLD | NEW |