OLD | NEW |
---|---|
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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 fasta.operators; | 5 library fasta.operators; |
6 | 6 |
7 /// The user-definable operators in Dart. | 7 /// The user-definable operators in Dart. |
8 /// | 8 /// |
9 /// The names have been chosen to represent their normal semantic meaning. | 9 /// The names have been chosen to represent their normal semantic meaning. |
10 enum Operator { | 10 enum Operator { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 return ">>"; | 92 return ">>"; |
93 case Operator.subtract: | 93 case Operator.subtract: |
94 return "-"; | 94 return "-"; |
95 case Operator.truncatingDivide: | 95 case Operator.truncatingDivide: |
96 return "~/"; | 96 return "~/"; |
97 case Operator.unaryMinus: | 97 case Operator.unaryMinus: |
98 return "unary-"; | 98 return "unary-"; |
99 } | 99 } |
100 return null; | 100 return null; |
101 } | 101 } |
102 | |
103 int operatorRequiredArgumentCount(Operator operator) { | |
104 switch (operator) { | |
105 case Operator.add: | |
karlklose
2017/03/29 10:12:01
Consider combining the cases for operators with th
ahe
2017/03/29 10:55:00
Done.
| |
106 return 1; | |
107 case Operator.bitwiseAnd: | |
108 return 1; | |
109 case Operator.bitwiseNot: | |
110 return 0; | |
111 case Operator.bitwiseOr: | |
112 return 1; | |
113 case Operator.bitwiseXor: | |
114 return 1; | |
115 case Operator.divide: | |
116 return 1; | |
117 case Operator.equals: | |
118 return 1; | |
119 case Operator.greaterThan: | |
120 return 1; | |
121 case Operator.greaterThanEquals: | |
122 return 1; | |
123 case Operator.indexGet: | |
124 return 1; | |
125 case Operator.indexSet: | |
126 return 2; | |
127 case Operator.leftShift: | |
128 return 1; | |
129 case Operator.lessThan: | |
130 return 1; | |
131 case Operator.lessThanEquals: | |
132 return 1; | |
133 case Operator.modulo: | |
134 return 1; | |
135 case Operator.multiply: | |
136 return 1; | |
137 case Operator.rightShift: | |
138 return 1; | |
139 case Operator.subtract: | |
140 return 1; | |
141 case Operator.truncatingDivide: | |
142 return 1; | |
143 case Operator.unaryMinus: | |
144 return 0; | |
145 } | |
146 return -1; | |
karlklose
2017/03/29 10:12:01
Should this be an internal error?
ahe
2017/03/29 10:55:00
If feel its sufficient with the warnings you get f
| |
147 } | |
OLD | NEW |