1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.dexmaker;
18 
19 import com.android.dx.rop.code.Rop;
20 import com.android.dx.rop.code.Rops;
21 import com.android.dx.rop.type.TypeList;
22 
23 /**
24  * A comparison between two values of the same type.
25  */
26 public enum Comparison {
27 
28     /** {@code a < b}. Supports int only. */
LT()29     LT() {
30         @Override Rop rop(TypeList types) {
31             return Rops.opIfLt(types);
32         }
33     },
34 
35     /** {@code a <= b}. Supports int only. */
LE()36     LE() {
37         @Override Rop rop(TypeList types) {
38             return Rops.opIfLe(types);
39         }
40     },
41 
42     /** {@code a == b}. Supports int and reference types. */
EQ()43     EQ() {
44         @Override Rop rop(TypeList types) {
45             return Rops.opIfEq(types);
46         }
47     },
48 
49     /** {@code a >= b}. Supports int only. */
GE()50     GE() {
51         @Override Rop rop(TypeList types) {
52             return Rops.opIfGe(types);
53         }
54     },
55 
56     /** {@code a > b}. Supports int only. */
GT()57     GT() {
58         @Override Rop rop(TypeList types) {
59             return Rops.opIfGt(types);
60         }
61     },
62 
63     /** {@code a != b}. Supports int and reference types. */
NE()64     NE() {
65         @Override Rop rop(TypeList types) {
66             return Rops.opIfNe(types);
67         }
68     };
69 
rop(TypeList types)70     abstract Rop rop(TypeList types);
71 }
72