001    package serp.bytecode;
002    
003    import serp.bytecode.visitor.*;
004    
005    /**
006     * Loads a value from a field onto the stack.
007     *
008     * @author Abe White
009     */
010    public class GetFieldInstruction extends FieldInstruction {
011        GetFieldInstruction(Code owner, int opcode) {
012            super(owner, opcode);
013        }
014    
015        public int getLogicalStackChange() {
016            if (getOpcode() == Constants.GETSTATIC)
017                return 1;
018            return 0;
019        }
020    
021        public int getStackChange() {
022            String type = getFieldTypeName();
023            if (type == null)
024                return 0;
025    
026            int stack = 0;
027            if (long.class.getName().equals(type) 
028                || double.class.getName().equals(type))
029                stack++;
030            if (getOpcode() == Constants.GETSTATIC)
031                stack++;
032            return stack;
033        }
034    
035        public void acceptVisit(BCVisitor visit) {
036            visit.enterGetFieldInstruction(this);
037            visit.exitGetFieldInstruction(this);
038        }
039    }