Class InstructionBuilderImpl
-
- 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 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_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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstructionBuilder
arrayLength()
Expects the top object on the stack to be an array.InstructionBuilder
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
typeName)
Casts the object on top of the stack to the indicated type.InstructionBuilder
clazz)
InstructionBuilder
className)
Adds a check that the object on top of the stack is assignable to the indicated class.InstructionBuilder
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
className, fieldName, fieldType)
Loads a field onto the stack.InstructionBuilder
className, fieldName, typeName)
Loads an instance field onto the stack.InstructionBuilder
getField(PlasticField field)
Loads an instance or static field onto the stack.InstructionBuilder
className, fieldName, fieldType)
Gets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack.InstructionBuilder
className, fieldName, 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
clazz, returnType, methodName, ... argumentTypes)
Automatically invokes an interface or virtual method.InstructionBuilder
method)
Automatically invokes an interface or virtual method.InstructionBuilder
clazz, ... argumentTypes)
InstructionBuilder
className, ... argumentTypes)
Invokes a constructor on a class.InstructionBuilder
interfaceName, returnType, methodName, ... argumentTypes)
Invokes a standard virtual method.InstructionBuilder
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
clazz, returnType, methodName, ... argumentTypes)
Invokes a static method of a class.InstructionBuilder
className, returnType, methodName, ... argumentTypes)
Invokes a standard virtual method.InstructionBuilder
invokeVirtual(PlasticMethod 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, elementType)
Loads a value from an array object, which must be the top element of the stack.InstructionBuilder
constant)
Loads a constant valueInstructionBuilder
loadNull()
Loads the null constant onto the stack.InstructionBuilder
loadThis()
Loads this onto the stack.InstructionBuilder
clazz)
Loads a Java type (a Class instance) as a constant.InstructionBuilder
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
clazz)
A convenience version ofInstructionBuilder.newInstance(String)
used when the class is known at build time.InstructionBuilder
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
className, fieldName, fieldType)
InstructionBuilder
className, fieldName, typeName)
Expects the stack to contain the instance to update, and the value to store into the field.InstructionBuilder
className, fieldName, fieldType)
Sets a static field; the new field value should be on top of the stack.InstructionBuilder
className, fieldName, 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
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 byInstructionBuilder.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
<? extends > exceptionType, message)
InstructionBuilder
className, message)
Throws an exception with a fixed message.InstructionBuilder
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 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).InstructionBuilder
when(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:InstructionBuilder
Returns the default value for the method, which may be null, or a specific primitive value.- Specified by:
returnDefaultValue
in interfaceInstructionBuilder
-
loadThis
public InstructionBuilder loadThis()
Description copied from interface:InstructionBuilder
Loads this onto the stack.- Specified by:
loadThis
in interfaceInstructionBuilder
-
loadNull
public InstructionBuilder loadNull()
Description copied from interface:InstructionBuilder
Loads the null constant onto the stack.- Specified by:
loadNull
in interfaceInstructionBuilder
-
loadArgument
public InstructionBuilder loadArgument(int index)
Description copied from interface:InstructionBuilder
Loads 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:
loadArgument
in interfaceInstructionBuilder
- Parameters:
index
- to argument (0 is the first argument, not this)
-
loadArguments
public InstructionBuilder loadArguments()
Description copied from interface:InstructionBuilder
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). A call toInstructionBuilder.loadThis()
(or some other way of identifying the target method) should precede this call.- Specified by:
loadArguments
in interfaceInstructionBuilder
-
invokeSpecial
public containingClassName, MethodDescription description)
Description copied from interface:InstructionBuilder
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. Leaves the result on the stack (unless its a void method).- Specified by:
invokeSpecial
in interfaceInstructionBuilder
- Parameters:
containingClassName
- class name containing the methoddescription
- describes the method name, parameters and return type
-
invokeVirtual
public InstructionBuilder invokeVirtual(PlasticMethod method)
- Specified by:
invokeVirtual
in interfaceInstructionBuilder
-
invokeVirtual
public className, returnType, methodName, ... argumentTypes)
Description copied from interface:InstructionBuilder
Invokes a standard virtual method.- Specified by:
invokeVirtual
in interfaceInstructionBuilder
-
invokeInterface
public interfaceName, returnType, methodName, ... argumentTypes)
Description copied from interface:InstructionBuilder
Invokes a standard virtual method.- Specified by:
invokeInterface
in interfaceInstructionBuilder
-
invokeStatic
public clazz, returnType, methodName, ... argumentTypes)
Description copied from interface:InstructionBuilder
Invokes a static method of a class.- Specified by:
invokeStatic
in interfaceInstructionBuilder
-
invoke
public method)
Description copied from interface:InstructionBuilder
Automatically invokes an interface or virtual method. Remember to useInstructionBuilder.invokeConstructor(Class, Class...)
for constructors andInstructionBuilder.invokeSpecial(String, MethodDescription)
for private methods.- Specified by:
invoke
in interfaceInstructionBuilder
-
invoke
public clazz, returnType, methodName, ... argumentTypes)
Description copied from interface:InstructionBuilder
Automatically invokes an interface or virtual method. Remember to useInstructionBuilder.invokeConstructor(Class, Class...)
for constructors andInstructionBuilder.invokeSpecial(String, MethodDescription)
for private methods.- Specified by:
invoke
in interfaceInstructionBuilder
-
returnResult
public InstructionBuilder returnResult()
Description copied from interface:InstructionBuilder
Returns the top value on the stack. For void methods, no value should be on the stack and the method will simply return.- Specified by:
returnResult
in interfaceInstructionBuilder
-
boxPrimitive
public typeName)
Description copied from interface:InstructionBuilder
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. Does nothing if the type is not primitive, or type void.- Specified by:
boxPrimitive
in interfaceInstructionBuilder
-
unboxPrimitive
public typeName)
Description copied from interface:InstructionBuilder
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). Does nothing for non-primitive types.- Specified by:
unboxPrimitive
in interfaceInstructionBuilder
- Parameters:
typeName
- possibly primitive type name
-
getField
public className, fieldName, typeName)
Description copied from interface:InstructionBuilder
Loads an instance field onto the stack. The object containing the field should already be loaded onto the stack (usually, viaInstructionBuilder.loadThis()
).- Specified by:
getField
in interfaceInstructionBuilder
- Parameters:
className
- name of class containing the fieldfieldName
- name of the fieldtypeName
- type of field
-
getStaticField
public className, fieldName, typeName)
Description copied from interface:InstructionBuilder
Gets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack.- Specified by:
getStaticField
in interfaceInstructionBuilder
- Parameters:
className
- name of class containing the fieldfieldName
- name of the fieldtypeName
- type of field
-
getStaticField
public className, fieldName, fieldType)
Description copied from interface:InstructionBuilder
Gets a static field; does not consume a value from the stack, but pushes the fields' value onto the stack.- Specified by:
getStaticField
in interfaceInstructionBuilder
- Parameters:
className
- name of class containing the fieldfieldName
- name of the fieldfieldType
- type of field
-
putStaticField
public className, fieldName, fieldType)
Description copied from interface:InstructionBuilder
Sets a static field; the new field value should be on top of the stack.- Specified by:
putStaticField
in interfaceInstructionBuilder
- Parameters:
className
- name of class containing the fieldfieldName
- name of the fieldfieldType
- type of field
-
putStaticField
public className, fieldName, typeName)
Description copied from interface:InstructionBuilder
Sets a static field; the new field value should be on top of the stack.- Specified by:
putStaticField
in 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:InstructionBuilder
Loads 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:
getField
in interfaceInstructionBuilder
- Parameters:
field
- identifies name, type and container of field to load
-
putField
public className, fieldName, typeName)
Description copied from interface:InstructionBuilder
Expects the stack to contain the instance to update, and the value to store into the field.- Specified by:
putField
in interfaceInstructionBuilder
-
putField
public className, fieldName, fieldType)
- Specified by:
putField
in interfaceInstructionBuilder
-
getField
public className, fieldName, fieldType)
Description copied from interface:InstructionBuilder
Loads 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:
getField
in interfaceInstructionBuilder
- Parameters:
className
- name of class containing the fieldfieldName
- name of the fieldfieldType
- type of field
-
loadArrayElement
public InstructionBuilder loadArrayElement(int index, elementType)
Description copied from interface:InstructionBuilder
Loads a value from an array object, which must be the top element of the stack.- Specified by:
loadArrayElement
in 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:InstructionBuilder
Loads 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:
loadArrayElement
in interfaceInstructionBuilder
-
checkcast
public className)
Description copied from interface:InstructionBuilder
Adds a check that the object on top of the stack is assignable to the indicated class.- Specified by:
checkcast
in interfaceInstructionBuilder
- Parameters:
className
- class to cast to
-
checkcast
public clazz)
- Specified by:
checkcast
in interfaceInstructionBuilder
-
startTryCatch
public InstructionBuilder startTryCatch(TryCatchCallback callback)
Description copied from interface:InstructionBuilder
Defines 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:
startTryCatch
in interfaceInstructionBuilder
- Parameters:
callback
- allows generation of try, catch, and finally clauses
-
newInstance
public className)
Description copied from interface:InstructionBuilder
Creates a new, uninitialized instance of the indicated class. This should be followed by code to call the new instance's constructor.- Specified by:
newInstance
in interfaceInstructionBuilder
- Parameters:
className
- of class to instantiate
-
newInstance
public clazz)
Description copied from interface:InstructionBuilder
A convenience version ofInstructionBuilder.newInstance(String)
used when the class is known at build time.- Specified by:
newInstance
in interfaceInstructionBuilder
- Parameters:
clazz
- to instantiate
-
invokeConstructor
public className, ... argumentTypes)
Description copied from interface:InstructionBuilder
Invokes 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:
invokeConstructor
in interfaceInstructionBuilder
- Parameters:
className
- the class containing the constructorargumentTypes
- java type names for each argument of the constructor
-
invokeConstructor
public clazz, ... argumentTypes)
- Specified by:
invokeConstructor
in interfaceInstructionBuilder
-
dupe
public InstructionBuilder dupe(int depth)
Description copied from interface:InstructionBuilder
Duplicates the top object on the stack, placing the result at some depth.- Specified by:
dupe
in interfaceInstructionBuilder
- Parameters:
depth
- 0 (DUP), 1 (DUP_X1) or 2 (DUP_X2)
-
dupe
public InstructionBuilder dupe()
Description copied from interface:InstructionBuilder
Duplicates the top object on the stack. Commonly used withInstructionBuilder.when(Condition, WhenCallback)
.- Specified by:
dupe
in interfaceInstructionBuilder
- See Also:
InstructionBuilder.dupe(int)
-
pop
public InstructionBuilder pop()
Description copied from interface:InstructionBuilder
Discards 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:
pop
in interfaceInstructionBuilder
-
swap
public InstructionBuilder swap()
Description copied from interface:InstructionBuilder
Swaps 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:
swap
in interfaceInstructionBuilder
-
loadConstant
public constant)
Description copied from interface:InstructionBuilder
Loads a constant value- Specified by:
loadConstant
in interfaceInstructionBuilder
- Parameters:
constant
- Integer, Float, Double, Long, String or null
-
loadTypeConstant
public typeName)
Description copied from interface:InstructionBuilder
Loads 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:
loadTypeConstant
in interfaceInstructionBuilder
- Parameters:
typeName
- Java class name
-
loadTypeConstant
public clazz)
Description copied from interface:InstructionBuilder
Loads 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:
loadTypeConstant
in interfaceInstructionBuilder
- Parameters:
clazz
- Java type to load as a constant
-
castOrUnbox
public typeName)
Description copied from interface:InstructionBuilder
Casts 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:
castOrUnbox
in interfaceInstructionBuilder
- Parameters:
typeName
- to cast or unbox to
-
throwException
public className, message)
Description copied from interface:InstructionBuilder
Throws an exception with a fixed message. Assumes the exception class includes a constructor that takes a single string.- Specified by:
throwException
in interfaceInstructionBuilder
- Parameters:
className
- name of exception class to instantiatemessage
- message (passed as first and only parameter to constructor)
-
throwException
public <? extends > exceptionType, message)
- Specified by:
throwException
in interfaceInstructionBuilder
-
throwException
public InstructionBuilder throwException()
Description copied from interface:InstructionBuilder
Throws the exception on the top of the stack.- Specified by:
throwException
in interfaceInstructionBuilder
-
startSwitch
public InstructionBuilder startSwitch(int min, int max, SwitchCallback callback)
Description copied from interface:InstructionBuilder
Starts a switch statement.- Specified by:
startSwitch
in interfaceInstructionBuilder
- Parameters:
min
- the minimum value to match againstmax
- the maximum value to match against
-
startVariable
public type, LocalVariableCallback callback)
Description copied from interface:InstructionBuilder
Starts a block where the given name is active.- Specified by:
startVariable
in 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:InstructionBuilder
Stores the value on top of the stack to a local variable (previously defined byInstructionBuilder.startVariable(String, LocalVariableCallback)
.- Specified by:
storeVariable
in interfaceInstructionBuilder
-
loadVariable
public InstructionBuilder loadVariable(LocalVariable var)
Description copied from interface:InstructionBuilder
Loads a value from a local variable and pushes it onto the stack. The variable is defined byInstructionBuilder.startVariable(String, LocalVariableCallback)
.- Specified by:
loadVariable
in interfaceInstructionBuilder
-
when
public InstructionBuilder when(Condition condition, InstructionBuilderCallback ifTrue)
Description copied from interface:InstructionBuilder
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). The testing opcodes all pop the value off the stack, so this is usually preceded bydupe(0)
.- Specified by:
when
in 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:InstructionBuilder
Executes conditional code based on aCondition
. The testing opcodes all pop the value off the stack, so this is usually preceded bydupe(0)
.- Specified by:
when
in 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:InstructionBuilder
Implements 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:
doWhile
in interfaceInstructionBuilder
- Returns:
- this builder
-
increment
public InstructionBuilder increment(LocalVariable variable)
Description copied from interface:InstructionBuilder
Increments a local integer variable.- Specified by:
increment
in interfaceInstructionBuilder
- Returns:
- this builder
-
arrayLength
public InstructionBuilder arrayLength()
Description copied from interface:InstructionBuilder
Expects the top object on the stack to be an array. Replaces it with the length of that array.- Specified by:
arrayLength
in interfaceInstructionBuilder
-
iterateArray
public InstructionBuilder iterateArray(InstructionBuilderCallback callback)
Description copied from interface:InstructionBuilder
Expects 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:
iterateArray
in 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:InstructionBuilder
Duplicates a wide value (a primitive long or double).- Specified by:
dupeWide
in interfaceInstructionBuilder
-
popWide
public InstructionBuilder popWide()
Description copied from interface:InstructionBuilder
Pops a wide value (a primitive long or double).- Specified by:
popWide
in interfaceInstructionBuilder
-
compareSpecial
public typeName)
Description copied from interface:InstructionBuilder
Special 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:
compareSpecial
in interfaceInstructionBuilder
-
-