1 package serp.bytecode; 2 3 import serp.bytecode.visitor.*; 4 5 /*** 6 * Loads a value from a field onto the stack. 7 * 8 * @author Abe White 9 */ 10 public class GetFieldInstruction extends FieldInstruction { 11 GetFieldInstruction(Code owner, int opcode) { 12 super(owner, opcode); 13 } 14 15 public int getLogicalStackChange() { 16 if (getOpcode() == Constants.GETSTATIC) 17 return 1; 18 return 0; 19 } 20 21 public int getStackChange() { 22 String type = getFieldTypeName(); 23 if (type == null) 24 return 0; 25 26 int stack = 0; 27 if (long.class.getName().equals(type) 28 || double.class.getName().equals(type)) 29 stack++; 30 if (getOpcode() == Constants.GETSTATIC) 31 stack++; 32 return stack; 33 } 34 35 public void acceptVisit(BCVisitor visit) { 36 visit.enterGetFieldInstruction(this); 37 visit.exitGetFieldInstruction(this); 38 } 39 }