Package serp.bytecode
Class Instruction
- java.lang.Object
-
- serp.bytecode.Instruction
-
- All Implemented Interfaces:
BCEntity,VisitAcceptor
- Direct Known Subclasses:
FieldInstruction,JumpInstruction,MethodInstruction,MonitorInstruction,TypedInstruction
public class Instruction extends java.lang.Object implements BCEntity, VisitAcceptor
An opcode in a method of a class.- Author:
- Abe White
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacceptVisit(BCVisitor visit)Accept a visit from aBCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.booleanequalsInstruction(Instruction other)Instructions are equal if their opcodes are the same.intgetByteIndex()Return the index in the method code byte block at which this opcode starts.java.lang.ClassLoadergetClassLoader()Return the class loader to use when loading related classes.CodegetCode()Return the code block that owns this instruction.LineNumbergetLineNumber()Return the line number of this instruction, or null if none.intgetLogicalStackChange()Return the logical number of stack positions changed by this instruction.java.lang.StringgetName()Return the name of this instruction.intgetOpcode()Return the opcode this instruction represents.ConstantPoolgetPool()Return the constant pool of the current class.ProjectgetProject()Return the project of the current class.intgetStackChange()Return the number of stack positions this instruction pushes or pops during its execution.booleanisValid()Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.
-
-
-
Method Detail
-
getCode
public Code getCode()
Return the code block that owns this instruction.
-
getName
public java.lang.String getName()
Return the name of this instruction.
-
getOpcode
public int getOpcode()
Return the opcode this instruction represents.
-
getByteIndex
public int getByteIndex()
Return the index in the method code byte block at which this opcode starts. Note that this information may be out of date if the code block has been modified since last read/written.
-
getLineNumber
public LineNumber getLineNumber()
Return the line number of this instruction, or null if none. This method is subject to the validity constraints ofgetByteIndex().
-
getLogicalStackChange
public int getLogicalStackChange()
Return the logical number of stack positions changed by this instruction. In other words, ignore weirdness with longs and doubles taking two stack positions.
-
getStackChange
public int getStackChange()
Return the number of stack positions this instruction pushes or pops during its execution.- Returns:
- 0 if the stack is not affected by this instruction, a positive number if it pushes onto the stack, and a negative number if it pops from the stack
-
equalsInstruction
public boolean equalsInstruction(Instruction other)
Instructions are equal if their opcodes are the same. Subclasses should override this method to perform a template comparison: instructions should compare equal to other instructions of the same type where the data is either the same or the data is unset.
-
getProject
public Project getProject()
Description copied from interface:BCEntityReturn the project of the current class.- Specified by:
getProjectin interfaceBCEntity
-
getPool
public ConstantPool getPool()
Description copied from interface:BCEntityReturn the constant pool of the current class.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:BCEntityReturn the class loader to use when loading related classes.- Specified by:
getClassLoaderin interfaceBCEntity
-
isValid
public boolean isValid()
Description copied from interface:BCEntityReturn false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.
-
acceptVisit
public void acceptVisit(BCVisitor visit)
Description copied from interface:VisitAcceptorAccept a visit from aBCVisitor, calling the appropriate methods to notify the visitor that it has entered this entity, and to provide it with the proper callbacks for each sub-entity owned by this one.- Specified by:
acceptVisitin interfaceVisitAcceptor
-
-