Chromium Code Reviews| Index: pkg/front_end/lib/src/fasta/operator.dart |
| diff --git a/pkg/front_end/lib/src/fasta/operator.dart b/pkg/front_end/lib/src/fasta/operator.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6d83e097d47f3deb9342bd84a09e63faa3e79208 |
| --- /dev/null |
| +++ b/pkg/front_end/lib/src/fasta/operator.dart |
| @@ -0,0 +1,55 @@ |
| +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library fasta.operators; |
| + |
| +/// The user-definable operators in Dart. |
| +/// |
| +/// The names have been chosen to represent their normal semantic meaning. |
| +enum Operator { |
| + 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
|
| + 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.
|
| + BitwiseNot, |
| + BitwiseOr, |
| + BitwiseXor, |
| + Divide, |
| + Equals, |
| + GreaterThan, |
| + GreaterThanEquals, |
| + Index, |
| + IndexSet, |
| + LeftShift, |
| + LessThan, |
| + LessThanEquals, |
| + Multiply, |
| + Percent, |
|
Lasse Reichstein Nielsen
2017/02/08 13:15:46
Should be Modulo
ahe
2017/02/08 14:03:37
Done.
|
| + RightShift, |
| + Subtract, |
| + TruncatingDivide, |
| + UnaryMinus, |
| +} |
| + |
| +Operator fromString(String string) { |
| + if (identical("+", string)) return Operator.Add; |
| + if (identical("&", string)) return Operator.BitwiseAnd; |
| + if (identical("~", string)) return Operator.BitwiseNot; |
| + if (identical("|", string)) return Operator.BitwiseOr; |
| + if (identical("^", string)) return Operator.BitwiseXor; |
| + if (identical("/", string)) return Operator.Divide; |
| + if (identical("==", string)) return Operator.Equals; |
| + if (identical(">", string)) return Operator.GreaterThan; |
| + if (identical(">=", string)) return Operator.GreaterThanEquals; |
| + if (identical("[]", string)) return Operator.Index; |
| + if (identical("[]=", string)) return Operator.IndexSet; |
| + if (identical("<<", string)) return Operator.LeftShift; |
| + if (identical("<", string)) return Operator.LessThan; |
| + if (identical("<=", string)) return Operator.LessThanEquals; |
| + if (identical("*", string)) return Operator.Multiply; |
| + if (identical("%", string)) return Operator.Percent; |
| + if (identical(">>", string)) return Operator.RightShift; |
| + if (identical("-", string)) return Operator.Subtract; |
| + if (identical("~/", string)) return Operator.TruncatingDivide; |
| + 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
|
| + return null; |
| +} |