Package serp.bytecode
Class MethodInstruction
- java.lang.Object
-
- serp.bytecode.Instruction
-
- serp.bytecode.MethodInstruction
-
- All Implemented Interfaces:
BCEntity,VisitAcceptor
public class MethodInstruction extends Instruction
An instruction that invokes a method.- 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)MethodInstructions are equal if the method they reference is the same, or if the method of either is unset.intgetLogicalStackChange()Return the logical number of stack positions changed by this instruction.BCMethodgetMethod()Return the method this instruction operates on, or null if not set.BCClassgetMethodDeclarerBC()Return the declaring type of the method this instruction operates on, or null if not set.java.lang.StringgetMethodDeclarerName()Return the declaring type of the method this instruction operates on, or null if not set.java.lang.ClassgetMethodDeclarerType()Return the declaring type of the method this instruction operates on, or null if not set.intgetMethodIndex()Return the index in the classConstantPoolof theComplexEntrydescribing the method to operate on.java.lang.StringgetMethodName()Return the name of the method this instruction operates on, or null if not set.BCClass[]getMethodParamBCs()Return the param types of the method this instruction operates on, or empty array if none.java.lang.String[]getMethodParamNames()Return the param types of the method this instruction operates on, or empty array if none.java.lang.Class[]getMethodParamTypes()Return the param types of the method this instruction operates on, or empty array if none.BCClassgetMethodReturnBC()Return the return type of the method this instruction operates on, or null if not set.java.lang.StringgetMethodReturnName()Return the return type of the method this instruction operates on, or null if not set.java.lang.ClassgetMethodReturnType()Return the return type of the method this instruction operates on, or null if not set.intgetStackChange()Return the number of stack positions this instruction pushes or pops during its execution.MethodInstructionsetMethod(java.lang.Class dec, java.lang.String name, java.lang.Class returnType, java.lang.Class[] params)Set the method this instruction operates on.MethodInstructionsetMethod(java.lang.reflect.Constructor method)Set the method this instruction operates on.MethodInstructionsetMethod(java.lang.reflect.Method method)Set the method this instruction operates on.MethodInstructionsetMethod(java.lang.String name, java.lang.Class returnType, java.lang.Class[] params)Set the method this instruction operates on, for methods that are declared by the current class.MethodInstructionsetMethod(java.lang.String name, java.lang.String returnType, java.lang.String[] params)Set the method this instruction operates on, for methods that are declared by the current class.MethodInstructionsetMethod(java.lang.String dec, java.lang.String name, java.lang.String returnType, java.lang.String[] params)Set the method this instruction operates on.MethodInstructionsetMethod(java.lang.String name, BCClass returnType, BCClass[] params)Set the method this instruction operates on, for methods that are declared by the current class.MethodInstructionsetMethod(BCClass dec, java.lang.String name, BCClass returnType, BCClass[] params)Set the method this instruction operates on.MethodInstructionsetMethod(BCMethod method)Set the method this instruction operates on.MethodInstructionsetMethodDeclarer(java.lang.Class type)Set the declaring type of the method this instruction operates on.MethodInstructionsetMethodDeclarer(java.lang.String type)Set the declaring type of the method this instruction operates on.MethodInstructionsetMethodDeclarer(BCClass type)Set the declaring type of the method this instruction operates on.MethodInstructionsetMethodIndex(int index)Set the index in the classConstantPoolof theComplexEntrydescribing the method to operate on.MethodInstructionsetMethodName(java.lang.String name)Set the name of the method this instruction operates on.voidsetMethodParams(java.lang.Class[] types)Set the param types of the method this instruction operates on.MethodInstructionsetMethodParams(java.lang.String[] types)Set the param types of the method this instruction operates on.voidsetMethodParams(BCClass[] types)Set the param types of the method this instruction operates on.MethodInstructionsetMethodReturn(java.lang.Class type)Set the return type of the method this instruction operates on.MethodInstructionsetMethodReturn(java.lang.String type)Set the return type of the method this instruction operates on.MethodInstructionsetMethodReturn(BCClass type)Set the return type of the method this instruction operates on.-
Methods inherited from class serp.bytecode.Instruction
getByteIndex, getClassLoader, getCode, getLineNumber, getName, getOpcode, getPool, getProject, isValid
-
-
-
-
Method Detail
-
getLogicalStackChange
public int getLogicalStackChange()
Description copied from class:InstructionReturn the logical number of stack positions changed by this instruction. In other words, ignore weirdness with longs and doubles taking two stack positions.- Overrides:
getLogicalStackChangein classInstruction
-
getStackChange
public int getStackChange()
Description copied from class:InstructionReturn the number of stack positions this instruction pushes or pops during its execution.- Overrides:
getStackChangein 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 classConstantPoolof theComplexEntrydescribing the method to operate on.
-
setMethodIndex
public MethodInstruction setMethodIndex(int index)
Set the index in the classConstantPoolof theComplexEntrydescribing the method to operate on.- Returns:
- this instruction, for method chaining
-
getMethod
public BCMethod getMethod()
Return the method this instruction operates on, or null if not set.
-
setMethod
public MethodInstruction setMethod(BCMethod method)
Set the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethod
public MethodInstruction setMethod(java.lang.reflect.Method method)
Set the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethod
public MethodInstruction setMethod(java.lang.reflect.Constructor method)
Set the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethod
public MethodInstruction setMethod(java.lang.String dec, java.lang.String name, java.lang.String returnType, java.lang.String[] params)
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
public MethodInstruction setMethod(java.lang.String name, java.lang.String returnType, java.lang.String[] params)
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
public MethodInstruction setMethod(java.lang.Class dec, java.lang.String name, java.lang.Class returnType, java.lang.Class[] params)
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
public MethodInstruction setMethod(java.lang.String name, java.lang.Class returnType, java.lang.Class[] params)
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
public MethodInstruction setMethod(BCClass dec, java.lang.String name, BCClass returnType, BCClass[] params)
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
public MethodInstruction setMethod(java.lang.String name, BCClass returnType, BCClass[] params)
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
public java.lang.String getMethodName()
Return the name of the method this instruction operates on, or null if not set.
-
setMethodName
public MethodInstruction setMethodName(java.lang.String name)
Set the name of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
getMethodReturnName
public java.lang.String getMethodReturnName()
Return the return type of the method this instruction operates on, or null if not set.
-
getMethodReturnType
public java.lang.Class getMethodReturnType()
Return the return type of the method this instruction operates on, or null if not set.
-
getMethodReturnBC
public BCClass getMethodReturnBC()
Return the return type of the method this instruction operates on, or null if not set.
-
setMethodReturn
public MethodInstruction setMethodReturn(java.lang.String type)
Set the return type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodReturn
public MethodInstruction setMethodReturn(java.lang.Class type)
Set the return type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodReturn
public MethodInstruction setMethodReturn(BCClass type)
Set the return type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
getMethodParamNames
public java.lang.String[] getMethodParamNames()
Return the param types of the method this instruction operates on, or empty array if none.
-
getMethodParamTypes
public java.lang.Class[] getMethodParamTypes()
Return the param types of the method this instruction operates on, or empty array if none.
-
getMethodParamBCs
public BCClass[] getMethodParamBCs()
Return the param types of the method this instruction operates on, or empty array if none.
-
setMethodParams
public MethodInstruction setMethodParams(java.lang.String[] types)
Set the param types of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodParams
public void setMethodParams(java.lang.Class[] types)
Set the param types of the method this instruction operates on.
-
setMethodParams
public void setMethodParams(BCClass[] types)
Set the param types of the method this instruction operates on.
-
getMethodDeclarerName
public java.lang.String getMethodDeclarerName()
Return the declaring type of the method this instruction operates on, or null if not set.
-
getMethodDeclarerType
public java.lang.Class getMethodDeclarerType()
Return the declaring type of the method this instruction operates on, or null if not set.
-
getMethodDeclarerBC
public BCClass getMethodDeclarerBC()
Return the declaring type of the method this instruction operates on, or null if not set.
-
setMethodDeclarer
public MethodInstruction setMethodDeclarer(java.lang.String type)
Set the declaring type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodDeclarer
public MethodInstruction setMethodDeclarer(java.lang.Class type)
Set the declaring type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
setMethodDeclarer
public MethodInstruction setMethodDeclarer(BCClass type)
Set the declaring type of the method this instruction operates on.- Returns:
- this instruction, for method chaining
-
equalsInstruction
public boolean equalsInstruction(Instruction other)
MethodInstructions are equal if the method they reference is the same, or if the method of either is unset.- Overrides:
equalsInstructionin classInstruction
-
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- Overrides:
acceptVisitin classInstruction
-
-