Class Code
- java.lang.Object
-
- serp.bytecode.Attributes
-
- serp.bytecode.Attribute
-
- serp.bytecode.Code
-
- All Implemented Interfaces:
BCEntity,VisitAcceptor
public class Code extends Attribute
Representation of a code block of a class. The methods of this class mimic those of the same name in theListIteratorclass. Note that the size and index information of the code block will change as opcodes are added.Code blocks are usually obtained from a
BCMethod, but can also be constructed via the default constructor. Blocks created this way can be used to provide template instructions to the various search/replace methods in this class.The code class contains methods named after most JVM instructions, each of which adds the matching opcode to the code block at the current iterator position. It also contains generic versions of various JVM instructions whose opcodes are not set until their properties are set with additional information. Almost all instruction types are able to 'morph' their opcode on the fly as the arguments to the instruction change. Thus the developer can initially call, for example, the
aloadopcode, but later change the type to load tointand the opcode will automatically morph to theiloadopcode.- Author:
- Abe White
-
-
Constructor Summary
Constructors Constructor Description Code()The public constructor is for creating template code modules that produceInstructions used in matching through the varioussearchandreplacemethods.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ArrayLoadInstructionaaload()Load an object array value onto the stack; theaaloadopcode.ArrayStoreInstructionaastore()Store an object value from the stack into an array; theaastoreopcode.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.Instructionadd(Instruction ins)Adds a copy of the given instruction.ExceptionHandleraddExceptionHandler()Add an exception handler to this code block.ExceptionHandleraddExceptionHandler(ExceptionHandler handler)Import the given exception handler from another code block.ExceptionHandleraddExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, java.lang.Class catchType)Add an exception handler to this code block.ExceptionHandleraddExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, java.lang.String catchType)Add an exception handler to this code block.ExceptionHandleraddExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, BCClass catchType)Add an exception handler to this code block.voidafter(int index)Place the iterator after the given list index.voidafter(Instruction ins)Position the iterator just after the given instruction.voidafterLast()Set the position of the instruction iterator to after the last opcode.LoadInstructionaload()Load an object local variable onto the stack.ClassInstructionanew()Create a new instance of an object; thenewopcode.ClassInstructionanewarray()Create a new instance of an object array; theanewopcode.ReturnInstructionareturn()Return an object from a method; theareturnopcode.Instructionarraylength()Get the length of an array on the stack; thearraylengthopcode.StoreInstructionastore()Store an object value from the stack into a local variable.Instructionathrow()Throw an exception; theathrowopcode.ArrayLoadInstructionbaload()Load a byte array value onto the stack; thebaloadopcode.ArrayStoreInstructionbastore()Store a byte value from the stack into an array; thebastoreopcode.voidbefore(int index)Place the iterator before the given list index.voidbefore(Instruction ins)Position the iterator just before the given instruction.voidbeforeFirst()Reset the position of the instruction iterator to the first opcode.voidcalculateMaxLocals()Calculate and set the number of locals needed based on the instructions used and the parameters of the method this code block is a part of.voidcalculateMaxStack()Calculate and set the maximum stack depth needed for the instructions used.ArrayLoadInstructioncaload()Load a char array value onto the stack; thecaloadopcode.ArrayStoreInstructioncastore()Store a char value from the stack into an array; thecastoreopcode.ClassInstructioncheckcast()Cast an object on the stack to another type; thecheckcastopcode.ClassConstantInstructionclassconstant()Load a class constant onto the stack.voidclearExceptionHandlers()Clear all exception handlers.ConstantInstructionconstant()Load some constant onto the stack.ConvertInstructionconvert()Convert the top stack value to another type.MathInstructiondadd()Add the top two stack double values; thedaddopcode.ArrayLoadInstructiondaload()Load a double array value onto the stack; thedaloadopcode.ArrayStoreInstructiondastore()Store a double value from the stack into an array; thedastoreopcode.CmpInstructiondcmpg()Compare the top two stack values; thedcmpgopcode.CmpInstructiondcmpl()Compare the top two stack values; thedcmplopcode.MathInstructionddiv()Divide the top two stack double values; theddivopcode.LoadInstructiondload()Load a double local variable onto the stack.MathInstructiondmul()Multiply the top two stack double values; thedmulopcode.MathInstructiondneg()Negate the top stack double value; thednegopcode.MathInstructiondrem()Take the remainder of the top two double stack values; thedremopcode.ReturnInstructiondreturn()Return a double from a method; thedreturnopcode.StoreInstructiondstore()Store a double value from the stack into a local variable.MathInstructiondsub()Subtract the top two stack double values; thedsubopcode.StackInstructiondup()Thedupopcode.StackInstructiondup2()Thedup2opcode.StackInstructiondup2x1()Thedup2x1opcode.StackInstructiondup2x2()Thedup2x2opcode.StackInstructiondupx1()Thedupx1opcode.StackInstructiondupx2()Thedupx2opcode.MathInstructionfadd()Add the top two stack float values; thefaddopcode.ArrayLoadInstructionfaload()Load a float array value onto the stack; thefaloadopcode.ArrayStoreInstructionfastore()Store a float value from the stack into an array; thefastoreopcode.CmpInstructionfcmpg()Compare the top two stack values; thefcmpgopcode.CmpInstructionfcmpl()Compare the top two stack values; thefcmplopcode.MathInstructionfdiv()Divide the top two stack float values; thefdivopcode.LoadInstructionfload()Load a float local variable onto the stack.MathInstructionfmul()Multiply the top two stack float values; thefmulopcode.MathInstructionfneg()Negate the top stack float value; thefnegopcode.MathInstructionfrem()Take the remainder of the top two float stack values; thefremopcode.ReturnInstructionfreturn()Return a float from a method; thefreturnopcode.StoreInstructionfstore()Store a float value from the stack into a local variable.MathInstructionfsub()Subtract the top two stack float values; thefsubopcode.ExceptionHandlergetExceptionHandler(java.lang.Class catchType)Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.ExceptionHandlergetExceptionHandler(java.lang.String catchType)Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.ExceptionHandlergetExceptionHandler(BCClass catchType)Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.ExceptionHandler[]getExceptionHandlers()Return the exception handlers active in this code block, or an empty array if none.ExceptionHandler[]getExceptionHandlers(java.lang.Class catchType)Return all exception handlers that catch the given exception type, or an empty array if none.ExceptionHandler[]getExceptionHandlers(java.lang.String catchType)Return all exception handlers that catch the given exception type, or an empty array if none.ExceptionHandler[]getExceptionHandlers(BCClass catchType)Return all exception handlers that catch the given exception type, or an empty array if none.GetFieldInstructiongetfield()Load the value from a field onto the stack; thegetfieldopcode.Instruction[]getInstructions()Return all the Instructions of this method.LineNumberTablegetLineNumberTable(boolean add)Return line number information for the code.intgetLocalsIndex(int paramIndex)Return the local variable index for the paramIndex'th parameter to the method.LocalVariableTablegetLocalVariableTable(boolean add)Return local variable information for the code.LocalVariableTypeTablegetLocalVariableTypeTable(boolean add)Return local variable generics information for the code.intgetMaxLocals()Return the maximum number of local variables (including params) set for this method.intgetMaxStack()Return the maximum stack depth set for this code block.BCMethodgetMethod()The owning method.intgetNextLocalsIndex()Return the next available local variable index.intgetParamsIndex(int localIndex)Return the parameter index for the given local index, or -1 if the given local does not reference a param.GetFieldInstructiongetstatic()Load the value from a static field onto the stack; thegetstaticopcode.JumpInstructiongo2()Thego2opcode.booleanhasNext()Return true if a subsequent call tonext()will return an instruction.booleanhasPrevious()Return true if a subsequent call toprevious()will return an instruction.MathInstructioniadd()Add the top two stack int values; theiaddopcode.ArrayLoadInstructioniaload()Load an int array value onto the stack; theialoadopcode.MathInstructioniand()Take the mathematical and of the top two stack int values; theiandopcode.ArrayStoreInstructioniastore()Store an int value from the stack into an array; theiastoreopcode.MathInstructionidiv()Divide the top two stack int values; theidivopcode.IfInstructionifacmpeq()Theifacmpeqopcode.IfInstructionifacmpne()Theifacmpneopcode.IfInstructionifeq()Theifeqopcode.IfInstructionifge()Theifgeopcode.IfInstructionifgt()Theifgtopcode.IfInstructionificmpeq()Theificmpeqopcode.IfInstructionificmpge()Theificmpgeopcode.IfInstructionificmpgt()Theificmpgtopcode.IfInstructionificmple()Theificmpleopcode.IfInstructionificmplt()Theificmpltopcode.IfInstructionificmpne()Theificmpneopcode.IfInstructionifle()Theifleopcode.IfInstructioniflt()Theifltopcode.IfInstructionifne()Theifneopcode.IfInstructionifnonnull()Theifnonnullopcode.IfInstructionifnull()Theifnullopcode.IIncInstructioniinc()Add theiincopcode.LoadInstructioniload()Load an int local variable onto the stack.MathInstructionimul()Multiply the top two stack int values; theimulopcode.MathInstructionineg()Negate the top stack int value; theinegopcode.MethodInstructioninvokedynamic()Invoke a dynamic method; theinvokedynamicopcode.MethodInstructioninvokeinterface()Invoke a method on an interface; theinvokeinterfaceopcode.MethodInstructioninvokespecial()Invoke a method non-virtually, as for constructors and superclass methods; theinvokespecialopcode.MethodInstructioninvokestatic()Invoke a static method; theinvokestaticopcode.MethodInstructioninvokevirtual()Invoke a virtual method; theinvokevirtualopcode.MathInstructionior()Take the mathematical or of the top two stack int values; theioropcode.MathInstructionirem()Take the remainder of the top two int stack values; theiremopcode.ReturnInstructionireturn()Return an int from a method; theireturnopcode.MathInstructionishl()Shift the top stack int values; theishlopcode.MathInstructionishr()Shift the top stack int values; theishropcode.ClassInstructionisinstance()Test if a stack object is an instance of a class; theinstanceofopcode.StoreInstructionistore()Store an int value from the stack into a local variable.MathInstructionisub()Subtract the top two stack int values; theisubopcode.MathInstructioniushr()Shift the top stack int values; theiushropcode.MathInstructionixor()Take the mathematical xor of the top two stack int values; theixoropcode.JumpInstructionjsr()Thejsropcode used in implementingfinallyclauses.MathInstructionladd()Add the top two stack long values; theladdopcode.ArrayLoadInstructionlaload()Load a long array value onto the stack; thelaloadopcode.MathInstructionland()Take the mathematical and of the top two stack long values; thelandopcode.ArrayStoreInstructionlastore()Store a long value from the stack into an array; thelastoreopcode.CmpInstructionlcmp()Compare the top two stack values; thelcmpopcode.MathInstructionldiv()Divide the top two stack long values; theldivopcode.java.util.ListIteratorlistIterator()Returns another listIterator view of the Instructions in this code block.LoadInstructionlload()Load a long local variable onto the stack.MathInstructionlmul()Multiply the top two stack long values; thelmulopcode.MathInstructionlneg()Negate the top stack long value; thelnegopcode.LookupSwitchInstructionlookupswitch()Thelookupswitchopcode.MathInstructionlor()Take the mathematical or of the top two stack long values; theloropcode.MathInstructionlrem()Take the remainder of the top two long stack values; thelremopcode.ReturnInstructionlreturn()Return a long from a method; thelreturnopcode.MathInstructionlshl()Shift the top stack long values; thelshlopcode.MathInstructionlshr()Shift the top stack long values; thelshropcode.StoreInstructionlstore()Store a long value from the stack into a local variable.MathInstructionlsub()Subtract the top two stack long values; thelsubopcode.MathInstructionlushr()Shift the top stack long values; thelushropcode.MathInstructionlxor()Take the mathematical xor of the top two stack long values; thelxoropcode.MathInstructionmath()Perform some math operation on the stack items.MonitorEnterInstructionmonitorenter()Themonitorenteropcode.MonitorExitInstructionmonitorexit()Themonitorexitopcode.MultiANewArrayInstructionmultianewarray()Create a new multidimensional array; themultianewarrayopcode.NewArrayInstructionnewarray()Create a new array of a primitive type; thenewarrayopcode.Instructionnext()Return the next instruction.intnextIndex()Return the index of the next instruction, orsize()if at end.Instructionnop()Add thenopopcode.StackInstructionpop()Thepopopcode.StackInstructionpop2()Thepop2opcode.Instructionprevious()Return the previous instruction.intpreviousIndex()Return the index of the previous instruction, or -1 if at beginning.PutFieldInstructionputfield()Place the value of a field onto the stack; theputfieldopcode.PutFieldInstructionputstatic()Place the value of a static field onto the stack; theputstaticopcode.voidremove()Remove the last iterated instruction.booleanremoveExceptionHandler(java.lang.Class catchType)Remove the exception handler that catches the given type.booleanremoveExceptionHandler(java.lang.String catchType)Remove the exception handler that catches the given type.booleanremoveExceptionHandler(BCClass catchType)Remove the exception handler that catches the given type.booleanremoveExceptionHandler(ExceptionHandler handler)Remove an exception handler from this code block.booleanremoveLineNumberTable()Remove the line number table for the code.booleanremoveLocalVariableTables()Remove the local variable table for the code.booleanremoveLocalVariableTypeTables()Remove the local variable type table for the code.intreplace(Instruction[] templates, Instruction[] with)Equivalent to looping over each given template/replacement pair and callingreplace(Instruction,Instruction)for each.intreplace(Instruction template, Instruction with)Replaces all the instructions in this code block that match the given template with the given instruction.RetInstructionret()Add theretopcode, used in implementingfinallyclauses.ArrayLoadInstructionsaload()Load a short array value onto the stack; thesaloadopcode.ArrayStoreInstructionsastore()Store a short value from the stack into an array; thesastoreopcode.booleansearchBackward(Instruction template)Find the closest previous instruction from the current iterator position that matches the given one, according to theObject.equals(java.lang.Object)methods of the instruction types.booleansearchForward(Instruction template)Find the next instruction from the current iterator position that matches the given one, according to theObject.equals(java.lang.Object)methods of the instruction types.Instructionset(Instruction ins)Replaces the last iterated instruction with a copy of the given one.voidsetExceptionHandlers(ExceptionHandler[] handlers)Set the exception handlers for this code block.voidsetMaxLocals(int max)Set the maximum number of local variables (including params) in this method.voidsetMaxStack(int max)Set the maximum stack depth for this code block.intsize()Return the number of instructions in the method.StackInstructionswap()Theswapopcode.TableSwitchInstructiontableswitch()Thetableswitchopcode.ReturnInstructionvreturn()Return void from a method; thereturnopcode.WideInstructionwide()Add thewideopcode.MathInstructionxadd()Add the top two stack values.ArrayLoadInstructionxaload()Load an array value onto the stack.MathInstructionxand()Take the mathematical and of the top two stack values.ArrayStoreInstructionxastore()Store a value from the stack into an array.CmpInstructionxcmp()Compare the top two stack values.MathInstructionxdiv()Divide the top two stack values.LoadInstructionxload()Load a local variable onto the stack.MathInstructionxmul()Multiply the top two stack values.MathInstructionxneg()Negate the top stack value.MathInstructionxor()Take the mathematical or of the top two stack values.MathInstructionxrem()Take the remainder of the top two stack values.ReturnInstructionxreturn()Return from a method.MathInstructionxshl()Shift the top stack values.MathInstructionxshr()Shift the top stack values.StoreInstructionxstore()Store a value from the stack into a local variable.MathInstructionxsub()Subtract the top two stack values.MathInstructionxushr()Shift the top stack values.MathInstructionxxor()Take the mathematical xor of the top two stack values.-
Methods inherited from class serp.bytecode.Attribute
getClassLoader, getName, getNameIndex, getOwner, getPool, getProject, isValid
-
Methods inherited from class serp.bytecode.Attributes
addAttribute, addAttribute, clearAttributes, getAttribute, getAttributes, getAttributes, removeAttribute, removeAttribute, setAttributes
-
-
-
-
Constructor Detail
-
Code
public Code()
The public constructor is for creating template code modules that produceInstructions used in matching through the varioussearchandreplacemethods.
-
-
Method Detail
-
getMethod
public BCMethod getMethod()
The owning method.
-
getMaxStack
public int getMaxStack()
Return the maximum stack depth set for this code block.
-
setMaxStack
public void setMaxStack(int max)
Set the maximum stack depth for this code block.
-
getMaxLocals
public int getMaxLocals()
Return the maximum number of local variables (including params) set for this method.
-
setMaxLocals
public void setMaxLocals(int max)
Set the maximum number of local variables (including params) in this method.
-
getLocalsIndex
public int getLocalsIndex(int paramIndex)
Return the local variable index for the paramIndex'th parameter to the method. Local variable indexes differ from parameter indexes because: a) non-static methods use the 0th local variable for the 'this' ptr, and b) double and long values occupy two spots in the local variable array. Returns -1 if the given index is not valid.
-
getParamsIndex
public int getParamsIndex(int localIndex)
Return the parameter index for the given local index, or -1 if the given local does not reference a param.- See Also:
getLocalsIndex(int)
-
getNextLocalsIndex
public int getNextLocalsIndex()
Return the next available local variable index.
-
calculateMaxLocals
public void calculateMaxLocals()
Calculate and set the number of locals needed based on the instructions used and the parameters of the method this code block is a part of.- See Also:
setMaxLocals(int)
-
calculateMaxStack
public void calculateMaxStack()
Calculate and set the maximum stack depth needed for the instructions used.- See Also:
setMaxStack(int)
-
getExceptionHandlers
public ExceptionHandler[] getExceptionHandlers()
Return the exception handlers active in this code block, or an empty array if none.
-
getExceptionHandler
public ExceptionHandler getExceptionHandler(java.lang.String catchType)
Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.
-
getExceptionHandler
public ExceptionHandler getExceptionHandler(java.lang.Class catchType)
Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.
-
getExceptionHandler
public ExceptionHandler getExceptionHandler(BCClass catchType)
Return the exception handler that catches the given exception type; if multiple handlers catch the given type, which is returned is undefined.
-
getExceptionHandlers
public ExceptionHandler[] getExceptionHandlers(java.lang.String catchType)
Return all exception handlers that catch the given exception type, or an empty array if none.
-
getExceptionHandlers
public ExceptionHandler[] getExceptionHandlers(java.lang.Class catchType)
Return all exception handlers that catch the given exception type, or an empty array if none.
-
getExceptionHandlers
public ExceptionHandler[] getExceptionHandlers(BCClass catchType)
Return all exception handlers that catch the given exception type, or an empty array if none.
-
setExceptionHandlers
public void setExceptionHandlers(ExceptionHandler[] handlers)
Set the exception handlers for this code block. This method is useful for importing all handlers from another code block. Set to null or empty array if none.
-
addExceptionHandler
public ExceptionHandler addExceptionHandler(ExceptionHandler handler)
Import the given exception handler from another code block.
-
addExceptionHandler
public ExceptionHandler addExceptionHandler()
Add an exception handler to this code block.
-
addExceptionHandler
public ExceptionHandler addExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, java.lang.String catchType)
Add an exception handler to this code block.- Parameters:
tryStart- the first instruction of the try {} blocktryEnd- the last instruction of the try {} blockhandlerStart- the first instruction of the catch {} blockcatchType- the type of exception being caught
-
addExceptionHandler
public ExceptionHandler addExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, java.lang.Class catchType)
Add an exception handler to this code block.- Parameters:
tryStart- the first instruction of the try {} blocktryEnd- the last instruction of the try {} blockhandlerStart- the first instruction of the catch {} blockcatchType- the type of exception being caught
-
addExceptionHandler
public ExceptionHandler addExceptionHandler(Instruction tryStart, Instruction tryEnd, Instruction handlerStart, BCClass catchType)
Add an exception handler to this code block.- Parameters:
tryStart- the first instruction of the try {} blocktryEnd- the last instruction of the try {} blockhandlerStart- the first instruction of the catch {} blockcatchType- the type of exception being caught
-
clearExceptionHandlers
public void clearExceptionHandlers()
Clear all exception handlers.
-
removeExceptionHandler
public boolean removeExceptionHandler(java.lang.String catchType)
Remove the exception handler that catches the given type.
-
removeExceptionHandler
public boolean removeExceptionHandler(java.lang.Class catchType)
Remove the exception handler that catches the given type.- Returns:
- true if the handler was removed, false otherwise
-
removeExceptionHandler
public boolean removeExceptionHandler(BCClass catchType)
Remove the exception handler that catches the given type.- Returns:
- true if the handler was removed, false otherwise
-
removeExceptionHandler
public boolean removeExceptionHandler(ExceptionHandler handler)
Remove an exception handler from this code block. The given handler must belong to this code block.
-
size
public int size()
Return the number of instructions in the method.
-
beforeFirst
public void beforeFirst()
Reset the position of the instruction iterator to the first opcode.
-
afterLast
public void afterLast()
Set the position of the instruction iterator to after the last opcode.
-
before
public void before(Instruction ins)
Position the iterator just before the given instruction. The instruction must belong to this method.
-
after
public void after(Instruction ins)
Position the iterator just after the given instruction. The instruction must belong to this method.
-
hasNext
public boolean hasNext()
Return true if a subsequent call tonext()will return an instruction.
-
hasPrevious
public boolean hasPrevious()
Return true if a subsequent call toprevious()will return an instruction.
-
next
public Instruction next()
Return the next instruction.
-
nextIndex
public int nextIndex()
Return the index of the next instruction, orsize()if at end.
-
previous
public Instruction previous()
Return the previous instruction.
-
previousIndex
public int previousIndex()
Return the index of the previous instruction, or -1 if at beginning.
-
before
public void before(int index)
Place the iterator before the given list index.
-
after
public void after(int index)
Place the iterator after the given list index.
-
searchForward
public boolean searchForward(Instruction template)
Find the next instruction from the current iterator position that matches the given one, according to theObject.equals(java.lang.Object)methods of the instruction types. This allows for matching based on template instructions, as the equals methods of most instructions return true if the information for the given instruction has not been filled in. If a match is found, the iterator is placed after the matching Instruction. If no match is found, moves the iterator toafterLast().- Returns:
- true if match found
-
searchBackward
public boolean searchBackward(Instruction template)
Find the closest previous instruction from the current iterator position that matches the given one, according to theObject.equals(java.lang.Object)methods of the instruction types. This allows for matching based on template instructions, as the equals methods of most instructions return true if the information for the given instruction has not been filled in. If a match is found, the iterator is placed before the matching Instruction. If no match is found, moves the iterator tobeforeFirst().- Returns:
- true if match found
-
add
public Instruction add(Instruction ins)
Adds a copy of the given instruction.- Returns:
- the newly added instruction
-
set
public Instruction set(Instruction ins)
Replaces the last iterated instruction with a copy of the given one. This method will also make sure that all jump points that referenced the old opcode are updated correctly.- Returns:
- the newly added instruction
- See Also:
ListIterator.set(E)
-
replace
public int replace(Instruction template, Instruction with)
Replaces all the instructions in this code block that match the given template with the given instruction. After this method, the iterator will beafterLast().- Returns:
- the number of substitutions made
-
replace
public int replace(Instruction[] templates, Instruction[] with)
Equivalent to looping over each given template/replacement pair and callingreplace(Instruction,Instruction)for each.
-
remove
public void remove()
Remove the last iterated instruction.- See Also:
ListIterator.remove()
-
classconstant
public ClassConstantInstruction classconstant()
Load a class constant onto the stack. For primitive types, this translates into a getstatic for the TYPE field of the primitive's wrapper type. For non-primitives, things get much more complex. Suffice it to say that the operation involves adding synthetic static fields and even methods to the class. Note that this instruction requires up to 3 stack positions to execute.
-
nop
public Instruction nop()
Add thenopopcode.
-
constant
public ConstantInstruction constant()
Load some constant onto the stack. TheConstantInstructiontype takes any constant and correctly translates it into the proper opcode, depending on the constant type and value. For example, if the constant value is set to 0L, the opcode will be set tolconst0.
-
xload
public LoadInstruction xload()
Load a local variable onto the stack. This instruction will result in anopuntil its type and local index are set.
-
iload
public LoadInstruction iload()
Load an int local variable onto the stack. This instruction will result in anopuntil its local index is set.
-
lload
public LoadInstruction lload()
Load a long local variable onto the stack. This instruction will result in anopuntil its local index is set.
-
fload
public LoadInstruction fload()
Load a float local variable onto the stack. This instruction will result in anopuntil its local index is set.
-
dload
public LoadInstruction dload()
Load a double local variable onto the stack. This instruction will result in anopuntil its local index is set.
-
aload
public LoadInstruction aload()
Load an object local variable onto the stack. This instruction will result in anopuntil its local index is set.
-
xstore
public StoreInstruction xstore()
Store a value from the stack into a local variable. This instruction will result in anopuntil its type and local index are set.
-
istore
public StoreInstruction istore()
Store an int value from the stack into a local variable. This instruction will result in anopuntil its local index is set.
-
lstore
public StoreInstruction lstore()
Store a long value from the stack into a local variable. This instruction will resultin anopuntil its local index is set.
-
fstore
public StoreInstruction fstore()
Store a float value from the stack into a local variable. This instruction will result in anopuntil its local index is set.
-
dstore
public StoreInstruction dstore()
Store a double value from the stack into a local variable. This instruction will result in anopuntil its local index is set.
-
astore
public StoreInstruction astore()
Store an object value from the stack into a local variable. This instruction will result in anopuntil its local index is set.
-
ret
public RetInstruction ret()
Add theretopcode, used in implementingfinallyclauses.
-
iinc
public IIncInstruction iinc()
Add theiincopcode.
-
wide
public WideInstruction wide()
Add thewideopcode.
-
xaload
public ArrayLoadInstruction xaload()
Load an array value onto the stack. This instruction will result in anopuntil its type is set.
-
iaload
public ArrayLoadInstruction iaload()
Load an int array value onto the stack; theialoadopcode.
-
laload
public ArrayLoadInstruction laload()
Load a long array value onto the stack; thelaloadopcode.
-
faload
public ArrayLoadInstruction faload()
Load a float array value onto the stack; thefaloadopcode.
-
daload
public ArrayLoadInstruction daload()
Load a double array value onto the stack; thedaloadopcode.
-
aaload
public ArrayLoadInstruction aaload()
Load an object array value onto the stack; theaaloadopcode.
-
baload
public ArrayLoadInstruction baload()
Load a byte array value onto the stack; thebaloadopcode.
-
caload
public ArrayLoadInstruction caload()
Load a char array value onto the stack; thecaloadopcode.
-
saload
public ArrayLoadInstruction saload()
Load a short array value onto the stack; thesaloadopcode.
-
xastore
public ArrayStoreInstruction xastore()
Store a value from the stack into an array. This instruction will result in anopuntil its type is set.
-
iastore
public ArrayStoreInstruction iastore()
Store an int value from the stack into an array; theiastoreopcode.
-
lastore
public ArrayStoreInstruction lastore()
Store a long value from the stack into an array; thelastoreopcode.
-
fastore
public ArrayStoreInstruction fastore()
Store a float value from the stack into an array; thefastoreopcode.
-
dastore
public ArrayStoreInstruction dastore()
Store a double value from the stack into an array; thedastoreopcode.
-
aastore
public ArrayStoreInstruction aastore()
Store an object value from the stack into an array; theaastoreopcode.
-
bastore
public ArrayStoreInstruction bastore()
Store a byte value from the stack into an array; thebastoreopcode.
-
castore
public ArrayStoreInstruction castore()
Store a char value from the stack into an array; thecastoreopcode.
-
sastore
public ArrayStoreInstruction sastore()
Store a short value from the stack into an array; thesastoreopcode.
-
pop
public StackInstruction pop()
Thepopopcode.
-
pop2
public StackInstruction pop2()
Thepop2opcode.
-
dup
public StackInstruction dup()
Thedupopcode.
-
dupx1
public StackInstruction dupx1()
Thedupx1opcode.
-
dupx2
public StackInstruction dupx2()
Thedupx2opcode.
-
dup2
public StackInstruction dup2()
Thedup2opcode.
-
dup2x1
public StackInstruction dup2x1()
Thedup2x1opcode.
-
dup2x2
public StackInstruction dup2x2()
Thedup2x2opcode.
-
swap
public StackInstruction swap()
Theswapopcode.
-
math
public MathInstruction math()
Perform some math operation on the stack items. This instruction will result in anopuntil its operation and type are set.
-
xadd
public MathInstruction xadd()
Add the top two stack values. This instruction will result in anopuntil its type is set.
-
iadd
public MathInstruction iadd()
Add the top two stack int values; theiaddopcode.
-
ladd
public MathInstruction ladd()
Add the top two stack long values; theladdopcode.
-
fadd
public MathInstruction fadd()
Add the top two stack float values; thefaddopcode.
-
dadd
public MathInstruction dadd()
Add the top two stack double values; thedaddopcode.
-
xsub
public MathInstruction xsub()
Subtract the top two stack values. This instruction will result in anopuntil its type is set.
-
isub
public MathInstruction isub()
Subtract the top two stack int values; theisubopcode.
-
lsub
public MathInstruction lsub()
Subtract the top two stack long values; thelsubopcode.
-
fsub
public MathInstruction fsub()
Subtract the top two stack float values; thefsubopcode.
-
dsub
public MathInstruction dsub()
Subtract the top two stack double values; thedsubopcode.
-
xmul
public MathInstruction xmul()
Multiply the top two stack values. This instruction will result in anopuntil its type is set.
-
imul
public MathInstruction imul()
Multiply the top two stack int values; theimulopcode.
-
lmul
public MathInstruction lmul()
Multiply the top two stack long values; thelmulopcode.
-
fmul
public MathInstruction fmul()
Multiply the top two stack float values; thefmulopcode.
-
dmul
public MathInstruction dmul()
Multiply the top two stack double values; thedmulopcode.
-
xdiv
public MathInstruction xdiv()
Divide the top two stack values. This instruction will result in anopuntil its type is set.
-
idiv
public MathInstruction idiv()
Divide the top two stack int values; theidivopcode.
-
ldiv
public MathInstruction ldiv()
Divide the top two stack long values; theldivopcode.
-
fdiv
public MathInstruction fdiv()
Divide the top two stack float values; thefdivopcode.
-
ddiv
public MathInstruction ddiv()
Divide the top two stack double values; theddivopcode.
-
xrem
public MathInstruction xrem()
Take the remainder of the top two stack values. This instruction will result in anopuntil its type is set.
-
irem
public MathInstruction irem()
Take the remainder of the top two int stack values; theiremopcode.
-
lrem
public MathInstruction lrem()
Take the remainder of the top two long stack values; thelremopcode.
-
frem
public MathInstruction frem()
Take the remainder of the top two float stack values; thefremopcode.
-
drem
public MathInstruction drem()
Take the remainder of the top two double stack values; thedremopcode.
-
xneg
public MathInstruction xneg()
Negate the top stack value. This instruction will result in anopuntil its type is set.
-
ineg
public MathInstruction ineg()
Negate the top stack int value; theinegopcode.
-
lneg
public MathInstruction lneg()
Negate the top stack long value; thelnegopcode.
-
fneg
public MathInstruction fneg()
Negate the top stack float value; thefnegopcode.
-
dneg
public MathInstruction dneg()
Negate the top stack double value; thednegopcode.
-
xshl
public MathInstruction xshl()
Shift the top stack values. This instruction will result in anopuntil its type is set.
-
ishl
public MathInstruction ishl()
Shift the top stack int values; theishlopcode.
-
lshl
public MathInstruction lshl()
Shift the top stack long values; thelshlopcode.
-
xshr
public MathInstruction xshr()
Shift the top stack values. This instruction will result in anopuntil its type is set.
-
ishr
public MathInstruction ishr()
Shift the top stack int values; theishropcode.
-
lshr
public MathInstruction lshr()
Shift the top stack long values; thelshropcode.
-
xushr
public MathInstruction xushr()
Shift the top stack values. This instruction will result in anopuntil its type is set.
-
iushr
public MathInstruction iushr()
Shift the top stack int values; theiushropcode.
-
lushr
public MathInstruction lushr()
Shift the top stack long values; thelushropcode.
-
xand
public MathInstruction xand()
Take the mathematical and of the top two stack values. This instruction results in anopuntil its type is set.
-
iand
public MathInstruction iand()
Take the mathematical and of the top two stack int values; theiandopcode.
-
land
public MathInstruction land()
Take the mathematical and of the top two stack long values; thelandopcode.
-
xor
public MathInstruction xor()
Take the mathematical or of the top two stack values. This instruction results in anopuntil its type is set.
-
ior
public MathInstruction ior()
Take the mathematical or of the top two stack int values; theioropcode.
-
lor
public MathInstruction lor()
Take the mathematical or of the top two stack long values; theloropcode.
-
xxor
public MathInstruction xxor()
Take the mathematical xor of the top two stack values. This instruction results in anopuntil its type is set.
-
ixor
public MathInstruction ixor()
Take the mathematical xor of the top two stack int values; theixoropcode.
-
lxor
public MathInstruction lxor()
Take the mathematical xor of the top two stack long values; thelxoropcode.
-
convert
public ConvertInstruction convert()
Convert the top stack value to another type. This instruction will result in anopuntil the types to convert between are set.
-
xcmp
public CmpInstruction xcmp()
Compare the top two stack values. This instruction will result in anopuntil its type is set.
-
lcmp
public CmpInstruction lcmp()
Compare the top two stack values; thelcmpopcode.
-
fcmpl
public CmpInstruction fcmpl()
Compare the top two stack values; thefcmplopcode.
-
fcmpg
public CmpInstruction fcmpg()
Compare the top two stack values; thefcmpgopcode.
-
dcmpl
public CmpInstruction dcmpl()
Compare the top two stack values; thedcmplopcode.
-
dcmpg
public CmpInstruction dcmpg()
Compare the top two stack values; thedcmpgopcode.
-
ifeq
public IfInstruction ifeq()
Theifeqopcode.
-
ifne
public IfInstruction ifne()
Theifneopcode.
-
iflt
public IfInstruction iflt()
Theifltopcode.
-
ifge
public IfInstruction ifge()
Theifgeopcode.
-
ifgt
public IfInstruction ifgt()
Theifgtopcode.
-
ifle
public IfInstruction ifle()
Theifleopcode.
-
ificmpeq
public IfInstruction ificmpeq()
Theificmpeqopcode.
-
ificmpne
public IfInstruction ificmpne()
Theificmpneopcode.
-
ificmplt
public IfInstruction ificmplt()
Theificmpltopcode.
-
ificmpge
public IfInstruction ificmpge()
Theificmpgeopcode.
-
ificmpgt
public IfInstruction ificmpgt()
Theificmpgtopcode.
-
ificmple
public IfInstruction ificmple()
Theificmpleopcode.
-
ifacmpeq
public IfInstruction ifacmpeq()
Theifacmpeqopcode.
-
ifacmpne
public IfInstruction ifacmpne()
Theifacmpneopcode.
-
ifnull
public IfInstruction ifnull()
Theifnullopcode.
-
ifnonnull
public IfInstruction ifnonnull()
Theifnonnullopcode.
-
go2
public JumpInstruction go2()
Thego2opcode.
-
jsr
public JumpInstruction jsr()
Thejsropcode used in implementingfinallyclauses.
-
tableswitch
public TableSwitchInstruction tableswitch()
Thetableswitchopcode.
-
lookupswitch
public LookupSwitchInstruction lookupswitch()
Thelookupswitchopcode.
-
xreturn
public ReturnInstruction xreturn()
Return from a method. This method will result in anopuntil its type is set.
-
vreturn
public ReturnInstruction vreturn()
Return void from a method; thereturnopcode.
-
ireturn
public ReturnInstruction ireturn()
Return an int from a method; theireturnopcode.
-
lreturn
public ReturnInstruction lreturn()
Return a long from a method; thelreturnopcode.
-
freturn
public ReturnInstruction freturn()
Return a float from a method; thefreturnopcode.
-
dreturn
public ReturnInstruction dreturn()
Return a double from a method; thedreturnopcode.
-
areturn
public ReturnInstruction areturn()
Return an object from a method; theareturnopcode.
-
getfield
public GetFieldInstruction getfield()
Load the value from a field onto the stack; thegetfieldopcode.
-
getstatic
public GetFieldInstruction getstatic()
Load the value from a static field onto the stack; thegetstaticopcode.
-
putfield
public PutFieldInstruction putfield()
Place the value of a field onto the stack; theputfieldopcode.
-
putstatic
public PutFieldInstruction putstatic()
Place the value of a static field onto the stack; theputstaticopcode.
-
invokevirtual
public MethodInstruction invokevirtual()
Invoke a virtual method; theinvokevirtualopcode.
-
invokespecial
public MethodInstruction invokespecial()
Invoke a method non-virtually, as for constructors and superclass methods; theinvokespecialopcode.
-
invokeinterface
public MethodInstruction invokeinterface()
Invoke a method on an interface; theinvokeinterfaceopcode.
-
invokestatic
public MethodInstruction invokestatic()
Invoke a static method; theinvokestaticopcode.
-
invokedynamic
public MethodInstruction invokedynamic()
Invoke a dynamic method; theinvokedynamicopcode.
-
anew
public ClassInstruction anew()
Create a new instance of an object; thenewopcode.
-
anewarray
public ClassInstruction anewarray()
Create a new instance of an object array; theanewopcode.
-
checkcast
public ClassInstruction checkcast()
Cast an object on the stack to another type; thecheckcastopcode.
-
isinstance
public ClassInstruction isinstance()
Test if a stack object is an instance of a class; theinstanceofopcode.
-
multianewarray
public MultiANewArrayInstruction multianewarray()
Create a new multidimensional array; themultianewarrayopcode.
-
newarray
public NewArrayInstruction newarray()
Create a new array of a primitive type; thenewarrayopcode.
-
arraylength
public Instruction arraylength()
Get the length of an array on the stack; thearraylengthopcode.
-
athrow
public Instruction athrow()
Throw an exception; theathrowopcode.
-
monitorenter
public MonitorEnterInstruction monitorenter()
Themonitorenteropcode.
-
monitorexit
public MonitorExitInstruction monitorexit()
Themonitorexitopcode.
-
getInstructions
public Instruction[] getInstructions()
Return all the Instructions of this method.
-
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.
-
getLineNumberTable
public LineNumberTable getLineNumberTable(boolean add)
Return line number information for the code. Acts internally through theAttributesinterface.- Parameters:
add- if true, a new line number table will be added if not already present- Returns:
- the line number information, or null if none
and the
addparam is set to false
-
removeLineNumberTable
public boolean removeLineNumberTable()
Remove the line number table for the code. Acts internally through theAttributesinterface.- Returns:
- true if there was a table to remove
-
getLocalVariableTable
public LocalVariableTable getLocalVariableTable(boolean add)
Return local variable information for the code. Acts internally through theAttributesinterface.- Parameters:
add- if true, a new local variable table will be added if not already present- Returns:
- the local variable information, or null if none
and the
addparam is set to false
-
removeLocalVariableTables
public boolean removeLocalVariableTables()
Remove the local variable table for the code. Acts internally through theAttributesinterface.- Returns:
- true if there was a table to remove
-
getLocalVariableTypeTable
public LocalVariableTypeTable getLocalVariableTypeTable(boolean add)
Return local variable generics information for the code. Acts internally through theAttributesinterface.- Parameters:
add- if true, a new local variable type table will be added if not already present- Returns:
- the local variable type information, or null if none
and the
addparam is set to false
-
removeLocalVariableTypeTables
public boolean removeLocalVariableTypeTables()
Remove the local variable type table for the code. Acts internally through theAttributesinterface.- Returns:
- true if there was a table to remove
-
listIterator
public java.util.ListIterator listIterator()
Returns another listIterator view of the Instructions in this code block. Useful for performing read-only searches through Instructions without effecting the pointer location of the main code block.
-
-