public class InstructionBuilderImpl extends Lockable implements org.apache.tapestry5.internal.plastic.asm.Opcodes, InstructionBuilder
| Modifier and Type | Field and Description |
|---|---|
protected NameCache |
cache |
protected InstructionBuilderState |
state |
protected org.apache.tapestry5.internal.plastic.asm.MethodVisitor |
v |
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_MANDATED, ACC_MODULE, ACC_NATIVE, ACC_OPEN, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_RECORD, ACC_STATIC, ACC_STATIC_PHASE, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_TRANSITIVE, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASM4, ASM5, ASM6, ASM7, ASM8, ASM9_EXPERIMENTAL, 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, SOURCE_DEPRECATED, SOURCE_MASK, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V_PREVIEW, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8, V10, V11, V12, V13, V14, V15, V9| Modifier and Type | Method and Description |
|---|---|
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. |
protected final InstructionBuilderState state
protected final org.apache.tapestry5.internal.plastic.asm.MethodVisitor v
public InstructionBuilder returnDefaultValue()
InstructionBuilderreturnDefaultValue in interface InstructionBuilderpublic InstructionBuilder loadThis()
InstructionBuilderloadThis in interface InstructionBuilderpublic InstructionBuilder loadNull()
InstructionBuilderloadNull in interface InstructionBuilderpublic InstructionBuilder loadArgument(int index)
InstructionBuilderloadArgument 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 InstructionBuilderpublic InstructionBuilder invokeSpecial(String containingClassName, MethodDescription description)
InstructionBuilderinvokeSpecial in interface InstructionBuildercontainingClassName - class name containing the methoddescription - describes the method name, parameters and return typepublic InstructionBuilder invokeVirtual(PlasticMethod method)
invokeVirtual in interface InstructionBuilderpublic InstructionBuilder invokeVirtual(String className, String returnType, String methodName, String... argumentTypes)
InstructionBuilderinvokeVirtual in interface InstructionBuilderpublic InstructionBuilder invokeInterface(String interfaceName, String returnType, String methodName, String... argumentTypes)
InstructionBuilderinvokeInterface in interface InstructionBuilderpublic InstructionBuilder invokeStatic(Class clazz, Class returnType, String methodName, Class... argumentTypes)
InstructionBuilderinvokeStatic in interface InstructionBuilderpublic InstructionBuilder invoke(Method method)
InstructionBuilderInstructionBuilder.invokeConstructor(Class, Class...)
for constructors and InstructionBuilder.invokeSpecial(String, MethodDescription) for private methods.invoke in interface InstructionBuilderpublic 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()
InstructionBuilderreturnResult in interface InstructionBuilderpublic InstructionBuilder boxPrimitive(String typeName)
InstructionBuilderboxPrimitive in interface InstructionBuilderpublic InstructionBuilder unboxPrimitive(String typeName)
InstructionBuilderunboxPrimitive in interface InstructionBuildertypeName - possibly primitive type namepublic 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 fieldpublic InstructionBuilder getStaticField(String className, String fieldName, String typeName)
InstructionBuildergetStaticField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldtypeName - type of fieldpublic InstructionBuilder getStaticField(String className, String fieldName, Class fieldType)
InstructionBuildergetStaticField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldfieldType - type of fieldpublic InstructionBuilder putStaticField(String className, String fieldName, Class fieldType)
InstructionBuilderputStaticField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldfieldType - type of fieldpublic InstructionBuilder putStaticField(String className, String fieldName, String typeName)
InstructionBuilderputStaticField 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 loadpublic InstructionBuilder putField(String className, String fieldName, String typeName)
InstructionBuilderputField in interface InstructionBuilderpublic InstructionBuilder putField(String className, String fieldName, Class fieldType)
putField in interface InstructionBuilderpublic InstructionBuilder getField(String className, String fieldName, Class fieldType)
InstructionBuildergetField in interface InstructionBuilderclassName - name of class containing the fieldfieldName - name of the fieldfieldType - type of fieldpublic InstructionBuilder loadArrayElement(int index, String elementType)
InstructionBuilderloadArrayElement 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()
InstructionBuilderloadArrayElement in interface InstructionBuilderpublic InstructionBuilder checkcast(String className)
InstructionBuildercheckcast in interface InstructionBuilderclassName - class to cast topublic InstructionBuilder checkcast(Class clazz)
checkcast in interface InstructionBuilderpublic InstructionBuilder startTryCatch(TryCatchCallback callback)
InstructionBuilderstartTryCatch in interface InstructionBuildercallback - allows generation of try, catch, and finally clausespublic InstructionBuilder newInstance(String className)
InstructionBuildernewInstance 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 instantiatepublic InstructionBuilder invokeConstructor(String className, String... argumentTypes)
InstructionBuilderinvokeConstructor in interface InstructionBuilderclassName - the class containing the constructorargumentTypes - java type names for each argument of the constructorpublic InstructionBuilder invokeConstructor(Class clazz, Class... argumentTypes)
invokeConstructor in interface InstructionBuilderpublic InstructionBuilder dupe(int depth)
InstructionBuilderdupe 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()
InstructionBuilderpop in interface InstructionBuilderpublic InstructionBuilder swap()
InstructionBuilderswap in interface InstructionBuilderpublic InstructionBuilder loadConstant(Object constant)
InstructionBuilderloadConstant in interface InstructionBuilderconstant - Integer, Float, Double, Long, String or nullpublic InstructionBuilder loadTypeConstant(String typeName)
InstructionBuilderloadTypeConstant in interface InstructionBuildertypeName - Java class namepublic InstructionBuilder loadTypeConstant(Class clazz)
InstructionBuilderloadTypeConstant in interface InstructionBuilderclazz - Java type to load as a constantpublic InstructionBuilder castOrUnbox(String typeName)
InstructionBuildercastOrUnbox in interface InstructionBuildertypeName - to cast or unbox topublic InstructionBuilder throwException(String className, String message)
InstructionBuilderthrowException 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()
InstructionBuilderthrowException in interface InstructionBuilderpublic InstructionBuilder startSwitch(int min, int max, SwitchCallback callback)
InstructionBuilderstartSwitch in interface InstructionBuildermin - the minimum value to match againstmax - the maximum value to match againstpublic InstructionBuilder startVariable(String type, LocalVariableCallback callback)
InstructionBuilderstartVariable 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 InstructionBuilderpublic 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 truepublic 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 blockspublic 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)
InstructionBuilderincrement in interface InstructionBuilderpublic InstructionBuilder arrayLength()
InstructionBuilderarrayLength in interface InstructionBuilderpublic InstructionBuilder iterateArray(InstructionBuilderCallback callback)
InstructionBuilderiterateArray 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()
InstructionBuilderdupeWide in interface InstructionBuilderpublic InstructionBuilder popWide()
InstructionBuilderpopWide in interface InstructionBuilderpublic InstructionBuilder compareSpecial(String typeName)
InstructionBuildercompareSpecial in interface InstructionBuilder5.6.4 - Copyright © 2003-2021 The Apache Software Foundation.