19 * limitations under the License. |
19 * limitations under the License. |
20 */ |
20 */ |
21 |
21 |
22 package com.sun.org.apache.bcel.internal.generic; |
22 package com.sun.org.apache.bcel.internal.generic; |
23 |
23 |
24 |
|
25 import com.sun.org.apache.bcel.internal.classfile.ConstantPool; |
24 import com.sun.org.apache.bcel.internal.classfile.ConstantPool; |
26 import com.sun.org.apache.bcel.internal.classfile.ConstantUtf8; |
|
27 import com.sun.org.apache.bcel.internal.classfile.ConstantNameAndType; |
|
28 import com.sun.org.apache.bcel.internal.classfile.ConstantCP; |
|
29 import com.sun.org.apache.bcel.internal.classfile.*; |
|
30 |
25 |
31 /** |
26 /** |
32 * Super class for the GET/PUTxxx family of instructions. |
27 * Super class for the GET/PUTxxx family of instructions. |
33 * |
28 * |
34 * @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A> |
29 * @version $Id: FieldInstruction.java 1747278 2016-06-07 17:28:43Z britter $ |
35 */ |
30 */ |
36 public abstract class FieldInstruction extends FieldOrMethod |
31 public abstract class FieldInstruction extends FieldOrMethod { |
37 implements TypedInstruction { |
|
38 /** |
|
39 * Empty constructor needed for the Class.newInstance() statement in |
|
40 * Instruction.readInstruction(). Not to be used otherwise. |
|
41 */ |
|
42 FieldInstruction() {} |
|
43 |
32 |
44 /** |
33 /** |
45 * @param index to constant pool |
34 * Empty constructor needed for the Class.newInstance() statement in |
46 */ |
35 * Instruction.readInstruction(). Not to be used otherwise. |
47 protected FieldInstruction(short opcode, int index) { |
36 */ |
48 super(opcode, index); |
37 FieldInstruction() { |
49 } |
38 } |
50 |
39 |
51 /** |
|
52 * @return mnemonic for instruction with symbolic references resolved |
|
53 */ |
|
54 public String toString(ConstantPool cp) { |
|
55 return com.sun.org.apache.bcel.internal.Constants.OPCODE_NAMES[opcode] + " " + |
|
56 cp.constantToString(index, com.sun.org.apache.bcel.internal.Constants.CONSTANT_Fieldref); |
|
57 } |
|
58 |
40 |
59 /** @return size of field (1 or 2) |
41 /** |
60 */ |
42 * @param index to constant pool |
61 protected int getFieldSize(ConstantPoolGen cpg) { |
43 */ |
62 return getType(cpg).getSize(); |
44 protected FieldInstruction(final short opcode, final int index) { |
63 } |
45 super(opcode, index); |
|
46 } |
64 |
47 |
65 /** @return return type of referenced field |
|
66 */ |
|
67 public Type getType(ConstantPoolGen cpg) { |
|
68 return getFieldType(cpg); |
|
69 } |
|
70 |
48 |
71 /** @return type of field |
49 /** |
72 */ |
50 * @return mnemonic for instruction with symbolic references resolved |
73 public Type getFieldType(ConstantPoolGen cpg) { |
51 */ |
74 return Type.getType(getSignature(cpg)); |
52 @Override |
75 } |
53 public String toString( final ConstantPool cp ) { |
|
54 return com.sun.org.apache.bcel.internal.Const.getOpcodeName(super.getOpcode()) + " " |
|
55 + cp.constantToString(super.getIndex(), com.sun.org.apache.bcel.internal.Const.CONSTANT_Fieldref); |
|
56 } |
76 |
57 |
77 /** @return name of referenced field. |
58 |
78 */ |
59 /** @return size of field (1 or 2) |
79 public String getFieldName(ConstantPoolGen cpg) { |
60 */ |
80 return getName(cpg); |
61 protected int getFieldSize( final ConstantPoolGen cpg ) { |
81 } |
62 return Type.size(Type.getTypeSize(getSignature(cpg))); |
|
63 } |
|
64 |
|
65 |
|
66 /** @return return type of referenced field |
|
67 */ |
|
68 @Override |
|
69 public Type getType( final ConstantPoolGen cpg ) { |
|
70 return getFieldType(cpg); |
|
71 } |
|
72 |
|
73 |
|
74 /** @return type of field |
|
75 */ |
|
76 public Type getFieldType( final ConstantPoolGen cpg ) { |
|
77 return Type.getType(getSignature(cpg)); |
|
78 } |
|
79 |
|
80 |
|
81 /** @return name of referenced field. |
|
82 */ |
|
83 public String getFieldName( final ConstantPoolGen cpg ) { |
|
84 return getName(cpg); |
|
85 } |
82 } |
86 } |