com.go.trove.classfile
Class FilteredCodeAssembler

java.lang.Object
  |
  +--com.go.trove.classfile.FilteredCodeAssembler
All Implemented Interfaces:
CodeAssembler

public class FilteredCodeAssembler
extends java.lang.Object
implements CodeAssembler

Version:
10 , 9/07/00
Author:
Brian S O'Neill

Field Summary
protected  CodeAssembler mAssembler
           
 
Constructor Summary
FilteredCodeAssembler(CodeAssembler assembler)
           
 
Method Summary
 void arrayLength()
          Generates code for an arraylength instruction.
 void branch(Location location)
          Generates code that performs an unconditional branch to the specified location.
 void breakpoint()
          Generates a breakpoint instruction for use in a debugging environment.
 void checkCast(TypeDescriptor type)
          Generates code that performs an object cast operation.
 void convert(java.lang.Class fromType, java.lang.Class toType)
          Generates code that converts the value of a primitive type already on the stack.
 Label createLabel()
          Creates a label, whose location must be set.
 LocalVariable createLocalVariable(java.lang.String name, TypeDescriptor type)
          Creates a LocalVariable reference from a name and type.
 void dup()
          Generates code for the dup instruction.
 void dup2()
          Generates code for the dup2 instruction.
 void dup2X1()
          Generates code for the dup2_x1 instruction.
 void dup2X2()
          Generates code for the dup2_x2 instruction.
 void dupX1()
          Generates code for the dup_x1 instruction.
 void dupX2()
          Generates code for the dup_x2 instruction.
 void exceptionHandler(Location startLocation, Location endLocation, java.lang.String catchClassName)
          Sets up an exception handler located here, the location of the next code to be generated.
 LocalVariable[] getParameters()
          Returns LocalVariable references for all the parameters passed into the method being assembled, not including any "this" reference.
 void ifComparisonBranch(Location location, java.lang.String choice)
          Generates code the performs a conditional branch based on a comparison between two int values on the stack.
 void ifEqualBranch(Location location, boolean choice)
          Generates code that performs a conditional branch based on the value of two object references on the stack.
 void ifNullBranch(Location location, boolean choice)
          Generates code that performs a conditional branch based on the value of an object on the stack.
 void ifZeroComparisonBranch(Location location, java.lang.String choice)
          Generates code the performs a conditional branch based on a comparison between an int value on the stack and zero.
 void instanceOf(TypeDescriptor type)
          Generates code that performs an instanceof operation.
 void integerIncrement(LocalVariable local, int amount)
          Generates code that increments a local integer variable by a signed constant amount.
 void invokeConstructor(java.lang.String className, TypeDescriptor[] params)
          Generates code to invoke a class constructor in any class.
 void invokeConstructor(TypeDescriptor[] params)
          Generates code to invoke a class constructor in this class.
 void invokeInterface(java.lang.String className, java.lang.String methodName, TypeDescriptor ret, TypeDescriptor[] params)
          Generates code to invoke an interface method in any class.
 void invokePrivate(java.lang.String methodName, TypeDescriptor ret, TypeDescriptor[] params)
          Generates code to invoke a private method in this class.
 void invokeStatic(java.lang.String className, java.lang.String methodName, TypeDescriptor ret, TypeDescriptor[] params)
          Generates code to invoke a static method in any class.
 void invokeStatic(java.lang.String methodName, TypeDescriptor ret, TypeDescriptor[] params)
          Generates code to invoke a static method in this class.
 void invokeSuper(java.lang.String superClassName, java.lang.String methodName, TypeDescriptor ret, TypeDescriptor[] params)
          Generates code to invoke a method in the super class.
 void invokeSuperConstructor(TypeDescriptor[] params)
          Generates code to invoke a super class constructor.
 void invokeVirtual(java.lang.String className, java.lang.String methodName, TypeDescriptor ret, TypeDescriptor[] params)
          Generates code to invoke a virtual method in any class.
 void invokeVirtual(java.lang.String methodName, TypeDescriptor ret, TypeDescriptor[] params)
          Generates code to invoke a virtual method in this class.
 void jsr(Location location)
          Generates code that performs a subroutine branch to the specified location.
 void loadConstant(boolean value)
          Generates code that loads a constant boolean value onto the stack.
 void loadConstant(double value)
          Generates code that loads a constant double value onto the stack.
 void loadConstant(float value)
          Generates code that loads a constant float value onto the stack.
 void loadConstant(int value)
          Generates code that loads a constant int, char, short or byte value onto the stack.
 void loadConstant(long value)
          Generates code that loads a constant long value onto the stack.
 void loadConstant(java.lang.String value)
          Generates code that loads a constant string value onto the stack.
 void loadField(java.lang.String className, java.lang.String fieldName, TypeDescriptor type)
          Generates code that loads a value from a field from any class.
 void loadField(java.lang.String fieldName, TypeDescriptor type)
          Generates code that loads a value from a field from this class.
 void loadFromArray(java.lang.Class type)
          Generates code that loads a value from an array.
 void loadLocal(LocalVariable local)
          Generates code that loads a local variable onto the stack.
 void loadStaticField(java.lang.String className, java.lang.String fieldName, TypeDescriptor type)
          Generates code that loads a value from a static field from any class.
 void loadStaticField(java.lang.String fieldName, TypeDescriptor type)
          Generates code that loads a value from a static field from this class.
 void loadThis()
          Loads a reference to "this" onto the stack.
 void mapLineNumber(int lineNumber)
          Map the location of the next code to be generated to a line number in source code.
 void math(byte opcode)
          Generates code for either a unary or binary math operation on one or two values pushed on the stack.
 void monitorEnter()
          Generates code to enter the monitor on an object loaded on the stack.
 void monitorExit()
          Generates code to exit the monitor on an object loaded on the stack.
 void newObject(TypeDescriptor type)
          Generates code to create a new object.
 void nop()
          Generates an instruction that does nothing.
 void pop()
          Generates code for the pop instruction.
 void pop2()
          Generates code for the pop2 instruction.
 void ret(LocalVariable local)
          Generates code that returns from a subroutine invoked by jsr.
 void returnValue(java.lang.Class type)
          Generates code that returns an object or primitive type.
 void returnVoid()
          Generates code that returns void.
 void storeField(java.lang.String className, java.lang.String fieldName, TypeDescriptor type)
          Generates code that stores a value into a field from any class.
 void storeField(java.lang.String fieldName, TypeDescriptor type)
          Generates code that stores a value into a field from this class.
 void storeLocal(LocalVariable local)
          Generates code that pops a value off of the stack into a local variable.
 void storeStaticField(java.lang.String className, java.lang.String fieldName, TypeDescriptor type)
          Generates code that stores a value into a field from any class.
 void storeStaticField(java.lang.String fieldName, TypeDescriptor type)
          Generates code that stores a value into a field from this class.
 void storeToArray(java.lang.Class type)
          Generates code that stores a value to an array.
 void swap()
          Generates code for the swap instruction.
 void swap2()
          Generates code for a swap2 instruction.
 void switchBranch(int[] cases, Location[] locations, Location defaultLocation)
          Generates code for a switch statement.
 void throwObject()
          Generates code that throws an exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mAssembler

