43972
|
1 |
/*
|
|
2 |
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
package org.graalvm.compiler.core.common.calc;
|
|
24 |
|
|
25 |
import org.graalvm.compiler.debug.GraalError;
|
|
26 |
|
|
27 |
import jdk.vm.ci.meta.Constant;
|
|
28 |
import jdk.vm.ci.meta.ConstantReflectionProvider;
|
|
29 |
import jdk.vm.ci.meta.JavaConstant;
|
|
30 |
import jdk.vm.ci.meta.PrimitiveConstant;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Condition codes used in conditionals.
|
|
34 |
*/
|
|
35 |
public enum Condition {
|
|
36 |
/**
|
|
37 |
* Equal.
|
|
38 |
*/
|
|
39 |
EQ("=="),
|
|
40 |
|
|
41 |
/**
|
|
42 |
* Not equal.
|
|
43 |
*/
|
|
44 |
NE("!="),
|
|
45 |
|
|
46 |
/**
|
|
47 |
* Signed less than.
|
|
48 |
*/
|
|
49 |
LT("<"),
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Signed less than or equal.
|
|
53 |
*/
|
|
54 |
LE("<="),
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Signed greater than.
|
|
58 |
*/
|
|
59 |
GT(">"),
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Signed greater than or equal.
|
|
63 |
*/
|
|
64 |
GE(">="),
|
|
65 |
|
|
66 |
/**
|
|
67 |
* Unsigned greater than or equal ("above than or equal").
|
|
68 |
*/
|
|
69 |
AE("|>=|"),
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Unsigned less than or equal ("below than or equal").
|
|
73 |
*/
|
|
74 |
BE("|<=|"),
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Unsigned greater than ("above than").
|
|
78 |
*/
|
|
79 |
AT("|>|"),
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Unsigned less than ("below than").
|
|
83 |
*/
|
|
84 |
BT("|<|");
|
|
85 |
|
|
86 |
public final String operator;
|
|
87 |
|
|
88 |
Condition(String operator) {
|
|
89 |
this.operator = operator;
|
|
90 |
}
|
|
91 |
|
|
92 |
public boolean check(int left, int right) {
|
|
93 |
switch (this) {
|
|
94 |
case EQ:
|
|
95 |
return left == right;
|
|
96 |
case NE:
|
|
97 |
return left != right;
|
|
98 |
case LT:
|
|
99 |
return left < right;
|
|
100 |
case LE:
|
|
101 |
return left <= right;
|
|
102 |
case GT:
|
|
103 |
return left > right;
|
|
104 |
case GE:
|
|
105 |
return left >= right;
|
|
106 |
case AE:
|
|
107 |
return UnsignedMath.aboveOrEqual(left, right);
|
|
108 |
case BE:
|
|
109 |
return UnsignedMath.belowOrEqual(left, right);
|
|
110 |
case AT:
|
|
111 |
return UnsignedMath.aboveThan(left, right);
|
|
112 |
case BT:
|
|
113 |
return UnsignedMath.belowThan(left, right);
|
|
114 |
}
|
|
115 |
throw new IllegalArgumentException(this.toString());
|
|
116 |
}
|
|
117 |
|
48861
|
118 |
public static final class CanonicalizedCondition {
|
|
119 |
private final CanonicalCondition canonicalCondition;
|
|
120 |
private final boolean mirror;
|
|
121 |
private final boolean negate;
|
|
122 |
|
|
123 |
private CanonicalizedCondition(CanonicalCondition canonicalCondition, boolean mirror, boolean negate) {
|
|
124 |
this.canonicalCondition = canonicalCondition;
|
|
125 |
this.mirror = mirror;
|
|
126 |
this.negate = negate;
|
|
127 |
}
|
|
128 |
|
|
129 |
public CanonicalCondition getCanonicalCondition() {
|
|
130 |
return canonicalCondition;
|
|
131 |
}
|
|
132 |
|
|
133 |
public boolean mustMirror() {
|
|
134 |
return mirror;
|
|
135 |
}
|
|
136 |
|
|
137 |
public boolean mustNegate() {
|
|
138 |
return negate;
|
|
139 |
}
|
|
140 |
}
|
|
141 |
|
|
142 |
public CanonicalizedCondition canonicalize() {
|
|
143 |
CanonicalCondition canonicalCondition;
|
|
144 |
switch (this) {
|
|
145 |
case EQ:
|
|
146 |
case NE:
|
|
147 |
canonicalCondition = CanonicalCondition.EQ;
|
|
148 |
break;
|
|
149 |
case LT:
|
|
150 |
case LE:
|
|
151 |
case GT:
|
|
152 |
case GE:
|
|
153 |
canonicalCondition = CanonicalCondition.LT;
|
|
154 |
break;
|
|
155 |
case BT:
|
|
156 |
case BE:
|
|
157 |
case AT:
|
|
158 |
case AE:
|
|
159 |
canonicalCondition = CanonicalCondition.BT;
|
|
160 |
break;
|
|
161 |
default:
|
|
162 |
throw new IllegalArgumentException(this.toString());
|
|
163 |
}
|
|
164 |
return new CanonicalizedCondition(canonicalCondition, canonicalMirror(), canonicalNegate());
|
|
165 |
}
|
|
166 |
|
43972
|
167 |
/**
|
|
168 |
* Given a condition and its negation, this method returns true for one of the two and false for
|
|
169 |
* the other one. This can be used to keep comparisons in a canonical form.
|
|
170 |
*
|
|
171 |
* @return true if this condition is considered to be the canonical form, false otherwise.
|
|
172 |
*/
|
|
173 |
public boolean isCanonical() {
|
|
174 |
switch (this) {
|
|
175 |
case EQ:
|
|
176 |
return true;
|
|
177 |
case NE:
|
|
178 |
return false;
|
|
179 |
case LT:
|
|
180 |
return true;
|
|
181 |
case LE:
|
|
182 |
return false;
|
|
183 |
case GT:
|
|
184 |
return false;
|
|
185 |
case GE:
|
|
186 |
return false;
|
|
187 |
case BT:
|
|
188 |
return true;
|
|
189 |
case BE:
|
|
190 |
return false;
|
|
191 |
case AT:
|
|
192 |
return false;
|
|
193 |
case AE:
|
|
194 |
return false;
|
|
195 |
}
|
|
196 |
throw new IllegalArgumentException(this.toString());
|
|
197 |
}
|
|
198 |
|
|
199 |
/**
|
|
200 |
* Returns true if the condition needs to be mirrored to get to a canonical condition. The
|
|
201 |
* result of the mirroring operation might still need to be negated to achieve a canonical form.
|
|
202 |
*/
|
48861
|
203 |
private boolean canonicalMirror() {
|
43972
|
204 |
switch (this) {
|
|
205 |
case EQ:
|
|
206 |
return false;
|
|
207 |
case NE:
|
|
208 |
return false;
|
|
209 |
case LT:
|
|
210 |
return false;
|
|
211 |
case LE:
|
|
212 |
return true;
|
|
213 |
case GT:
|
|
214 |
return true;
|
|
215 |
case GE:
|
|
216 |
return false;
|
|
217 |
case BT:
|
|
218 |
return false;
|
|
219 |
case BE:
|
|
220 |
return true;
|
|
221 |
case AT:
|
|
222 |
return true;
|
|
223 |
case AE:
|
|
224 |
return false;
|
|
225 |
}
|
|
226 |
throw new IllegalArgumentException(this.toString());
|
|
227 |
}
|
|
228 |
|
|
229 |
/**
|
|
230 |
* Returns true if the condition needs to be negated to get to a canonical condition. The result
|
|
231 |
* of the negation might still need to be mirrored to achieve a canonical form.
|
|
232 |
*/
|
48861
|
233 |
private boolean canonicalNegate() {
|
43972
|
234 |
switch (this) {
|
|
235 |
case EQ:
|
|
236 |
return false;
|
|
237 |
case NE:
|
|
238 |
return true;
|
|
239 |
case LT:
|
|
240 |
return false;
|
|
241 |
case LE:
|
|
242 |
return true;
|
|
243 |
case GT:
|
|
244 |
return false;
|
|
245 |
case GE:
|
|
246 |
return true;
|
|
247 |
case BT:
|
|
248 |
return false;
|
|
249 |
case BE:
|
|
250 |
return true;
|
|
251 |
case AT:
|
|
252 |
return false;
|
|
253 |
case AE:
|
|
254 |
return true;
|
|
255 |
}
|
|
256 |
throw new IllegalArgumentException(this.toString());
|
|
257 |
}
|
|
258 |
|
|
259 |
/**
|
|
260 |
* Negate this conditional.
|
|
261 |
*
|
|
262 |
* @return the condition that represents the negation
|
|
263 |
*/
|
|
264 |
public final Condition negate() {
|
|
265 |
switch (this) {
|
|
266 |
case EQ:
|
|
267 |
return NE;
|
|
268 |
case NE:
|
|
269 |
return EQ;
|
|
270 |
case LT:
|
|
271 |
return GE;
|
|
272 |
case LE:
|
|
273 |
return GT;
|
|
274 |
case GT:
|
|
275 |
return LE;
|
|
276 |
case GE:
|
|
277 |
return LT;
|
|
278 |
case BT:
|
|
279 |
return AE;
|
|
280 |
case BE:
|
|
281 |
return AT;
|
|
282 |
case AT:
|
|
283 |
return BE;
|
|
284 |
case AE:
|
|
285 |
return BT;
|
|
286 |
}
|
|
287 |
throw new IllegalArgumentException(this.toString());
|
|
288 |
}
|
|
289 |
|
|
290 |
public boolean implies(Condition other) {
|
|
291 |
if (other == this) {
|
|
292 |
return true;
|
|
293 |
}
|
|
294 |
switch (this) {
|
|
295 |
case EQ:
|
|
296 |
return other == LE || other == GE || other == BE || other == AE;
|
|
297 |
case NE:
|
|
298 |
return false;
|
|
299 |
case LT:
|
|
300 |
return other == LE || other == NE;
|
|
301 |
case LE:
|
|
302 |
return false;
|
|
303 |
case GT:
|
|
304 |
return other == GE || other == NE;
|
|
305 |
case GE:
|
|
306 |
return false;
|
|
307 |
case BT:
|
|
308 |
return other == BE || other == NE;
|
|
309 |
case BE:
|
|
310 |
return false;
|
|
311 |
case AT:
|
|
312 |
return other == AE || other == NE;
|
|
313 |
case AE:
|
|
314 |
return false;
|
|
315 |
}
|
|
316 |
throw new IllegalArgumentException(this.toString());
|
|
317 |
}
|
|
318 |
|
|
319 |
/**
|
|
320 |
* Mirror this conditional (i.e. commute "a op b" to "b op' a")
|
|
321 |
*
|
|
322 |
* @return the condition representing the equivalent commuted operation
|
|
323 |
*/
|
|
324 |
public final Condition mirror() {
|
|
325 |
switch (this) {
|
|
326 |
case EQ:
|
|
327 |
return EQ;
|
|
328 |
case NE:
|
|
329 |
return NE;
|
|
330 |
case LT:
|
|
331 |
return GT;
|
|
332 |
case LE:
|
|
333 |
return GE;
|
|
334 |
case GT:
|
|
335 |
return LT;
|
|
336 |
case GE:
|
|
337 |
return LE;
|
|
338 |
case BT:
|
|
339 |
return AT;
|
|
340 |
case BE:
|
|
341 |
return AE;
|
|
342 |
case AT:
|
|
343 |
return BT;
|
|
344 |
case AE:
|
|
345 |
return BE;
|
|
346 |
}
|
|
347 |
throw new IllegalArgumentException();
|
|
348 |
}
|
|
349 |
|
|
350 |
/**
|
|
351 |
* Returns true if this condition represents an unsigned comparison. EQ and NE are not
|
|
352 |
* considered to be unsigned.
|
|
353 |
*/
|
|
354 |
public final boolean isUnsigned() {
|
|
355 |
return this == Condition.BT || this == Condition.BE || this == Condition.AT || this == Condition.AE;
|
|
356 |
}
|
|
357 |
|
|
358 |
/**
|
|
359 |
* Checks if this conditional operation is commutative.
|
|
360 |
*
|
|
361 |
* @return {@code true} if this operation is commutative
|
|
362 |
*/
|
|
363 |
public final boolean isCommutative() {
|
|
364 |
return this == EQ || this == NE;
|
|
365 |
}
|
|
366 |
|
|
367 |
/**
|
|
368 |
* Attempts to fold a comparison between two constants and return the result.
|
|
369 |
*
|
|
370 |
* @param lt the constant on the left side of the comparison
|
|
371 |
* @param rt the constant on the right side of the comparison
|
|
372 |
* @param constantReflection needed to compare constants
|
|
373 |
* @return {@link Boolean#TRUE} if the comparison is known to be true, {@link Boolean#FALSE} if
|
|
374 |
* the comparison is known to be false
|
|
375 |
*/
|
|
376 |
public boolean foldCondition(JavaConstant lt, JavaConstant rt, ConstantReflectionProvider constantReflection) {
|
|
377 |
assert !lt.getJavaKind().isNumericFloat() && !rt.getJavaKind().isNumericFloat();
|
|
378 |
return foldCondition(lt, rt, constantReflection, false);
|
|
379 |
}
|
|
380 |
|
|
381 |
/**
|
|
382 |
* Attempts to fold a comparison between two constants and return the result.
|
|
383 |
*
|
|
384 |
* @param lt the constant on the left side of the comparison
|
|
385 |
* @param rt the constant on the right side of the comparison
|
|
386 |
* @param constantReflection needed to compare constants
|
|
387 |
* @param unorderedIsTrue true if an undecided float comparison should result in "true"
|
|
388 |
* @return true if the comparison is known to be true, false if the comparison is known to be
|
|
389 |
* false
|
|
390 |
*/
|
|
391 |
public boolean foldCondition(Constant lt, Constant rt, ConstantReflectionProvider constantReflection, boolean unorderedIsTrue) {
|
|
392 |
if (lt instanceof PrimitiveConstant) {
|
|
393 |
PrimitiveConstant lp = (PrimitiveConstant) lt;
|
|
394 |
PrimitiveConstant rp = (PrimitiveConstant) rt;
|
46371
|
395 |
return foldCondition(lp, rp, unorderedIsTrue);
|
43972
|
396 |
} else {
|
|
397 |
Boolean equal = constantReflection.constantEquals(lt, rt);
|
|
398 |
if (equal == null) {
|
|
399 |
throw new GraalError("could not fold %s %s %s", lt, this, rt);
|
|
400 |
}
|
|
401 |
switch (this) {
|
|
402 |
case EQ:
|
|
403 |
return equal.booleanValue();
|
|
404 |
case NE:
|
|
405 |
return !equal.booleanValue();
|
|
406 |
default:
|
|
407 |
throw new GraalError("expected condition: %s", this);
|
|
408 |
}
|
|
409 |
}
|
|
410 |
}
|
|
411 |
|
46371
|
412 |
/**
|
|
413 |
* Attempts to fold a comparison between two primitive constants and return the result.
|
|
414 |
*
|
|
415 |
* @param lp the constant on the left side of the comparison
|
|
416 |
* @param rp the constant on the right side of the comparison
|
|
417 |
* @param unorderedIsTrue true if an undecided float comparison should result in "true"
|
|
418 |
* @return true if the comparison is known to be true, false if the comparison is known to be
|
|
419 |
* false
|
|
420 |
*/
|
|
421 |
public boolean foldCondition(PrimitiveConstant lp, PrimitiveConstant rp, boolean unorderedIsTrue) {
|
|
422 |
switch (lp.getJavaKind()) {
|
|
423 |
case Boolean:
|
|
424 |
case Byte:
|
|
425 |
case Char:
|
|
426 |
case Short:
|
|
427 |
case Int: {
|
|
428 |
int x = lp.asInt();
|
|
429 |
int y = rp.asInt();
|
|
430 |
switch (this) {
|
|
431 |
case EQ:
|
|
432 |
return x == y;
|
|
433 |
case NE:
|
|
434 |
return x != y;
|
|
435 |
case LT:
|
|
436 |
return x < y;
|
|
437 |
case LE:
|
|
438 |
return x <= y;
|
|
439 |
case GT:
|
|
440 |
return x > y;
|
|
441 |
case GE:
|
|
442 |
return x >= y;
|
|
443 |
case AE:
|
|
444 |
return UnsignedMath.aboveOrEqual(x, y);
|
|
445 |
case BE:
|
|
446 |
return UnsignedMath.belowOrEqual(x, y);
|
|
447 |
case AT:
|
|
448 |
return UnsignedMath.aboveThan(x, y);
|
|
449 |
case BT:
|
|
450 |
return UnsignedMath.belowThan(x, y);
|
|
451 |
default:
|
|
452 |
throw new GraalError("expected condition: %s", this);
|
|
453 |
}
|
|
454 |
}
|
|
455 |
case Long: {
|
|
456 |
long x = lp.asLong();
|
|
457 |
long y = rp.asLong();
|
|
458 |
switch (this) {
|
|
459 |
case EQ:
|
|
460 |
return x == y;
|
|
461 |
case NE:
|
|
462 |
return x != y;
|
|
463 |
case LT:
|
|
464 |
return x < y;
|
|
465 |
case LE:
|
|
466 |
return x <= y;
|
|
467 |
case GT:
|
|
468 |
return x > y;
|
|
469 |
case GE:
|
|
470 |
return x >= y;
|
|
471 |
case AE:
|
|
472 |
return UnsignedMath.aboveOrEqual(x, y);
|
|
473 |
case BE:
|
|
474 |
return UnsignedMath.belowOrEqual(x, y);
|
|
475 |
case AT:
|
|
476 |
return UnsignedMath.aboveThan(x, y);
|
|
477 |
case BT:
|
|
478 |
return UnsignedMath.belowThan(x, y);
|
|
479 |
default:
|
|
480 |
throw new GraalError("expected condition: %s", this);
|
|
481 |
}
|
|
482 |
}
|
|
483 |
case Float: {
|
|
484 |
float x = lp.asFloat();
|
|
485 |
float y = rp.asFloat();
|
|
486 |
if (Float.isNaN(x) || Float.isNaN(y)) {
|
|
487 |
return unorderedIsTrue;
|
|
488 |
}
|
|
489 |
switch (this) {
|
|
490 |
case EQ:
|
|
491 |
return x == y;
|
|
492 |
case NE:
|
|
493 |
return x != y;
|
|
494 |
case LT:
|
|
495 |
return x < y;
|
|
496 |
case LE:
|
|
497 |
return x <= y;
|
|
498 |
case GT:
|
|
499 |
return x > y;
|
|
500 |
case GE:
|
|
501 |
return x >= y;
|
|
502 |
default:
|
|
503 |
throw new GraalError("expected condition: %s", this);
|
|
504 |
}
|
|
505 |
}
|
|
506 |
case Double: {
|
|
507 |
double x = lp.asDouble();
|
|
508 |
double y = rp.asDouble();
|
|
509 |
if (Double.isNaN(x) || Double.isNaN(y)) {
|
|
510 |
return unorderedIsTrue;
|
|
511 |
}
|
|
512 |
switch (this) {
|
|
513 |
case EQ:
|
|
514 |
return x == y;
|
|
515 |
case NE:
|
|
516 |
return x != y;
|
|
517 |
case LT:
|
|
518 |
return x < y;
|
|
519 |
case LE:
|
|
520 |
return x <= y;
|
|
521 |
case GT:
|
|
522 |
return x > y;
|
|
523 |
case GE:
|
|
524 |
return x >= y;
|
|
525 |
default:
|
|
526 |
throw new GraalError("expected condition: %s", this);
|
|
527 |
}
|
|
528 |
}
|
|
529 |
default:
|
|
530 |
throw new GraalError("expected value kind %s while folding condition: %s", lp.getJavaKind(), this);
|
|
531 |
}
|
|
532 |
}
|
|
533 |
|
43972
|
534 |
public Condition join(Condition other) {
|
|
535 |
if (other == this) {
|
|
536 |
return this;
|
|
537 |
}
|
|
538 |
switch (this) {
|
|
539 |
case EQ:
|
|
540 |
if (other == LE || other == GE || other == BE || other == AE) {
|
|
541 |
return EQ;
|
|
542 |
} else {
|
|
543 |
return null;
|
|
544 |
}
|
|
545 |
case NE:
|
|
546 |
if (other == LT || other == GT || other == BT || other == AT) {
|
|
547 |
return other;
|
|
548 |
} else if (other == LE) {
|
|
549 |
return LT;
|
|
550 |
} else if (other == GE) {
|
|
551 |
return GT;
|
|
552 |
} else if (other == BE) {
|
|
553 |
return BT;
|
|
554 |
} else if (other == AE) {
|
|
555 |
return AT;
|
|
556 |
} else {
|
|
557 |
return null;
|
|
558 |
}
|
|
559 |
case LE:
|
|
560 |
if (other == GE || other == EQ) {
|
|
561 |
return EQ;
|
|
562 |
} else if (other == NE || other == LT) {
|
|
563 |
return LT;
|
|
564 |
} else {
|
|
565 |
return null;
|
|
566 |
}
|
|
567 |
case LT:
|
|
568 |
if (other == NE || other == LE) {
|
|
569 |
return LT;
|
|
570 |
} else {
|
|
571 |
return null;
|
|
572 |
}
|
|
573 |
case GE:
|
|
574 |
if (other == LE || other == EQ) {
|
|
575 |
return EQ;
|
|
576 |
} else if (other == NE || other == GT) {
|
|
577 |
return GT;
|
|
578 |
} else {
|
|
579 |
return null;
|
|
580 |
}
|
|
581 |
case GT:
|
|
582 |
if (other == NE || other == GE) {
|
|
583 |
return GT;
|
|
584 |
} else {
|
|
585 |
return null;
|
|
586 |
}
|
|
587 |
case BE:
|
|
588 |
if (other == AE || other == EQ) {
|
|
589 |
return EQ;
|
|
590 |
} else if (other == NE || other == BT) {
|
|
591 |
return BT;
|
|
592 |
} else {
|
|
593 |
return null;
|
|
594 |
}
|
|
595 |
case BT:
|
|
596 |
if (other == NE || other == BE) {
|
|
597 |
return BT;
|
|
598 |
} else {
|
|
599 |
return null;
|
|
600 |
}
|
|
601 |
case AE:
|
|
602 |
if (other == BE || other == EQ) {
|
|
603 |
return EQ;
|
|
604 |
} else if (other == NE || other == AT) {
|
|
605 |
return AT;
|
|
606 |
} else {
|
|
607 |
return null;
|
|
608 |
}
|
|
609 |
case AT:
|
|
610 |
if (other == NE || other == AE) {
|
|
611 |
return AT;
|
|
612 |
} else {
|
|
613 |
return null;
|
|
614 |
}
|
|
615 |
}
|
|
616 |
throw new IllegalArgumentException(this.toString());
|
|
617 |
}
|
|
618 |
|
|
619 |
public Condition meet(Condition other) {
|
|
620 |
if (other == this) {
|
|
621 |
return this;
|
|
622 |
}
|
|
623 |
switch (this) {
|
|
624 |
case EQ:
|
|
625 |
if (other == LE || other == GE || other == BE || other == AE) {
|
|
626 |
return other;
|
|
627 |
} else if (other == LT) {
|
|
628 |
return LE;
|
|
629 |
} else if (other == GT) {
|
|
630 |
return GE;
|
|
631 |
} else if (other == BT) {
|
|
632 |
return BE;
|
|
633 |
} else if (other == AT) {
|
|
634 |
return AE;
|
|
635 |
} else {
|
|
636 |
return null;
|
|
637 |
}
|
|
638 |
case NE:
|
|
639 |
if (other == LT || other == GT || other == BT || other == AT) {
|
|
640 |
return NE;
|
|
641 |
} else {
|
|
642 |
return null;
|
|
643 |
}
|
|
644 |
case LE:
|
|
645 |
if (other == EQ || other == LT) {
|
|
646 |
return LE;
|
|
647 |
} else {
|
|
648 |
return null;
|
|
649 |
}
|
|
650 |
case LT:
|
|
651 |
if (other == EQ || other == LE) {
|
|
652 |
return LE;
|
|
653 |
} else if (other == NE || other == GT) {
|
|
654 |
return NE;
|
|
655 |
} else {
|
|
656 |
return null;
|
|
657 |
}
|
|
658 |
case GE:
|
|
659 |
if (other == EQ || other == GT) {
|
|
660 |
return GE;
|
|
661 |
} else {
|
|
662 |
return null;
|
|
663 |
}
|
|
664 |
case GT:
|
|
665 |
if (other == EQ || other == GE) {
|
|
666 |
return GE;
|
|
667 |
} else if (other == NE || other == LT) {
|
|
668 |
return NE;
|
|
669 |
} else {
|
|
670 |
return null;
|
|
671 |
}
|
|
672 |
case BE:
|
|
673 |
if (other == EQ || other == BT) {
|
|
674 |
return BE;
|
|
675 |
} else {
|
|
676 |
return null;
|
|
677 |
}
|
|
678 |
case BT:
|
|
679 |
if (other == EQ || other == BE) {
|
|
680 |
return BE;
|
|
681 |
} else if (other == NE || other == AT) {
|
|
682 |
return NE;
|
|
683 |
} else {
|
|
684 |
return null;
|
|
685 |
}
|
|
686 |
case AE:
|
|
687 |
if (other == EQ || other == AT) {
|
|
688 |
return AE;
|
|
689 |
} else {
|
|
690 |
return null;
|
|
691 |
}
|
|
692 |
case AT:
|
|
693 |
if (other == EQ || other == AE) {
|
|
694 |
return AE;
|
|
695 |
} else if (other == NE || other == BT) {
|
|
696 |
return NE;
|
|
697 |
} else {
|
|
698 |
return null;
|
|
699 |
}
|
|
700 |
}
|
|
701 |
throw new IllegalArgumentException(this.toString());
|
|
702 |
}
|
|
703 |
}
|