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

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

Issue 2680323002: Handle operators correctly. (Closed)
Patch Set: Rename Operator.index to Operator.indexGet. 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 | pkg/front_end/lib/src/fasta/source/outline_builder.dart » ('j') | 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,
12 bitwiseAnd,
13 bitwiseNot,
14 bitwiseOr,
15 bitwiseXor,
16 divide,
17 equals,
18 greaterThan,
19 greaterThanEquals,
20 indexGet,
21 indexSet,
22 leftShift,
23 lessThan,
24 lessThanEquals,
25 modulo,
26 multiply,
27 rightShift,
28 subtract,
29 truncatingDivide,
30 unaryMinus,
31 }
32
33 Operator operatorFromString(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.indexGet;
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.modulo;
49 if (identical("*", string)) return Operator.multiply;
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;
54 return null;
55 }
56
57 String operatorToString(Operator operator) {
58 switch (operator) {
59 case Operator.add: return "+";
60 case Operator.bitwiseAnd: return "&";
61 case Operator.bitwiseNot: return "~";
62 case Operator.bitwiseOr: return "|";
63 case Operator.bitwiseXor: return "^";
64 case Operator.divide: return "/";
65 case Operator.equals: return "==";
66 case Operator.greaterThan: return ">";
67 case Operator.greaterThanEquals: return ">=";
68 case Operator.indexGet: return "[]";
69 case Operator.indexSet: return "[]=";
70 case Operator.leftShift: return "<<";
71 case Operator.lessThan: return "<";
72 case Operator.lessThanEquals: return "<=";
73 case Operator.modulo: return "%";
74 case Operator.multiply: return "*";
75 case Operator.rightShift: return ">>";
76 case Operator.subtract: return "-";
77 case Operator.truncatingDivide: return "~/";
78 case Operator.unaryMinus: return "unary-";
79 }
80 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/source/outline_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698