protected final CodeAssembler mAssembler
Constructor Detail

FilteredCodeAssembler

public FilteredCodeAssembler(CodeAssembler assembler)
Method Detail

getParameters

public LocalVariable[] getParameters()
Description copied from interface: CodeAssembler
Returns LocalVariable references for all the parameters passed into the method being assembled, not including any "this" reference. Returns a zero-length array if there are no passed in parameters.

The names of the LocalVariables returned by this method are initially set to null. It is encouraged that a name be provided.

Specified by:
getParameters in interface CodeAssembler

createLocalVariable

public LocalVariable createLocalVariable(java.lang.String name,
                                         TypeDescriptor type)
Description copied from interface: CodeAssembler
Creates a LocalVariable reference from a name and type. Although name is optional, it is encouraged that a name be provided. Names do not need to be unique.
Specified by:
createLocalVariable in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
name - Optional name for the LocalVariable.
type - The type of data that the requested LocalVariable can store.

createLabel

public Label createLabel()
Description copied from interface: CodeAssembler
Creates a label, whose location must be set. To create a label and locate it here, the following example demonstrates how the call to setLocation can be chained:
 CodeBuilder builder;
 ...
 Label label = builder.createLabel().setLocation();
 
Specified by:
createLabel in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
See Also:
Label.setLocation()

exceptionHandler

public void exceptionHandler(Location startLocation,
                             Location endLocation,
                             java.lang.String catchClassName)
