Package serp.bytecode
Class MethodInstruction
java.lang.Object
serp.bytecode.CodeEntry
serp.bytecode.Instruction
serp.bytecode.MethodInstruction
- All Implemented Interfaces:
BCEntity
,VisitAcceptor
An instruction that invokes a method.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
acceptVisit
(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.boolean
equalsInstruction
(Instruction other) MethodInstructions are equal if the method they reference is the same, or if the method of either is unset.(package private) int
Return the length in bytes of this opcode, including all arguments.int
Return the logical number of stack positions changed by this instruction.Return the method this instruction operates on, or null if not set.Return the declaring type of the method this instruction operates on, or null if not set.Return the declaring type of the method this instruction operates on, or null if not set.Return the declaring type of the method this instruction operates on, or null if not set.int
Return the index in the classConstantPool
of theComplexEntry
describing the method to operate on.Return the name of the method this instruction operates on, or null if not set.BCClass[]
Return the param types of the method this instruction operates on, or empty array if none.String[]
Return the param types of the method this instruction operates on, or empty array if none.Class[]
Return the param types of the method this instruction operates on, or empty array if none.Return the return type of the method this instruction operates on, or null if not set.Return the return type of the method this instruction operates on, or null if not set.Return the return type of the method this instruction operates on, or null if not set.int
Return the number of stack positions this instruction pushes or pops during its execution.(package private) void
Read the arguments for this opcode from the given stream.(package private) void
read
(Instruction orig) Copy the given instruction data.Set the method this instruction operates on.setMethod
(Constructor method) Set the method this instruction operates on.Set the method this instruction operates on.Set the method this instruction operates on, for methods that are declared by the current class.Set the method this instruction operates on, for methods that are declared by the current class.Set the method this instruction operates on.private MethodInstruction
Set the method this instruction operates on.Set the method this instruction operates on, for methods that are declared by the current class.Set the method this instruction operates on.Set the method this instruction operates on.setMethodDeclarer
(Class type) Set the declaring type of the method this instruction operates on.setMethodDeclarer
(String type) Set the declaring type of the method this instruction operates on.setMethodDeclarer
(BCClass type) Set the declaring type of the method this instruction operates on.setMethodIndex
(int index) Set the index in the classConstantPool
of theComplexEntry
describing the method to operate on.setMethodName
(String name) Set the name of the method this instruction operates on.void
setMethodParams
(Class[] types) Set the param types of the method this instruction operates on.setMethodParams
(String[] types) Set the param types of the method this instruction operates on.void
setMethodParams
(BCClass[] types) Set the param types of the method this instruction operates on.setMethodReturn
(Class type) Set the return type of the method this instruction operates on.setMethodReturn
(String type) Set the return type of the method this instruction operates on.setMethodReturn
(BCClass type) Set the return type of the method this instruction operates on.(package private) void
write
(DataOutput out) Write the arguments for this opcode to the given stream.Methods inherited from class serp.bytecode.Instruction
getByteIndex, getClassLoader, getCode, getLineNumber, getName, getOpcode, getPool, getProject, invalidate, invalidateByteIndexes, isValid, setOpcode
-
Field Details
-
_index
private int _index
-
-
Constructor Details
-
MethodInstruction
MethodInstruction(Code owner, int opcode)
-
-
Method Details
-
getLength
int getLength()Description copied from class:Instruction
Return the length in bytes of this opcode, including all arguments. For many opcodes this method relies on an up-to-date byte index.- Overrides:
getLength
in classInstruction
-
getLogicalStackChange
public int getLogicalStackChange()Description copied from class:Instruction
Return the logical number of stack positions changed by this instruction. In other words, ignore weirdness with longs and doubles taking two stack positions.- Overrides:
getLogicalStackChange
in classInstruction
-
getStackChange
public int getStackChange()Description copied from class:Instruction
Return the number of stack positions this instruction pushes or pops during its execution.- Overrides:
getStackChange
in classInstruction
- 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
-
getMethodIndex
public int getMethodIndex()Return the index in the classConstantPool
of theComplexEntry
describing the method to operate on. -
setMethodIndex
Set the index in the classConstantPool
of theComplexEntry
describing the method to operate on.- Returns:
- this instruction, for method chaining
-
getMethod
Return the method this instruction operates on, or null if not set. -
setMethod
Set the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethod
Set the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethod
Set the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethod
Set the method this instruction operates on.- Parameters:
dec
- the full class name of the method's declaring classname
- the method namereturnType
- the full class name of the method return typeparam
- the full class names of the method param types- Returns:
- this instruction, for method chaining
-
setMethod
private MethodInstruction setMethod(String dec, String name, String returnType, String[] params, boolean copy) Set the method this instruction operates on.- Parameters:
dec
- the full class name of the method's declaring class, or the bootstrap index for InvokeDynamicname
- the method namereturnType
- the full class name of the method return typecopy
- whether to copy the the parameter arrayparam
- the full class names of the method param types- Returns:
- this instruction, for method chaining
-
setMethod
Set the method this instruction operates on, for methods that are declared by the current class.- Parameters:
name
- the method namereturnType
- the full class name of the method return typeparam
- the full class names of the method param types- Returns:
- this instruction, for method chaining
-
setMethod
Set the method this instruction operates on.- Parameters:
dec
- the method's declaring classname
- the method namereturnType
- the class of the method return typeparam
- the class of the method param types- Returns:
- this instruction, for method chaining
-
setMethod
Set the method this instruction operates on, for methods that are declared by the current class.- Parameters:
name
- the method namereturnType
- the class of the method return typeparam
- the class of the method param types- Returns:
- this instruction, for method chaining
-
setMethod
Set the method this instruction operates on.- Parameters:
dec
- the method's declaring classname
- the method namereturnType
- the class of the method return typeparam
- the class of the method param types- Returns:
- this instruction, for method chaining
-
setMethod
Set the method this instruction operates on, for methods that are declared by the current class.- Parameters:
name
- the method namereturnType
- the class of the method return typeparam
- the class of the method param types- Returns:
- this instruction, for method chaining
-
getMethodName
Return the name of the method this instruction operates on, or null if not set. -
setMethodName
Set the name of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
getMethodReturnName
Return the return type of the method this instruction operates on, or null if not set. -
getMethodReturnType
Return the return type of the method this instruction operates on, or null if not set. -
getMethodReturnBC
Return the return type of the method this instruction operates on, or null if not set. -
setMethodReturn
Set the return type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodReturn
Set the return type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodReturn
Set the return type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
getMethodParamNames
Return the param types of the method this instruction operates on, or empty array if none. -
getMethodParamTypes
Return the param types of the method this instruction operates on, or empty array if none. -
getMethodParamBCs
Return the param types of the method this instruction operates on, or empty array if none. -
setMethodParams
Set the param types of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodParams
Set the param types of the method this instruction operates on. -
setMethodParams
Set the param types of the method this instruction operates on. -
getMethodDeclarerName
Return the declaring type of the method this instruction operates on, or null if not set. -
getMethodDeclarerType
Return the declaring type of the method this instruction operates on, or null if not set. -
getMethodDeclarerBC
Return the declaring type of the method this instruction operates on, or null if not set. -
setMethodDeclarer
Set the declaring type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodDeclarer
Set the declaring type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodDeclarer
Set the declaring type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
equalsInstruction
MethodInstructions are equal if the method they reference is the same, or if the method of either is unset.- Overrides:
equalsInstruction
in classInstruction
-
acceptVisit
Description copied from interface:VisitAcceptor
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.- Specified by:
acceptVisit
in interfaceVisitAcceptor
- Overrides:
acceptVisit
in classInstruction
-
read
Description copied from class:Instruction
Copy the given instruction data.- Overrides:
read
in classInstruction
-
read
Description copied from class:Instruction
Read the arguments for this opcode from the given stream. This method should be overridden by opcodes that take arguments.- Overrides:
read
in classInstruction
- Throws:
IOException
-
write
Description copied from class:Instruction
Write the arguments for this opcode to the given stream. This method should be overridden by opcodes that take arguments.- Overrides:
write
in classInstruction
- Throws:
IOException
-