Debian Codegraph @

src/main/java/com/kenai/jnr/x86asm/Operand.java

raw
1 //
2 // Copyright (C) 2010 Wayne Meissner
3 // Copyright (c) 2008-2009, Petr Kobalicek <[email protected]>
4 //
5 // Permission is hereby granted, free of charge, to any person
6 // obtaining a copy of this software and associated documentation
7 // files (the "Software"), to deal in the Software without
8 // restriction, including without limitation the rights to use,
9 // copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following
12 // conditions:
13 //
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 // OTHER DEALINGS IN THE SOFTWARE.
25
26 package com.kenai.jnr.x86asm;
27
28 import static com.kenai.jnr.x86asm.OP.*;
29
30 @Deprecated
31 public class Operand {
32 private final int op;
33 private final int size;
34
35 public Operand(int op, int size) {
36 this.op = op;
37 this.size = size;
38 }
39
40
41 /** Return type of operand, see @c OP. */
42 public int op() {
43 return op;
44 }
45
46 public int size() {
47 return size;
48 }
49
50 /** Return @c true if operand is none (@c OP_NONE). */
51 public boolean isNone() {
52 return op() == OP_NONE;
53 }
54
55 /** Return @c true if operand is any (general purpose, mmx or sse) register (@c OP_REG). */
56 public boolean isReg() {
57 return op() == OP_REG;
58 }
59
60 /** Return @c true if operand is memory address (@c OP_MEM). */
61 public boolean isMem() {
62 return op() == OP_MEM;
63 }
64
65 /** Return @c true if operand is immediate (@c OP_IMM). */
66 public boolean isImm() {
67 return op() == OP_IMM;
68 }
69
70 /** Return @c true if operand is label (@c OP_LABEL). */
71 public boolean isLabel() {
72 return op() == OP_LABEL;
73 }
74
75 /** Return @c true if operand is any register or memory. */
76 public final boolean isRegMem() {
77 return isMem() || isReg();
78 }
79
80 public final boolean isRegCode(int code) {
81 return this instanceof BaseReg && ((BaseReg) this).code() == code;
82 }
83
84 public final boolean isRegType(int type) {
85 return this instanceof BaseReg && ((BaseReg) this).type() == type;
86 }
87
88 public final boolean isRegIndex(int index) {
89 return this instanceof BaseReg && ((BaseReg) this).index() == index;
90 }
91
92 /** @brief Return @c true if operand is register of @a regType type or memory. */
93 public final boolean isRegMem(int regType) {
94 return isMem() || isRegType(regType);
95 }
96 }