Description copied from interface: CodeAssembler
Sets up an exception handler located here, the location of the next code to be generated.
Specified by:
exceptionHandler in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
startLocation - Location at the start of the section of code to be wrapped by an exception handler.
endLocation - Location directly after the end of the section of code.
catchClassName - The name of the type of exception to be caught; if null, then catch every object.

mapLineNumber

public void mapLineNumber(int lineNumber)
Description copied from interface: CodeAssembler
Map the location of the next code to be generated to a line number in source code. This enables line numbers in a stack trace from the generated code.
Specified by:
mapLineNumber in interface CodeAssembler

loadConstant

public void loadConstant(java.lang.String value)
Description copied from interface: CodeAssembler
Generates code that loads a constant string value onto the stack. If value is null, the generated code loads a null onto the stack. Strings that exceed 65535 UTF encoded bytes in length are loaded by creating a StringBuffer, appending substrings, and then converting to a String.
Specified by:
loadConstant in interface CodeAssembler

loadConstant

public void loadConstant(boolean value)
Description copied from interface: CodeAssembler
Generates code that loads a constant boolean value onto the stack.
Specified by:
loadConstant in interface CodeAssembler

loadConstant

public void loadConstant(int value)
Description copied from interface: CodeAssembler
Generates code that loads a constant int, char, short or byte value onto the stack.
Specified by:
loadConstant in interface CodeAssembler

loadConstant

public void loadConstant(long value)
Description copied from interface: CodeAssembler
Generates code that loads a constant long value onto the stack.
Specified by:
loadConstant in interface CodeAssembler

loadConstant

public void loadConstant(float value)
Description copied from interface: CodeAssembler
Generates code that loads a constant float value onto the stack.
Specified by:
loadConstant in interface CodeAssembler

loadConstant

public void loadConstant(double value)
Description copied from interface: CodeAssembler
Generates code that loads a constant double value onto the stack.
Specified by:
loadConstant in interface CodeAssembler

loadLocal

public void loadLocal(LocalVariable local)
Description copied from interface: CodeAssembler
Generates code that loads a local variable onto the stack. Parameters passed to a method and the "this" reference are all considered local variables, as well as any that were created.
Specified by:
loadLocal in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
local - The local variable reference

loadThis

public void loadThis()
Description copied from interface: CodeAssembler
Loads a reference to "this" onto the stack. Static methods have no "this" reference, and an exception is thrown when attempting to generate "this" in a static method.
Specified by:
loadThis in interface CodeAssembler

storeLocal

public void storeLocal(LocalVariable local)
Description copied from interface: CodeAssembler
Generates code that pops a value off of the stack into a local variable. Parameters passed to a method and the "this" reference are all considered local variables, as well as any that were created.
Specified by:
storeLocal in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
local - The local variable reference

loadFromArray

public void loadFromArray(java.lang.Class type)
Description copied from interface: CodeAssembler
Generates code that loads a value from an array. An array reference followed by an index must be on the stack. The array reference and index are replaced by the value retrieved from the array after the generated instruction has executed.

The type doesn't need to be an exact match for objects. Object.class works fine for all objects. For primitive types, use the class that matches that type. For an int the type is int.class.

Specified by:
loadFromArray in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
type - The type of data stored in the array.

storeToArray

public void storeToArray(java.lang.Class type)
Description copied from interface: CodeAssembler
Generates code that stores a value to an array. An array reference followed by an index, followed by a value (or two if a long or double) must be on the stack. All items on the stack are gone after the generated instruction has executed.

The type doesn't need to be an exact match for objects. Object.class works fine for all objects. For primitive types, use the class that matches that type. For an int the type is int.class.

Specified by:
storeToArray in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
type - The type of data stored in the array.

loadField

