Class InstructionBuilderImpl
- java.lang.Object
-
- org.apache.tapestry5.internal.plastic.Lockable
-
- org.apache.tapestry5.internal.plastic.InstructionBuilderImpl
-
- All Implemented Interfaces:
org.apache.tapestry5.internal.plastic.asm.Opcodes,InstructionBuilder
public class InstructionBuilderImpl extends Lockable implements org.apache.tapestry5.internal.plastic.asm.Opcodes, InstructionBuilder
-
-
Field Summary
Fields Modifier and Type Field Description protected NameCachecacheprotected InstructionBuilderStatestateprotected org.apache.tapestry5.internal.plastic.asm.MethodVisitorv-
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_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, ASM10_EXPERIMENTAL, ASM4, ASM5, ASM6, ASM7, ASM8, ASM9, 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, V16, V17, V18, V9
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstructionBuilderarrayLength()Expects the top object on the stack to be an array.InstructionBuilderboxPrimitive(java.lang.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.InstructionBuildercastOrUnbox(java.lang.String typeName)Casts the object on top of the stack to the indicated type.InstructionBuildercheckcast(java.lang.Class clazz)InstructionBuildercheckcast(java.lang.String className)Adds a check that the object on top of the stack is assignable to the indicated class.InstructionBuildercompareSpecial(java.lang.String typeName)Special comparison logic for primitive float, double and long.InstructionBuilderdoWhile(Condition condition, WhileCallback callback)Implements a simple loop based on a condition.InstructionBuilderdupe()Duplicates the top object on the stack.InstructionBuilderdupe(int depth)Duplicates the top object on the stack, placing the result at some depth.InstructionBuilderdupeWide()Duplicates a wide value (a primitive long or double).InstructionBuildergetField(java.lang.String className, java.lang.String fieldName, java.lang.Class fieldType)Loads a field onto the stack.InstructionBuildergetField(java.lang.String className, java.lang.String fieldName, java.lang.String typeName)Loads an instance field onto the stack.InstructionBuildergetField(PlasticField field)Loads an instance or static field onto the stack.InstructionBuildergetStaticField(java.lang.String className, java.lang.String fieldName, java.lang.Class fieldType)Gets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack.InstructionBuildergetStaticField(java.lang.String className, java.lang.String fieldName, java.lang.String typeName)Gets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack.InstructionBuilderincrement(LocalVariable variable)Increments a local integer variable.InstructionBuilderinvoke(java.lang.Class clazz, java.lang.Class returnType, java.lang.String methodName, java.lang.Class... argumentTypes)Automatically invokes an interface or virtual method.InstructionBuilderinvoke(java.lang.reflect.Method method)Automatically invokes an interface or virtual method.InstructionBuilderinvokeConstructor(java.lang.Class clazz, java.lang.Class... argumentTypes)InstructionBuilderinvokeConstructor(java.lang.String className, java.lang.String... argumentTypes)Invokes a constructor on a class.InstructionBuilderinvokeInterface(java.lang.String interfaceName, java.lang.String returnType, java.lang.String methodName, java.lang.String... argumentTypes)Invokes a standard virtual method.InstructionBuilderinvokeSpecial(java.lang.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.InstructionBuilderinvokeStatic(java.lang.Class clazz, java.lang.Class returnType, java.lang.String methodName, java.lang.Class... argumentTypes)Invokes a static method of a class.InstructionBuilderinvokeVirtual(java.lang.String className, java.lang.String returnType, java.lang.String methodName, java.lang.String... argumentTypes)Invokes a standard virtual method.InstructionBuilderinvokeVirtual(PlasticMethod method)InstructionBuilderiterateArray(InstructionBuilderCallback callback)Expects an array to be the top value on the stack.InstructionBuilderloadArgument(int index)Loads an argument onto the stack, using the opcode appropriate to the argument's type.InstructionBuilderloadArguments()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).InstructionBuilderloadArrayElement()Loads a value from an array object.InstructionBuilderloadArrayElement(int index, java.lang.String elementType)Loads a value from an array object, which must be the top element of the stack.InstructionBuilderloadConstant(java.lang.Object constant)Loads a constant valueInstructionBuilderloadNull()Loads the null constant onto the stack.InstructionBuilderloadThis()Loads this onto the stack.InstructionBuilderloadTypeConstant(java.lang.Class clazz)Loads a Java type (a Class instance) as a constant.InstructionBuilderloadTypeConstant(java.lang.String typeName)Loads a Java type (a Class instance) as a constant.InstructionBuilderloadVariable(LocalVariable var)Loads a value from a local variable and pushes it onto the stack.InstructionBuildernewInstance(java.lang.Class clazz)A convenience version ofInstructionBuilder.newInstance(String)used when the class is known at build time.InstructionBuildernewInstance(java.lang.String className)Creates a new, uninitialized instance of the indicated class.InstructionBuilderpop()Discards the top value on the stack.InstructionBuilderpopWide()Pops a wide value (a primitive long or double).InstructionBuilderputField(java.lang.String className, java.lang.String fieldName, java.lang.Class fieldType)InstructionBuilderputField(java.lang.String className, java.lang.String fieldName, java.lang.String typeName)Expects the stack to contain the instance to update, and the value to store into the field.InstructionBuilderputStaticField(java.lang.String className, java.lang.String fieldName, java.lang.Class fieldType)Sets a static field; the new field value should be on top of the stack.InstructionBuilderputStaticField(java.lang.String className, java.lang.String fieldName, java.lang.String typeName)Sets a static field; the new field value should be on top of the stack.InstructionBuilderreturnDefaultValue()Returns the default value for the method, which may be null, or a specific primitive value.InstructionBuilderreturnResult()Returns the top value on the stack.InstructionBuilderstartSwitch(int min, int max, SwitchCallback callback)Starts a switch statement.InstructionBuilderstartTryCatch(TryCatchCallback callback)Defines the start of a block that can have exception handlers and finally blocks applied.InstructionBuilderstartVariable(java.lang.String type, LocalVariableCallback callback)Starts a block where the given name is active.InstructionBuilderstoreVariable(LocalVariable var)Stores the value on top of the stack to a local variable (previously defined byInstructionBuilder.startVariable(String, LocalVariableCallback).InstructionBuilderswap()Swaps the top element of the stack with the next element down.InstructionBuilderthrowException()Throws the exception on the top of the stack.InstructionBuilderthrowException(java.lang.Class<? extends java.lang.Throwable> exceptionType, java.lang.String message)InstructionBuilderthrowException(java.lang.String className, java.lang.String message)Throws an exception with a fixed message.InstructionBuilderunboxPrimitive(java.lang.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).InstructionBuilderwhen(Condition condition, InstructionBuilderCallback ifTrue)Simplified version ofInstructionBuilder.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).InstructionBuilderwhen(Condition condition, WhenCallback callback)Executes conditional code based on aCondition.
-
-
-
Field Detail
-
state
protected final InstructionBuilderState state
-
v
protected final org.apache.tapestry5.internal.plastic.asm.MethodVisitor v
-
-
Method Detail
-
returnDefaultValue
public InstructionBuilder returnDefaultValue()
Description copied from interface:InstructionBuilderReturns the default value for the method, which may be null, or a specific primitive value.- Specified by:
returnDefaultValuein interfaceInstructionBuilder
-
loadThis
public InstructionBuilder loadThis()
Description copied from interface:InstructionBuilderLoads this onto the stack.- Specified by:
loadThisin interfaceInstructionBuilder
-
loadNull
public InstructionBuilder loadNull()
Description copied from interface:InstructionBuilderLoads the null constant onto the stack.- Specified by:
loadNullin interfaceInstructionBuilder
-
loadArgument
public InstructionBuilder loadArgument(int index)
Description copied from interface:InstructionBuilderLoads an argument onto the stack, using the opcode appropriate to the argument's type. In addition this automatically adjusts for arguments of primitive type long or double (which take up two local variable indexes, rather than one as for all other types)- Specified by:
loadArgumentin interfaceInstructionBuilder- Parameters:
index- to argument (0 is the first argument, not this)
-
loadArguments
public InstructionBuilder loadArguments()
Description copied from interface:InstructionBuilderLoads 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). A call toInstructionBuilder.loadThis()(or some other way of identifying the target method) should precede this call.- Specified by:
loadArgumentsin interfaceInstructionBuilder
-
invokeSpecial
public InstructionBuilder invokeSpecial(java.lang.String containingClassName, MethodDescription description)
Description copied from interface:InstructionBuilderInvokes an instance method of a base class, or a private method of a class, using the target object and parameters already on the stack. Leaves the result on the stack (unless its a void method).- Specified by:
invokeSpecialin interfaceInstructionBuilder- Parameters:
containingClassName- class name containing the methoddescription- describes the method name, parameters and return type
-
invokeVirtual
public InstructionBuilder invokeVirtual(PlasticMethod method)
- Specified by:
invokeVirtualin interfaceInstructionBuilder
-
invokeVirtual
public InstructionBuilder invokeVirtual(java.lang.String className, java.lang.String returnType, java.lang.String methodName, java.lang.String... argumentTypes)
Description copied from interface:InstructionBuilderInvokes a standard virtual method.- Specified by:
invokeVirtualin interfaceInstructionBuilder
-
invokeInterface
public InstructionBuilder invokeInterface(java.lang.String interfaceName, java.lang.String returnType, java.lang.String methodName, java.lang.String... argumentTypes)
Description copied from interface:InstructionBuilderInvokes a standard virtual method.- Specified by:
invokeInterfacein interfaceInstructionBuilder
-
invokeStatic
public InstructionBuilder invokeStatic(java.lang.Class clazz, java.lang.Class returnType, java.lang.String methodName, java.lang.Class... argumentTypes)
Description copied from interface:InstructionBuilderInvokes a static method of a class.- Specified by:
invokeStaticin interfaceInstructionBuilder
-
invoke
public InstructionBuilder invoke(java.lang.reflect.Method method)
Description copied from interface:InstructionBuilderAutomatically invokes an interface or virtual method. Remember to useInstructionBuilder.invokeConstructor(Class, Class...)for constructors andInstructionBuilder.invokeSpecial(String, MethodDescription)for private methods.- Specified by:
invokein interfaceInstructionBuilder
-
invoke
public InstructionBuilder invoke(java.lang.Class clazz, java.lang.Class returnType, java.lang.String methodName, java.lang.Class... argumentTypes)
Description copied from interface:InstructionBuilderAutomatically invokes an interface or virtual method. Remember to useInstructionBuilder.invokeConstructor(Class, Class...)for constructors andInstructionBuilder.invokeSpecial(String, MethodDescription)for private methods.- Specified by:
invokein interfaceInstructionBuilder
-
returnResult
public InstructionBuilder returnResult()
Description copied from interface:InstructionBuilderReturns the top value on the stack. For void methods, no value should be on the stack and the method will simply return.- Specified by:
returnResultin interfaceInstructionBuilder
-
boxPrimitive
public InstructionBuilder boxPrimitive(java.lang.String typeName)
Description copied from interface:InstructionBuilderIf 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. Does nothing if the type is not primitive, or type void.- Specified by:
boxPrimitivein interfaceInstructionBuilder
-
unboxPrimitive
public InstructionBuilder unboxPrimitive(java.lang.String typeName)
Description copied from interface:InstructionBuilderUnboxes 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). Does nothing for non-primitive types.- Specified by:
unboxPrimitivein interfaceInstructionBuilder- Parameters:
typeName- possibly primitive type name
-
getField
public InstructionBuilder getField(java.lang.String className, java.lang.String fieldName, java.lang.String typeName)
Description copied from interface:InstructionBuilderLoads an instance field onto the stack. The object containing the field should already be loaded onto the stack (usually, viaInstructionBuilder.loadThis()).- Specified by:
getFieldin interfaceInstructionBuilder- Parameters:
className- name of class containing the fieldfieldName- name of the fieldtypeName- type of field
-
getStaticField
public InstructionBuilder getStaticField(java.lang.String className, java.lang.String fieldName, java.lang.String typeName)
Description copied from interface:InstructionBuilderGets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack.- Specified by:
getStaticFieldin interfaceInstructionBuilder- Parameters:
className- name of class containing the fieldfieldName- name of the fieldtypeName- type of field
-
getStaticField
public InstructionBuilder getStaticField(java.lang.String className, java.lang.String fieldName, java.lang.Class fieldType)
Description copied from interface:InstructionBuilderGets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack.- Specified by:
getStaticFieldin interfaceInstructionBuilder- Parameters:
className- name of class containing the fieldfieldName- name of the fieldfieldType- type of field
-
putStaticField
public InstructionBuilder putStaticField(java.lang.String className, java.lang.String fieldName, java.lang.Class fieldType)
Description copied from interface:InstructionBuilderSets a static field; the new field value should be on top of the stack.- Specified by:
putStaticFieldin interfaceInstructionBuilder- Parameters:
className- name of class containing the fieldfieldName- name of the fieldfieldType- type of field
-
putStaticField
public InstructionBuilder putStaticField(java.lang.String className, java.lang.String fieldName, java.lang.String typeName)
Description copied from interface:InstructionBuilderSets a static field; the new field value should be on top of the stack.- Specified by:
putStaticFieldin interfaceInstructionBuilder- Parameters:
className- name of class containing the fieldfieldName- name of the fieldtypeName- type of field
-
getField
public InstructionBuilder getField(PlasticField field)
Description copied from interface:InstructionBuilderLoads an instance or static field onto the stack. The plastic class instance containing the field should already be loaded onto the stack (usually, viaInstructionBuilder.loadThis()).- Specified by:
getFieldin interfaceInstructionBuilder- Parameters:
field- identifies name, type and container of field to load
-
putField
public InstructionBuilder putField(java.lang.String className, java.lang.String fieldName, java.lang.String typeName)
Description copied from interface:InstructionBuilderExpects the stack to contain the instance to update, and the value to store into the field.- Specified by:
putFieldin interfaceInstructionBuilder
-
putField
public InstructionBuilder putField(java.lang.String className, java.lang.String fieldName, java.lang.Class fieldType)
- Specified by:
putFieldin interfaceInstructionBuilder
-
getField
public InstructionBuilder getField(java.lang.String className, java.lang.String fieldName, java.lang.Class fieldType)
Description copied from interface:InstructionBuilderLoads a field onto the stack. This version is used when the field type is known at build time, rather than discovered at runtime.- Specified by:
getFieldin interfaceInstructionBuilder- Parameters:
className- name of class containing the fieldfieldName- name of the fieldfieldType- type of field
-
loadArrayElement
public InstructionBuilder loadArrayElement(int index, java.lang.String elementType)
Description copied from interface:InstructionBuilderLoads a value from an array object, which must be the top element of the stack.- Specified by:
loadArrayElementin interfaceInstructionBuilder- Parameters:
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 primitives
-
loadArrayElement
public InstructionBuilder loadArrayElement()
Description copied from interface:InstructionBuilderLoads a value from an array object. The stack should have the array at depth 1, and an array index on top. Only object arrays (not arrays of primitives) are supported.- Specified by:
loadArrayElementin interfaceInstructionBuilder
-
checkcast
public InstructionBuilder checkcast(java.lang.String className)
Description copied from interface:InstructionBuilderAdds a check that the object on top of the stack is assignable to the indicated class.- Specified by:
checkcastin interfaceInstructionBuilder- Parameters:
className- class to cast to
-
checkcast
public InstructionBuilder checkcast(java.lang.Class clazz)
- Specified by:
checkcastin interfaceInstructionBuilder
-
startTryCatch
public InstructionBuilder startTryCatch(TryCatchCallback callback)
Description copied from interface:InstructionBuilderDefines the start of a block that can have exception handlers and finally blocks applied. Continue using this InstructionBuilder to define code inside the block, then call methods on the InstructionBlock to define the end of the block and set up handlers.- Specified by:
startTryCatchin interfaceInstructionBuilder- Parameters:
callback- allows generation of try, catch, and finally clauses
-
newInstance
public InstructionBuilder newInstance(java.lang.String className)
Description copied from interface:InstructionBuilderCreates a new, uninitialized instance of the indicated class. This should be followed by code to call the new instance's constructor.- Specified by:
newInstancein interfaceInstructionBuilder- Parameters:
className- of class to instantiate
-
newInstance
public InstructionBuilder newInstance(java.lang.Class clazz)
Description copied from interface:InstructionBuilderA convenience version ofInstructionBuilder.newInstance(String)used when the class is known at build time.- Specified by:
newInstancein interfaceInstructionBuilder- Parameters:
clazz- to instantiate
-
invokeConstructor
public InstructionBuilder invokeConstructor(java.lang.String className, java.lang.String... argumentTypes)
Description copied from interface:InstructionBuilderInvokes a constructor on a class. The instance should already be on the stack, followed by the right number and type of parameters. Note that a constructor acts like a void method, so you will often follow the sequence: newInstance(), dupe(0), invokeConstructor() so that a reference to the instance is left on the stack.F- Specified by:
invokeConstructorin interfaceInstructionBuilder- Parameters:
className- the class containing the constructorargumentTypes- java type names for each argument of the constructor
-
invokeConstructor
public InstructionBuilder invokeConstructor(java.lang.Class clazz, java.lang.Class... argumentTypes)
- Specified by:
invokeConstructorin interfaceInstructionBuilder
-
dupe
public InstructionBuilder dupe(int depth)
Description copied from interface:InstructionBuilderDuplicates the top object on the stack, placing the result at some depth.- Specified by:
dupein interfaceInstructionBuilder- Parameters:
depth- 0 (DUP), 1 (DUP_X1) or 2 (DUP_X2)
-
dupe
public InstructionBuilder dupe()
Description copied from interface:InstructionBuilderDuplicates the top object on the stack. Commonly used withInstructionBuilder.when(Condition, WhenCallback).- Specified by:
dupein interfaceInstructionBuilder- See Also:
InstructionBuilder.dupe(int)
-
pop
public InstructionBuilder pop()
Description copied from interface:InstructionBuilderDiscards the top value on the stack. Assumes the value is a single word value: an object reference, or a small primitive) and not a double or long.- Specified by:
popin interfaceInstructionBuilder
-
swap
public InstructionBuilder swap()
Description copied from interface:InstructionBuilderSwaps the top element of the stack with the next element down. Note that this can cause problems if the top element on the stack is a long or double.- Specified by:
swapin interfaceInstructionBuilder
-
loadConstant
public InstructionBuilder loadConstant(java.lang.Object constant)
Description copied from interface:InstructionBuilderLoads a constant value- Specified by:
loadConstantin interfaceInstructionBuilder- Parameters:
constant- Integer, Float, Double, Long, String or null
-
loadTypeConstant
public InstructionBuilder loadTypeConstant(java.lang.String typeName)
Description copied from interface:InstructionBuilderLoads a Java type (a Class instance) as a constant. This assumes the type name is the name of class (or array) but not a primitive type.- Specified by:
loadTypeConstantin interfaceInstructionBuilder- Parameters:
typeName- Java class name
-
loadTypeConstant
public InstructionBuilder loadTypeConstant(java.lang.Class clazz)
Description copied from interface:InstructionBuilderLoads a Java type (a Class instance) as a constant. This assumes the type name is the name of class (or array) but not a primitive type.- Specified by:
loadTypeConstantin interfaceInstructionBuilder- Parameters:
clazz- Java type to load as a constant
-
castOrUnbox
public InstructionBuilder castOrUnbox(java.lang.String typeName)
Description copied from interface:InstructionBuilderCasts the object on top of the stack to the indicated type. For primitive types, casts to the wrapper type and invokes the appropriate unboxing static method call, leaving a primitive type value on the stack.- Specified by:
castOrUnboxin interfaceInstructionBuilder- Parameters:
typeName- to cast or unbox to
-
throwException
public InstructionBuilder throwException(java.lang.String className, java.lang.String message)
Description copied from interface:InstructionBuilderThrows an exception with a fixed message. Assumes the exception class includes a constructor that takes a single string.- Specified by:
throwExceptionin interfaceInstructionBuilder- Parameters:
className- name of exception class to instantiatemessage- message (passed as first and only parameter to constructor)
-
throwException
public InstructionBuilder throwException(java.lang.Class<? extends java.lang.Throwable> exceptionType, java.lang.String message)
- Specified by:
throwExceptionin interfaceInstructionBuilder
-
throwException
public InstructionBuilder throwException()
Description copied from interface:InstructionBuilderThrows the exception on the top of the stack.- Specified by:
throwExceptionin interfaceInstructionBuilder
-
startSwitch
public InstructionBuilder startSwitch(int min, int max, SwitchCallback callback)
Description copied from interface:InstructionBuilderStarts a switch statement.- Specified by:
startSwitchin interfaceInstructionBuilder- Parameters:
min- the minimum value to match againstmax- the maximum value to match against
-
startVariable
public InstructionBuilder startVariable(java.lang.String type, LocalVariableCallback callback)
Description copied from interface:InstructionBuilderStarts a block where the given name is active.- Specified by:
startVariablein interfaceInstructionBuilder- Parameters:
type- type of local variablecallback- generates code used when variable is in effect
-
storeVariable
public InstructionBuilder storeVariable(LocalVariable var)
Description copied from interface:InstructionBuilderStores the value on top of the stack to a local variable (previously defined byInstructionBuilder.startVariable(String, LocalVariableCallback).- Specified by:
storeVariablein interfaceInstructionBuilder
-
loadVariable
public InstructionBuilder loadVariable(LocalVariable var)
Description copied from interface:InstructionBuilderLoads a value from a local variable and pushes it onto the stack. The variable is defined byInstructionBuilder.startVariable(String, LocalVariableCallback).- Specified by:
loadVariablein interfaceInstructionBuilder
-
when
public InstructionBuilder when(Condition condition, InstructionBuilderCallback ifTrue)
Description copied from interface:InstructionBuilderSimplified version ofInstructionBuilder.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 bydupe(0).- Specified by:
whenin interfaceInstructionBuilder- Parameters:
condition- to evaluateifTrue- generates code for when condition is true- Returns:
- this builder
-
when
public InstructionBuilder when(Condition condition, WhenCallback callback)
Description copied from interface:InstructionBuilderExecutes conditional code based on aCondition. The testing opcodes all pop the value off the stack, so this is usually preceded bydupe(0).- Specified by:
whenin interfaceInstructionBuilder- Parameters:
condition- defines true and false casescallback- provides code for true and false blocks- Returns:
- this builder
-
doWhile
public InstructionBuilder doWhile(Condition condition, WhileCallback callback)
Description copied from interface:InstructionBuilderImplements a simple loop based on a condition. First the WhileCallback.buildTest(InstructionBuilder) code is executed, then the condition is evaluated (which will consume at least the top value on the stack). When the condition is false, the loop is exited. When the condition is true, the code defined byWhileCallback.buildBody(InstructionBuilder)is executed, and then a GOTO back to the test code.- Specified by:
doWhilein interfaceInstructionBuilder- Returns:
- this builder
-
increment
public InstructionBuilder increment(LocalVariable variable)
Description copied from interface:InstructionBuilderIncrements a local integer variable.- Specified by:
incrementin interfaceInstructionBuilder- Returns:
- this builder
-
arrayLength
public InstructionBuilder arrayLength()
Description copied from interface:InstructionBuilderExpects the top object on the stack to be an array. Replaces it with the length of that array.- Specified by:
arrayLengthin interfaceInstructionBuilder
-
iterateArray
public InstructionBuilder iterateArray(InstructionBuilderCallback callback)
Description copied from interface:InstructionBuilderExpects an array to be the top value on the stack. Iterates the array. The callback generates code that will have each successive value from the array as the top value on the stack. Creates a variable to store the loop index.- Specified by:
iterateArrayin interfaceInstructionBuilder- Parameters:
callback- to invoke. The element will be the top value on the stack. The callback is responsible for removing it from the stack.- Returns:
- this builder
-
dupeWide
public InstructionBuilder dupeWide()
Description copied from interface:InstructionBuilderDuplicates a wide value (a primitive long or double).- Specified by:
dupeWidein interfaceInstructionBuilder
-
popWide
public InstructionBuilder popWide()
Description copied from interface:InstructionBuilderPops a wide value (a primitive long or double).- Specified by:
popWidein interfaceInstructionBuilder
-
compareSpecial
public InstructionBuilder compareSpecial(java.lang.String typeName)
Description copied from interface:InstructionBuilderSpecial comparison logic for primitive float, double and long. Expect two matching wide values on the stack. Reduces the two wide values to a single int value: -1, 0, or 1 depending on whether the deeper value is less than, equal to, or greater than the top value on the stack.- Specified by:
compareSpecialin interfaceInstructionBuilder
-
-