Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: pkg/front_end/lib/src/fasta/operator.dart

Issue 2684933002: Add enum for user-definable operators. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698