public void loadField(java.lang.String fieldName,
                      TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that loads a value from a field from this class. An object reference must be on the stack. After the generated code has executed, the object reference is replaced by the value retrieved from the field.
Specified by:
loadField in interface CodeAssembler

loadField

public void loadField(java.lang.String className,
                      java.lang.String fieldName,
                      TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that loads a value from a field from any class. An object reference must be on the stack. After the generated code has executed, the object reference is replaced by the value retrieved from the field.
Specified by:
loadField in interface CodeAssembler

loadStaticField

public void loadStaticField(java.lang.String fieldName,
                            TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that loads a value from a static field from this class. After the generated code has executed, the value retrieved is placed on the stack.
Specified by:
loadStaticField in interface CodeAssembler

loadStaticField

public void loadStaticField(java.lang.String className,
                            java.lang.String fieldName,
                            TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that loads a value from a static field from any class. After the generated code has executed, the value retrieved is placed on the stack.
Specified by:
loadStaticField in interface CodeAssembler

storeField

public void storeField(java.lang.String fieldName,
                       TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that stores a value into a field from this class. An object reference and value must be on the stack. After the generated code has executed, the object reference and value are gone from the stack.
Specified by:
storeField in interface CodeAssembler

storeField

public void storeField(java.lang.String className,
                       java.lang.String fieldName,
                       TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that stores a value into a field from any class. An object reference and value must be on the stack. After the generated code has executed, the object reference and value are gone from the stack.
Specified by:
storeField in interface CodeAssembler

storeStaticField

public void storeStaticField(java.lang.String fieldName,
                             TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that stores a value into a field from this class. A value must be on the stack. After the generated code has executed, the value is gone from the stack.
Specified by:
storeStaticField in interface CodeAssembler

storeStaticField

public void storeStaticField(java.lang.String className,
                             java.lang.String fieldName,
                             TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that stores a value into a field from any class. A value must be on the stack. After the generated code has executed, the value is gone from the stack.
Specified by:
storeStaticField in interface CodeAssembler

returnVoid

public void returnVoid()
Description copied from interface: CodeAssembler
Generates code that returns void.
Specified by:
returnVoid in interface CodeAssembler

returnValue

public void returnValue(java.lang.Class type)
Description copied from interface: CodeAssembler
Generates code that returns an object or primitive type. The value to return must be on the stack.

The type doesn't need to be an exact match for objects. Object.class works fine for all objects. For primitive types, use the class that matches that type. For an int the type is int.class.

Specified by:
returnValue in interface CodeAssembler

convert

public void convert(java.lang.Class fromType,
                    java.lang.Class toType)
Description copied from interface: CodeAssembler
Generates code that converts the value of a primitive type already on the stack.
Specified by:
convert in interface CodeAssembler

invokeVirtual

public void invokeVirtual(java.lang.String methodName,
                          TypeDescriptor ret,
                          TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a virtual method in this class. The object reference and the method's argument(s) must be on the stack.
Specified by:
invokeVirtual in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
ret - May be null if method returns void.
params - May be null if method takes no parameters.

invokeVirtual

public void invokeVirtual(java.lang.String className,
                          java.lang.String methodName,
                          TypeDescriptor ret,
                          TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a virtual method in any class. The object reference and the method's argument(s) must be on the stack.
Specified by:
invokeVirtual in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
ret - May be null if method returns void.
params - May be null if method takes no parameters.

invokeStatic

public void invokeStatic(java.lang.String methodName,
                         TypeDescriptor ret,
                         TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a static method in this class. The method's argument(s) must be on the stack.
Specified by:
invokeStatic in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
ret - May be null if method returns void.
params - May be null if method takes no parameters.

invokeStatic

public void invokeStatic(java.lang.String className,
                         java.lang.String methodName,
                         TypeDescriptor ret,
                         TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a static method in any class. The method's argument(s) must be on the stack.
Specified by:
invokeStatic in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
ret - May be null if method returns void.
params - May be null if method takes no parameters.

invokeInterface

public void invokeInterface(java.lang.String className,
                            java.lang.String methodName,
                            TypeDescriptor ret,
                            TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke an interface method in any class. The object reference and the method's argument(s) must be on the stack.
Specified by:
invokeInterface in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
ret - May be null if method returns void.
params - May be null if method takes no parameters.

invokePrivate

public void invokePrivate(java.lang.String methodName,
                          TypeDescriptor ret,
                          TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a private method in this class. The object reference and the method's argument(s) must be on the stack.
Specified by:
invokePrivate in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
ret - May be null if method returns void.
params - May be null if method takes no parameters.

invokeSuper

public void invokeSuper(java.lang.String superClassName,
                        java.lang.String methodName,
                        TypeDescriptor ret,
                        TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a method in the super class. The object reference and the method's argument(s) must be on the stack.
Specified by:
invokeSuper in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
ret - May be null if method returns void.
params - May be null if method takes no parameters.

invokeConstructor

public void invokeConstructor(TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a class constructor in this class. The object reference and the constructor's argument(s) must be on the stack.
Specified by:
invokeConstructor in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
params - May be null if constructor takes no parameters.

invokeConstructor

public void invokeConstructor(java.lang.String className,
                              TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a class constructor in any class. The object reference and the constructor's argument(s) must be on the stack.
Specified by:
invokeConstructor in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
params - May be null if constructor takes no parameters.

invokeSuperConstructor

public void invokeSuperConstructor(TypeDescriptor[] params)
Description copied from interface: CodeAssembler
Generates code to invoke a super class constructor. The object reference and the constructor's argument(s) must be on the stack.
Specified by:
invokeSuperConstructor in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
params - May be null if constructor takes no parameters.

newObject

public void newObject(TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code to create a new object. Unless the new object is an array, it is invalid until a constructor method is invoked on it. When creating arrays, the size for each dimension must be on the operand stack.
Specified by:
newObject in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
See Also:
CodeAssembler.invokeConstructor(com.go.trove.classfile.TypeDescriptor[])

dup

public void dup()
Description copied from interface: CodeAssembler
Generates code for the dup instruction.
Specified by:
dup in interface CodeAssembler

dupX1

public void dupX1()
Description copied from interface: CodeAssembler
Generates code for the dup_x1 instruction.
Specified by:
dupX1 in interface CodeAssembler

dupX2

public void dupX2()
Description copied from interface: CodeAssembler
Generates code for the dup_x2 instruction.
Specified by:
dupX2 in interface CodeAssembler

dup2

public void dup2()
Description copied from interface: CodeAssembler
Generates code for the dup2 instruction.
Specified by:
dup2 in interface CodeAssembler

dup2X1

public void dup2X1()
Description copied from interface: CodeAssembler
Generates code for the dup2_x1 instruction.
Specified by:
dup2X1 in interface CodeAssembler

dup2X2

public void dup2X2()
Description copied from interface: CodeAssembler
Generates code for the dup2_x2 instruction.
Specified by:
dup2X2 in interface CodeAssembler

pop

public void pop()
Description copied from interface: CodeAssembler
Generates code for the pop instruction.
Specified by:
pop in interface CodeAssembler

pop2

public void pop2()
Description copied from interface: CodeAssembler
Generates code for the pop2 instruction.
Specified by:
pop2 in interface CodeAssembler

swap

public void swap()
Description copied from interface: CodeAssembler
Generates code for the swap instruction.
Specified by:
swap in interface CodeAssembler

swap2

public void swap2()
Description copied from interface: CodeAssembler
Generates code for a swap2 instruction.
Specified by:
swap2 in interface CodeAssembler

branch

public void branch(Location location)
Description copied from interface: CodeAssembler
Generates code that performs an unconditional branch to the specified location.
Specified by:
branch in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
location - The location to branch to

ifNullBranch

public void ifNullBranch(Location location,
                         boolean choice)
Description copied from interface: CodeAssembler
Generates code that performs a conditional branch based on the value of an object on the stack. A branch is performed based on whether the object reference on the stack is null or not.
Specified by:
ifNullBranch in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
location - The location to branch to
choice - If true, do branch when null, else branch when not null

ifEqualBranch

public void ifEqualBranch(Location location,
                          boolean choice)
Description copied from interface: CodeAssembler
Generates code that performs a conditional branch based on the value of two object references on the stack. A branch is performed based on whether the two objects are equal.
Specified by:
ifEqualBranch in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
location - The location to branch to
choice - If true, branch when equal, else branch when not equal

ifZeroComparisonBranch

public void ifZeroComparisonBranch(Location location,
                                   java.lang.String choice)
                            throws java.lang.IllegalArgumentException
Description copied from interface: CodeAssembler
Generates code the performs a conditional branch based on a comparison between an int value on the stack and zero. The int value on the stack is on the left side of the comparison expression.
Specified by:
ifZeroComparisonBranch in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
location - The location to branch to
choice - One of "==", "!=", "<", ">=", ">" or "<="
Throws:
java.lang.IllegalArgumentException - When the choice is not valid

ifComparisonBranch

public void ifComparisonBranch(Location location,
                               java.lang.String choice)
                        throws java.lang.IllegalArgumentException
Description copied from interface: CodeAssembler
Generates code the performs a conditional branch based on a comparison between two int values on the stack. The first int value on the stack is on the left side of the comparison expression.
Specified by:
ifComparisonBranch in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
location - The location to branch to
choice - One of "==", "!=", "<", ">=", ">" or "<="
Throws:
java.lang.IllegalArgumentException - When the choice is not valid

switchBranch

public void switchBranch(int[] cases,
                         Location[] locations,
                         Location defaultLocation)
Description copied from interface: CodeAssembler
Generates code for a switch statement. The generated code is either a lookupswitch or tableswitch. The choice of which switch type to generate is made based on the amount of bytes to be generated. A tableswitch is usually smaller, unless the cases are sparse.

The key value to switch on must already be on the stack when this instruction executes.

Specified by:
switchBranch in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
cases - The values to match on. The array length must be the same as for locations.
locations - The locations to branch to for each case. The array length must be the same as for cases.
defaultLocation - The location to branch to if the key on the stack was not matched.

jsr

public void jsr(Location location)
Description copied from interface: CodeAssembler
Generates code that performs a subroutine branch to the specified location. The instruction generated is either jsr or jsr_w. It is most often used for implementing a finally block.
Specified by:
jsr in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
Location - The location to branch to

ret

public void ret(LocalVariable local)
Description copied from interface: CodeAssembler
Generates code that returns from a subroutine invoked by jsr.
Specified by:
ret in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
local - The local variable reference that contains the return address. The local variable must be of an object type.

math

public void math(byte opcode)
Description copied from interface: CodeAssembler
Generates code for either a unary or binary math operation on one or two values pushed on the stack.

Pass in an opcode from the the Opcode class. The only valid math opcodes are:

 IADD, ISUB, IMUL, IDIV, IREM, INEG, IAND, IOR, IXOR, ISHL, ISHR, IUSHR
 LADD, LSUB, LMUL, LDIV, LREM, LNEG, LAND, LOR, LXOR, LSHL, LSHR, LUSHR
 FADD, FSUB, FMUL, FDIV, FREM, FNEG
 DADD, DSUB, DMUL, DDIV, DREM, DNEG

 LCMP
 FCMPG, FCMPL
 DCMPG, DCMPL
 
A not operation (~) is performed by doing a loadConstant with either -1 or -1L followed by math(Opcode.IXOR) or math(Opcode.LXOR).
Specified by:
math in interface CodeAssembler
Following copied from interface: com.go.trove.classfile.CodeAssembler
Parameters:
opcode - An opcode from the Opcode class.
Throws:
java.lang.IllegalArgumentException - When the opcode selected is not a math operation.
See Also:
Opcode

arrayLength

public void arrayLength()
Description copied from interface: CodeAssembler
Generates code for an arraylength instruction. The object to get the length from must already be on the stack.
Specified by:
arrayLength in interface CodeAssembler

throwObject

public void throwObject()
Description copied from interface: CodeAssembler
Generates code that throws an exception. The object to throw must already be on the stack.
Specified by:
throwObject in interface CodeAssembler

checkCast

public void checkCast(TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that performs an object cast operation. The object to check must already be on the stack.
Specified by:
checkCast in interface CodeAssembler

instanceOf

public void instanceOf(TypeDescriptor type)
Description copied from interface: CodeAssembler
Generates code that performs an instanceof operation. The object to check must already be on the stack.
Specified by:
instanceOf in interface CodeAssembler

integerIncrement

public void integerIncrement(LocalVariable local,
                             int amount)
Description copied from interface: CodeAssembler
Generates code that increments a local integer variable by a signed constant amount.
Specified by:
integerIncrement in interface CodeAssembler

monitorEnter

public void monitorEnter()
Description copied from interface: CodeAssembler
Generates code to enter the monitor on an object loaded on the stack.
Specified by:
monitorEnter in interface CodeAssembler

monitorExit

public void monitorExit()
Description copied from interface: CodeAssembler
Generates code to exit the monitor on an object loaded on the stack.
Specified by:
monitorExit in interface CodeAssembler

nop

public void nop()
Description copied from interface: CodeAssembler
Generates an instruction that does nothing. (No-OPeration)
Specified by:
nop in interface CodeAssembler

breakpoint

public void breakpoint()
Description copied from interface: CodeAssembler
Generates a breakpoint instruction for use in a debugging environment.
Specified by:
breakpoint in interface CodeAssembler