|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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 InstructionBuilderpublic InstructionBuilder loadThis()
InstructionBuilder
loadThis in interface InstructionBuilderpublic InstructionBuilder loadNull()
InstructionBuilder
loadNull in interface InstructionBuilderpublic InstructionBuilder loadArgument(int index)
InstructionBuilder
loadArgument in interface InstructionBuilderindex - to argument (0 is the first argument, not this)public InstructionBuilder loadArguments()
InstructionBuilderInstructionBuilder.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 InstructionBuildercontainingClassName - 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 InstructionBuilderpublic InstructionBuilder invoke(Method method)
InstructionBuilderInstructionBuilder.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)
InstructionBuilderInstructionBuilder.invokeConstructor(Class, Class...)
for constructors and InstructionBuilder.invokeSpecial(String, MethodDescription) for private methods.
invoke in interface InstructionBuilderpublic InstructionBuilder returnResult()
InstructionBuilder
returnResult in interface InstructionBuilderpublic InstructionBuilder boxPrimitive(String typeName)
InstructionBuilder
boxPrimitive in interface InstructionBuilderpublic InstructionBuilder unboxPrimitive(String typeName)
InstructionBuilder
unboxPrimitive in interface InstructionBuildertypeName - possibly primitive type name
public InstructionBuilder getField(String className,
String fieldName,
String typeName)
InstructionBuilderInstructionBuilder.loadThis()).
getField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldtypeName - type of field
public InstructionBuilder getStaticField(String className,
String fieldName,
String typeName)
InstructionBuilder
getStaticField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldtypeName - type of field
public InstructionBuilder getStaticField(String className,
String fieldName,
Class fieldType)
InstructionBuilder
getStaticField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldfieldType - type of field
public InstructionBuilder putStaticField(String className,
String fieldName,
Class fieldType)
InstructionBuilder
putStaticField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldfieldType - type of field
public InstructionBuilder putStaticField(String className,
String fieldName,
String typeName)
InstructionBuilder
putStaticField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldtypeName - type of fieldpublic InstructionBuilder getField(PlasticField field)
InstructionBuilderInstructionBuilder.loadThis()).
getField in interface InstructionBuilderfield - identifies name, type and container of field to load
public 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 InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldfieldType - type of field
public InstructionBuilder loadArrayElement(int index,
String elementType)
InstructionBuilder
loadArrayElement in interface InstructionBuilderindex - 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 InstructionBuilderpublic InstructionBuilder checkcast(String className)
InstructionBuilder
checkcast in interface InstructionBuilderclassName - class to cast topublic InstructionBuilder checkcast(Class clazz)
checkcast in interface InstructionBuilderpublic InstructionBuilder startTryCatch(TryCatchCallback callback)
InstructionBuilder
startTryCatch in interface InstructionBuildercallback - allows generation of try, catch, and finally clausespublic InstructionBuilder newInstance(String className)
InstructionBuilder
newInstance in interface InstructionBuilderclassName - of class to instantiatepublic InstructionBuilder newInstance(Class clazz)
InstructionBuilderInstructionBuilder.newInstance(String) used when the class is known
at build time.
newInstance in interface InstructionBuilderclazz - to instantiate
public InstructionBuilder invokeConstructor(String className,
String... argumentTypes)
InstructionBuilder
invokeConstructor in interface InstructionBuilderclassName - the class containing the constructorargumentTypes - java type names for each argument of the constructor
public InstructionBuilder invokeConstructor(Class clazz,
Class... argumentTypes)
invokeConstructor in interface InstructionBuilderpublic InstructionBuilder dupe(int depth)
InstructionBuilder
dupe in interface InstructionBuilderdepth - 0 (DUP), 1 (DUP_X1) or 2 (DUP_X2)public InstructionBuilder dupe()
InstructionBuilderInstructionBuilder.when(Condition, WhenCallback).
dupe in interface InstructionBuilderInstructionBuilder.dupe(int)public InstructionBuilder pop()
InstructionBuilder
pop in interface InstructionBuilderpublic InstructionBuilder swap()
InstructionBuilder
swap in interface InstructionBuilderpublic InstructionBuilder loadConstant(Object constant)
InstructionBuilder
loadConstant in interface InstructionBuilderconstant - Integer, Float, Double, Long, String or nullpublic InstructionBuilder loadTypeConstant(String typeName)
InstructionBuilder
loadTypeConstant in interface InstructionBuildertypeName - Java class namepublic InstructionBuilder loadTypeConstant(Class clazz)
InstructionBuilder
loadTypeConstant in interface InstructionBuilderclazz - Java type to load as a constantpublic InstructionBuilder castOrUnbox(String typeName)
InstructionBuilder
castOrUnbox in interface InstructionBuildertypeName - to cast or unbox to
public InstructionBuilder throwException(String className,
String message)
InstructionBuilder
throwException in interface InstructionBuilderclassName - 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 InstructionBuilderpublic InstructionBuilder throwException()
InstructionBuilder
throwException in interface InstructionBuilder
public InstructionBuilder startSwitch(int min,
int max,
SwitchCallback callback)
InstructionBuilder
startSwitch in interface InstructionBuildermin - the minimum value to match againstmax - the maximum value to match against
public InstructionBuilder startVariable(String type,
LocalVariableCallback callback)
InstructionBuilder
startVariable in interface InstructionBuildertype - type of local variablecallback - generates code used when variable is in effectpublic InstructionBuilder storeVariable(LocalVariable var)
InstructionBuilderInstructionBuilder.startVariable(String, LocalVariableCallback).
storeVariable in interface InstructionBuilderpublic InstructionBuilder loadVariable(LocalVariable var)
InstructionBuilderInstructionBuilder.startVariable(String, LocalVariableCallback).
loadVariable in interface InstructionBuilder
public InstructionBuilder when(Condition condition,
InstructionBuilderCallback ifTrue)
InstructionBuilderInstructionBuilder.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 InstructionBuildercondition - to evaluateifTrue - generates code for when condition is true
public InstructionBuilder when(Condition condition,
WhenCallback callback)
InstructionBuilderCondition. The testing opcodes all pop
the value off the stack, so this is usually preceded by dupe(0).
when in interface InstructionBuildercondition - defines true and false casescallback - provides code for true and false blocks
public InstructionBuilder doWhile(Condition condition,
WhileCallback callback)
InstructionBuilderWhileCallback.buildBody(InstructionBuilder) is executed, and then a GOTO back to the test code.
doWhile in interface InstructionBuilderpublic InstructionBuilder increment(LocalVariable variable)
InstructionBuilder
increment in interface InstructionBuilderpublic InstructionBuilder arrayLength()
InstructionBuilder
arrayLength in interface InstructionBuilderpublic InstructionBuilder iterateArray(InstructionBuilderCallback callback)
InstructionBuilder
iterateArray in interface InstructionBuildercallback - 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 InstructionBuilderpublic InstructionBuilder popWide()
InstructionBuilder
popWide in interface InstructionBuilderpublic 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 | |||||||||