|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry5.internal.plastic.Lockable org.apache.tapestry5.internal.plastic.InstructionBuilderImpl
public class InstructionBuilderImpl
Field Summary | |
---|---|
protected NameCache |
cache
|
protected InstructionBuilderState |
state
|
protected org.apache.tapestry5.internal.plastic.asm.MethodVisitor |
v
|
Fields inherited from interface org.apache.tapestry5.internal.plastic.asm.Opcodes |
---|
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASM4, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DOUBLE, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F_APPEND, F_CHOP, F_FULL, F_NEW, F_SAME, F_SAME1, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAT, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, H_GETFIELD, H_GETSTATIC, H_INVOKEINTERFACE, H_INVOKESPECIAL, H_INVOKESTATIC, H_INVOKEVIRTUAL, H_NEWINVOKESPECIAL, H_PUTFIELD, H_PUTSTATIC, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INTEGER, INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LONG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, NULL, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7 |
Method Summary | |
---|---|
InstructionBuilder |
arrayLength()
Expects the top object on the stack to be an array. |
InstructionBuilder |
boxPrimitive(String typeName)
If the type name is a primitive type, adds code to box the type into the equivalent wrapper type, using static methods on the wrapper type. |
InstructionBuilder |
castOrUnbox(String typeName)
Casts the object on top of the stack to the indicated type. |
InstructionBuilder |
checkcast(Class clazz)
|
InstructionBuilder |
checkcast(String className)
Adds a check that the object on top of the stack is assignable to the indicated class. |
InstructionBuilder |
compareSpecial(String typeName)
Special comparison logic for primitive float, double and long. |
InstructionBuilder |
doWhile(Condition condition,
WhileCallback callback)
Implements a simple loop based on a condition. |
InstructionBuilder |
dupe()
Duplicates the top object on the stack. |
InstructionBuilder |
dupe(int depth)
Duplicates the top object on the stack, placing the result at some depth. |
InstructionBuilder |
dupeWide()
Duplicates a wide value (a primitive long or double). |
InstructionBuilder |
getField(PlasticField field)
Loads an instance or static field onto the stack. |
InstructionBuilder |
getField(String className,
String fieldName,
Class fieldType)
Loads a field onto the stack. |
InstructionBuilder |
getField(String className,
String fieldName,
String typeName)
Loads an instance field onto the stack. |
InstructionBuilder |
getStaticField(String className,
String fieldName,
Class fieldType)
Gets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack. |
InstructionBuilder |
getStaticField(String className,
String fieldName,
String typeName)
Gets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack. |
InstructionBuilder |
increment(LocalVariable variable)
Increments a local integer variable. |
InstructionBuilder |
invoke(Class clazz,
Class returnType,
String methodName,
Class... argumentTypes)
Automatically invokes an interface or virtual method. |
InstructionBuilder |
invoke(Method method)
Automatically invokes an interface or virtual method. |
InstructionBuilder |
invokeConstructor(Class clazz,
Class... argumentTypes)
|
InstructionBuilder |
invokeConstructor(String className,
String... argumentTypes)
Invokes a constructor on a class. |
InstructionBuilder |
invokeInterface(String interfaceName,
String returnType,
String methodName,
String... argumentTypes)
Invokes a standard virtual method. |
InstructionBuilder |
invokeSpecial(String containingClassName,
MethodDescription description)
Invokes an instance method of a base class, or a private method of a class, using the target object and parameters already on the stack. |
InstructionBuilder |
invokeStatic(Class clazz,
Class returnType,
String methodName,
Class... argumentTypes)
Invokes a static method of a class. |
InstructionBuilder |
invokeVirtual(PlasticMethod method)
|
InstructionBuilder |
invokeVirtual(String className,
String returnType,
String methodName,
String... argumentTypes)
Invokes a standard virtual method. |
InstructionBuilder |
iterateArray(InstructionBuilderCallback callback)
Expects an array to be the top value on the stack. |
InstructionBuilder |
loadArgument(int index)
Loads an argument onto the stack, using the opcode appropriate to the argument's type. |
InstructionBuilder |
loadArguments()
Loads all arguments for the current method onto the stack; this is used when invoking a method that takes the exact same parameters (often, a super-class implementation). |
InstructionBuilder |
loadArrayElement()
Loads a value from an array object. |
InstructionBuilder |
loadArrayElement(int index,
String elementType)
Loads a value from an array object, which must be the top element of the stack. |
InstructionBuilder |
loadConstant(Object constant)
Loads a constant value |
InstructionBuilder |
loadNull()
Loads the null constant onto the stack. |
InstructionBuilder |
loadThis()
Loads this onto the stack. |
InstructionBuilder |
loadTypeConstant(Class clazz)
Loads a Java type (a Class instance) as a constant. |
InstructionBuilder |
loadTypeConstant(String typeName)
Loads a Java type (a Class instance) as a constant. |
InstructionBuilder |
loadVariable(LocalVariable var)
Loads a value from a local variable and pushes it onto the stack. |
InstructionBuilder |
newInstance(Class clazz)
A convenience version of InstructionBuilder.newInstance(String) used when the class is known
at build time. |
InstructionBuilder |
newInstance(String className)
Creates a new, uninitialized instance of the indicated class. |
InstructionBuilder |
pop()
Discards the top value on the stack. |
InstructionBuilder |
popWide()
Pops a wide value (a primitive long or double). |
InstructionBuilder |
putField(String className,
String fieldName,
Class fieldType)
|
InstructionBuilder |
putField(String className,
String fieldName,
String typeName)
Expects the stack to contain the instance to update, and the value to store into the field. |
InstructionBuilder |
putStaticField(String className,
String fieldName,
Class fieldType)
Sets a static field; the new field value should be on top of the stack. |
InstructionBuilder |
putStaticField(String className,
String fieldName,
String typeName)
Sets a static field; the new field value should be on top of the stack. |
InstructionBuilder |
returnDefaultValue()
Returns the default value for the method, which may be null, or a specific primitive value. |
InstructionBuilder |
returnResult()
Returns the top value on the stack. |
InstructionBuilder |
startSwitch(int min,
int max,
SwitchCallback callback)
Starts a switch statement. |
InstructionBuilder |
startTryCatch(TryCatchCallback callback)
Defines the start of a block that can have exception handlers and finally blocks applied. |
InstructionBuilder |
startVariable(String type,
LocalVariableCallback callback)
Starts a block where the given name is active. |
InstructionBuilder |
storeVariable(LocalVariable var)
Stores the value on top of the stack to a local variable (previously defined by InstructionBuilder.startVariable(String, LocalVariableCallback) . |
InstructionBuilder |
swap()
Swaps the top element of the stack with the next element down. |
InstructionBuilder |
throwException()
Throws the exception on the top of the stack. |
InstructionBuilder |
throwException(Class<? extends Throwable> exceptionType,
String message)
|
InstructionBuilder |
throwException(String className,
String message)
Throws an exception with a fixed message. |
InstructionBuilder |
unboxPrimitive(String typeName)
Unboxes a wrapper type to a primitive type if typeName is a primitive type name (the value on the stack should be the corresponding wrapper type instance). |
InstructionBuilder |
when(Condition condition,
InstructionBuilderCallback ifTrue)
Simplified version of InstructionBuilder.when(Condition, WhenCallback) that
simply executes the callback code when the condition is true and does nothing
if the condition is false (the more general case). |
InstructionBuilder |
when(Condition condition,
WhenCallback callback)
Executes conditional code based on a Condition . |
Methods inherited from class org.apache.tapestry5.internal.plastic.Lockable |
---|
check, lock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final InstructionBuilderState state
protected final org.apache.tapestry5.internal.plastic.asm.MethodVisitor v
protected final NameCache cache
Method Detail |
---|
public InstructionBuilder returnDefaultValue()
InstructionBuilder
returnDefaultValue
in interface InstructionBuilder
public InstructionBuilder loadThis()
InstructionBuilder
loadThis
in interface InstructionBuilder
public InstructionBuilder loadNull()
InstructionBuilder
loadNull
in interface InstructionBuilder
public InstructionBuilder loadArgument(int index)
InstructionBuilder
loadArgument
in interface InstructionBuilder
index
- to argument (0 is the first argument, not this)public InstructionBuilder loadArguments()
InstructionBuilder
InstructionBuilder.loadThis()
(or
some other way of identifying the target method) should precede this call.
loadArguments
in interface InstructionBuilder
public InstructionBuilder invokeSpecial(String containingClassName, MethodDescription description)
InstructionBuilder
invokeSpecial
in interface InstructionBuilder
containingClassName
- class name containing the methoddescription
- describes the method name, parameters and return typepublic InstructionBuilder invokeVirtual(PlasticMethod method)
invokeVirtual
in interface InstructionBuilder
public InstructionBuilder invokeVirtual(String className, String returnType, String methodName, String... argumentTypes)
InstructionBuilder
invokeVirtual
in interface InstructionBuilder
public InstructionBuilder invokeInterface(String interfaceName, String returnType, String methodName, String... argumentTypes)
InstructionBuilder
invokeInterface
in interface InstructionBuilder
public InstructionBuilder invokeStatic(Class clazz, Class returnType, String methodName, Class... argumentTypes)
InstructionBuilder
invokeStatic
in interface InstructionBuilder
public InstructionBuilder invoke(Method method)
InstructionBuilder
InstructionBuilder.invokeConstructor(Class, Class...)
for constructors and InstructionBuilder.invokeSpecial(String, MethodDescription)
for private methods.
invoke
in interface InstructionBuilder
public InstructionBuilder invoke(Class clazz, Class returnType, String methodName, Class... argumentTypes)
InstructionBuilder
InstructionBuilder.invokeConstructor(Class, Class...)
for constructors and InstructionBuilder.invokeSpecial(String, MethodDescription)
for private methods.
invoke
in interface InstructionBuilder
public InstructionBuilder returnResult()
InstructionBuilder
returnResult
in interface InstructionBuilder
public InstructionBuilder boxPrimitive(String typeName)
InstructionBuilder
boxPrimitive
in interface InstructionBuilder
public InstructionBuilder unboxPrimitive(String typeName)
InstructionBuilder
unboxPrimitive
in interface InstructionBuilder
typeName
- possibly primitive type namepublic InstructionBuilder getField(String className, String fieldName, String typeName)
InstructionBuilder
InstructionBuilder.loadThis()
).
getField
in interface InstructionBuilder
className
- name of class containing the fieldfieldName
- name of the fieldtypeName
- type of fieldpublic InstructionBuilder getStaticField(String className, String fieldName, String typeName)
InstructionBuilder
getStaticField
in interface InstructionBuilder
className
- name of class containing the fieldfieldName
- name of the fieldtypeName
- type of fieldpublic InstructionBuilder getStaticField(String className, String fieldName, Class fieldType)
InstructionBuilder
getStaticField
in interface InstructionBuilder
className
- name of class containing the fieldfieldName
- name of the fieldfieldType
- type of fieldpublic InstructionBuilder putStaticField(String className, String fieldName, Class fieldType)
InstructionBuilder
putStaticField
in interface InstructionBuilder
className
- name of class containing the fieldfieldName
- name of the fieldfieldType
- type of fieldpublic InstructionBuilder putStaticField(String className, String fieldName, String typeName)
InstructionBuilder
putStaticField
in interface InstructionBuilder
className
- name of class containing the fieldfieldName
- name of the fieldtypeName
- type of fieldpublic InstructionBuilder getField(PlasticField field)
InstructionBuilder
InstructionBuilder.loadThis()
).
getField
in interface InstructionBuilder
field
- identifies name, type and container of field to loadpublic InstructionBuilder putField(String className, String fieldName, String typeName)
InstructionBuilder
putField
in interface InstructionBuilder
public InstructionBuilder putField(String className, String fieldName, Class fieldType)
putField
in interface InstructionBuilder
public InstructionBuilder getField(String className, String fieldName, Class fieldType)
InstructionBuilder
getField
in interface InstructionBuilder
className
- name of class containing the fieldfieldName
- name of the fieldfieldType
- type of fieldpublic InstructionBuilder loadArrayElement(int index, String elementType)
InstructionBuilder
loadArrayElement
in interface InstructionBuilder
index
- constant index into the arrayelementType
- the type name of the elements of the array
Note: currently only reference types (objects and arrays) are supported, not
primitivespublic InstructionBuilder loadArrayElement()
InstructionBuilder
loadArrayElement
in interface InstructionBuilder
public InstructionBuilder checkcast(String className)
InstructionBuilder
checkcast
in interface InstructionBuilder
className
- class to cast topublic InstructionBuilder checkcast(Class clazz)
checkcast
in interface InstructionBuilder
public InstructionBuilder startTryCatch(TryCatchCallback callback)
InstructionBuilder
startTryCatch
in interface InstructionBuilder
callback
- allows generation of try, catch, and finally clausespublic InstructionBuilder newInstance(String className)
InstructionBuilder
newInstance
in interface InstructionBuilder
className
- of class to instantiatepublic InstructionBuilder newInstance(Class clazz)
InstructionBuilder
InstructionBuilder.newInstance(String)
used when the class is known
at build time.
newInstance
in interface InstructionBuilder
clazz
- to instantiatepublic InstructionBuilder invokeConstructor(String className, String... argumentTypes)
InstructionBuilder
invokeConstructor
in interface InstructionBuilder
className
- the class containing the constructorargumentTypes
- java type names for each argument of the constructorpublic InstructionBuilder invokeConstructor(Class clazz, Class... argumentTypes)
invokeConstructor
in interface InstructionBuilder
public InstructionBuilder dupe(int depth)
InstructionBuilder
dupe
in interface InstructionBuilder
depth
- 0 (DUP), 1 (DUP_X1) or 2 (DUP_X2)public InstructionBuilder dupe()
InstructionBuilder
InstructionBuilder.when(Condition, WhenCallback)
.
dupe
in interface InstructionBuilder
InstructionBuilder.dupe(int)
public InstructionBuilder pop()
InstructionBuilder
pop
in interface InstructionBuilder
public InstructionBuilder swap()
InstructionBuilder
swap
in interface InstructionBuilder
public InstructionBuilder loadConstant(Object constant)
InstructionBuilder
loadConstant
in interface InstructionBuilder
constant
- Integer, Float, Double, Long, String or nullpublic InstructionBuilder loadTypeConstant(String typeName)
InstructionBuilder
loadTypeConstant
in interface InstructionBuilder
typeName
- Java class namepublic InstructionBuilder loadTypeConstant(Class clazz)
InstructionBuilder
loadTypeConstant
in interface InstructionBuilder
clazz
- Java type to load as a constantpublic InstructionBuilder castOrUnbox(String typeName)
InstructionBuilder
castOrUnbox
in interface InstructionBuilder
typeName
- to cast or unbox topublic InstructionBuilder throwException(String className, String message)
InstructionBuilder
throwException
in interface InstructionBuilder
className
- name of exception class to instantiatemessage
- message (passed as first and only parameter to constructor)public InstructionBuilder throwException(Class<? extends Throwable> exceptionType, String message)
throwException
in interface InstructionBuilder
public InstructionBuilder throwException()
InstructionBuilder
throwException
in interface InstructionBuilder
public InstructionBuilder startSwitch(int min, int max, SwitchCallback callback)
InstructionBuilder
startSwitch
in interface InstructionBuilder
min
- the minimum value to match againstmax
- the maximum value to match againstpublic InstructionBuilder startVariable(String type, LocalVariableCallback callback)
InstructionBuilder
startVariable
in interface InstructionBuilder
type
- type of local variablecallback
- generates code used when variable is in effectpublic InstructionBuilder storeVariable(LocalVariable var)
InstructionBuilder
InstructionBuilder.startVariable(String, LocalVariableCallback)
.
storeVariable
in interface InstructionBuilder
public InstructionBuilder loadVariable(LocalVariable var)
InstructionBuilder
InstructionBuilder.startVariable(String, LocalVariableCallback)
.
loadVariable
in interface InstructionBuilder
public InstructionBuilder when(Condition condition, InstructionBuilderCallback ifTrue)
InstructionBuilder
InstructionBuilder.when(Condition, WhenCallback)
that
simply executes the callback code when the condition is true and does nothing
if the condition is false (the more general case).
The testing opcodes all pop the value off the stack, so this is usually preceded by dupe(0)
.
when
in interface InstructionBuilder
condition
- to evaluateifTrue
- generates code for when condition is true
public InstructionBuilder when(Condition condition, WhenCallback callback)
InstructionBuilder
Condition
. The testing opcodes all pop
the value off the stack, so this is usually preceded by dupe(0)
.
when
in interface InstructionBuilder
condition
- defines true and false casescallback
- provides code for true and false blocks
public InstructionBuilder doWhile(Condition condition, WhileCallback callback)
InstructionBuilder
WhileCallback.buildBody(InstructionBuilder)
is executed, and then a GOTO back to the test code.
doWhile
in interface InstructionBuilder
public InstructionBuilder increment(LocalVariable variable)
InstructionBuilder
increment
in interface InstructionBuilder
public InstructionBuilder arrayLength()
InstructionBuilder
arrayLength
in interface InstructionBuilder
public InstructionBuilder iterateArray(InstructionBuilderCallback callback)
InstructionBuilder
iterateArray
in interface InstructionBuilder
callback
- to invoke. The element will be the top value on the stack. The callback is responsible
for removing it from the stack.
public InstructionBuilder dupeWide()
InstructionBuilder
dupeWide
in interface InstructionBuilder
public InstructionBuilder popWide()
InstructionBuilder
popWide
in interface InstructionBuilder
public InstructionBuilder compareSpecial(String typeName)
InstructionBuilder
compareSpecial
in interface InstructionBuilder
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |