23 import com.sun.org.apache.bcel.internal.Const; |
23 import com.sun.org.apache.bcel.internal.Const; |
24 import com.sun.org.apache.bcel.internal.ExceptionConst; |
24 import com.sun.org.apache.bcel.internal.ExceptionConst; |
25 |
25 |
26 /** |
26 /** |
27 * GETFIELD - Fetch field from object |
27 * GETFIELD - Fetch field from object |
28 * <PRE>Stack: ..., objectref -> ..., value</PRE> OR |
28 * <PRE>Stack: ..., objectref -> ..., value</PRE> |
|
29 * OR |
29 * <PRE>Stack: ..., objectref -> ..., value.word1, value.word2</PRE> |
30 * <PRE>Stack: ..., objectref -> ..., value.word1, value.word2</PRE> |
30 * |
31 * |
31 * @version $Id: GETFIELD.java 1747278 2016-06-07 17:28:43Z britter $ |
32 * @version $Id$ |
32 */ |
33 */ |
33 public class GETFIELD extends FieldInstruction implements ExceptionThrower, StackConsumer, |
34 public class GETFIELD extends FieldInstruction implements ExceptionThrower, StackConsumer, |
34 StackProducer { |
35 StackProducer { |
35 |
36 |
36 /** |
37 /** |
37 * Empty constructor needed for the Class.newInstance() statement in |
38 * Empty constructor needed for Instruction.readInstruction. |
38 * Instruction.readInstruction(). Not to be used otherwise. |
39 * Not to be used otherwise. |
39 */ |
40 */ |
40 GETFIELD() { |
41 GETFIELD() { |
41 } |
42 } |
|
43 |
42 |
44 |
43 public GETFIELD(final int index) { |
45 public GETFIELD(final int index) { |
44 super(Const.GETFIELD, index); |
46 super(Const.GETFIELD, index); |
45 } |
47 } |
46 |
48 |
|
49 |
47 @Override |
50 @Override |
48 public int produceStack(final ConstantPoolGen cpg) { |
51 public int produceStack( final ConstantPoolGen cpg ) { |
49 return getFieldSize(cpg); |
52 return getFieldSize(cpg); |
50 } |
53 } |
|
54 |
51 |
55 |
52 @Override |
56 @Override |
53 public Class<?>[] getExceptions() { |
57 public Class<?>[] getExceptions() { |
54 return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, |
58 return ExceptionConst.createExceptions(ExceptionConst.EXCS.EXCS_FIELD_AND_METHOD_RESOLUTION, |
55 ExceptionConst.NULL_POINTER_EXCEPTION, |
59 ExceptionConst.NULL_POINTER_EXCEPTION, |
56 ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); |
60 ExceptionConst.INCOMPATIBLE_CLASS_CHANGE_ERROR); |
57 } |
61 } |
58 |
62 |
|
63 |
59 /** |
64 /** |
60 * Call corresponding visitor method(s). The order is: Call visitor methods |
65 * Call corresponding visitor method(s). The order is: |
61 * of implemented interfaces first, then call methods according to the class |
66 * Call visitor methods of implemented interfaces first, then |
62 * hierarchy in descending order, i.e., the most specific visitXXX() call |
67 * call methods according to the class hierarchy in descending order, |
63 * comes last. |
68 * i.e., the most specific visitXXX() call comes last. |
64 * |
69 * |
65 * @param v Visitor object |
70 * @param v Visitor object |
66 */ |
71 */ |
67 @Override |
72 @Override |
68 public void accept(final Visitor v) { |
73 public void accept( final Visitor v ) { |
69 v.visitExceptionThrower(this); |
74 v.visitExceptionThrower(this); |
70 v.visitStackConsumer(this); |
75 v.visitStackConsumer(this); |
71 v.visitStackProducer(this); |
76 v.visitStackProducer(this); |
72 v.visitTypedInstruction(this); |
77 v.visitTypedInstruction(this); |
73 v.visitLoadClass(this); |
78 v.visitLoadClass(this); |