Class BytecodeCreatorImpl
- All Implemented Interfaces:
BytecodeCreator,AutoCloseable
- Direct Known Subclasses:
AbstractSwitch,CatchBlockCreatorImpl,FunctionCreatorImpl.FunctionBytecodeCreator,IfThenElseImpl,LoopImpl,MethodCreatorImpl,TryBlockImpl
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class(package private) static class(package private) class(package private) class(package private) static class(package private) class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.objectweb.asm.Labelprivate ResultHandleprivate static final MethodDescriptorprivate static final booleanprivate static final Stringprivate static final Map<String, AtomicInteger> (package private) static final intprivate final MethodCreatorImplprotected final List<BytecodeCreatorImpl.Operation> private final BytecodeCreatorImplprivate final StackTraceElement[]private static final MethodDescriptorprivate static final MethodDescriptorprivate final org.objectweb.asm.Label -
Constructor Summary
ConstructorsConstructorDescriptionBytecodeCreatorImpl(BytecodeCreatorImpl enclosing) BytecodeCreatorImpl(BytecodeCreatorImpl enclosing, boolean useThisMethod) BytecodeCreatorImpl(BytecodeCreatorImpl enclosing, MethodCreatorImpl methodCreator) -
Method Summary
Modifier and TypeMethodDescriptionadd(ResultHandle a1, ResultHandle a2) Adds the two result handles together and returns the resultprotected intallocateLocalVariables(int localVarCount) private ResultHandleallocateResult(String returnType) arrayLength(ResultHandle array) voidassign(AssignableResultHandle target, ResultHandle value) Assign the given value to the given assignable target.bitwiseAnd(ResultHandle a1, ResultHandle a2) Computes the bitwise AND of the two result handles and returns the resultbitwiseOr(ResultHandle a1, ResultHandle a2) Computes the bitwise OR of the two result handles and returns the resultbitwiseXor(ResultHandle a1, ResultHandle a2) Computes the bitwise XOR of the two result handles and returns the resultvoidbreakScope(BytecodeCreator scope) Go to the end of the given scope.checkCast(ResultHandle resultHandle, String castTarget) Perform a check cast operation which transforms the type of the given result handle.(package private) ResultHandle[]checkScope(ResultHandle[] handles) (package private) <R extends ResultHandle>
RcheckScope(R handle) compareDouble(ResultHandle value1, ResultHandle value2, boolean nanComparesAsGreater) Compares twodoublevalues and pushes the resulting integer to the stack.compareFloat(ResultHandle value1, ResultHandle value2, boolean nanComparesAsGreater) Compares twofloatvalues and pushes the resulting integer to the stack.compareLong(ResultHandle value1, ResultHandle value2) Compares twolongvalues and pushes the resulting integer to the stack.voidcontinueScope(BytecodeCreator scope) Go to the top of the given scope.convertPrimitive(ResultHandle value, Class<?> conversionTarget) Converts givenvalue, which must be of a primitive type, to the givenconversionTarget, which must be a primitive type, using primitive conversions defined by the Java language specification.createFunction(Class<?> functionalInterface) Creates an instance of a functional interface(package private) BytecodeCreatorImpl.OperationcreateNewInstanceOp(ResultHandle handle, MethodDescriptor descriptor, ResultHandle[] args) Create a nested scope.createVariable(String typeDescr) Create a local variable which can be assigned within this scope.divide(ResultHandle a1, ResultHandle a2) Divides the first result handle by the second and returns the resultprivate intdoubleArithmeticOpcode(int intOpcode) private voiddumpScope(StringBuilder builder) private ResultHandleemitBinaryArithmetic(int intOpcode, ResultHandle a1, ResultHandle a2) private ResultHandleemitCompare(int opcode, String expectedType, ResultHandle value1, ResultHandle value2) private static voidemitLoadConstant(org.objectweb.asm.MethodVisitor methodVisitor, Object constant) <E extends Enum<E>>
Switch.EnumSwitch<E> enumSwitch(ResultHandle value, Class<E> enumClass) Create a new switch construct for an enum constant.(package private) voidfindActiveResultHandles(Set<ResultHandle> handlesToAllocate) private intfloatArithmeticOpcode(int intOpcode) forEach(ResultHandle iterable) Create a new for-each loop construct.(package private) org.objectweb.asm.Label(package private) MethodCreatorImplgetMethodParam(int methodNo) (package private) BytecodeCreatorImplgetOwner()getThis()(package private) org.objectweb.asm.LabelgetTop()ifFalse(ResultHandle resultHandle) An if statement.ifGreaterEqualZero(ResultHandle resultHandle) An if statement.ifGreaterThanZero(ResultHandle resultHandle) An if statement.ifIntegerEqual(ResultHandle value1, ResultHandle value2) An if statement.ifIntegerGreaterEqual(ResultHandle value1, ResultHandle value2) An if statement.ifIntegerGreaterThan(ResultHandle value1, ResultHandle value2) An if statement.ifIntegerLessEqual(ResultHandle value1, ResultHandle value2) An if statement.ifIntegerLessThan(ResultHandle value1, ResultHandle value2) An if statement.ifLessEqualZero(ResultHandle resultHandle) An if statement.ifLessThanZero(ResultHandle resultHandle) An if statement.ifNonZero(ResultHandle resultHandle) An if statement.ifNotNull(ResultHandle resultHandle) An if statement.ifNull(ResultHandle resultHandle) An if statement.ifReferencesEqual(ResultHandle ref1, ResultHandle ref2) An if statement.ifReferencesNotEqual(ResultHandle ref1, ResultHandle ref2) An if statement.ifThenElse(ResultHandle value) Create a new if-then-else construct.ifTrue(ResultHandle resultHandle) An if statement.private BranchResultifValue(ResultHandle resultHandle, int opcode, String opType) private BranchResultifValues(ResultHandle resultHandle1, ResultHandle resultHandle2, int opcode, String opType) ifZero(ResultHandle resultHandle) An if statement.instanceOf(ResultHandle resultHandle, String castTarget) Checks if the given resultHandle is an instance of the target typeinvokeInterfaceMethod(MethodDescriptor descriptor, ResultHandle object, ResultHandle... args) Invokes a interface method, and returns aResultHandlewith the result, or null if the method is void.invokeSpecialInterfaceMethod(MethodDescriptor descriptor, ResultHandle object, ResultHandle... args) Invokes a special interface method, and returns aResultHandlewith the result, or null if the method is void.invokeSpecialMethod(MethodDescriptor descriptor, ResultHandle object, ResultHandle... args) Invokes a special method, and returns aResultHandlewith the result, or null if the method is void.invokeStaticInterfaceMethod(MethodDescriptor descriptor, ResultHandle... args) Invokes a static method of an interface, and returns aResultHandlewith the result, or null if the method is void.invokeStaticMethod(MethodDescriptor descriptor, ResultHandle... args) Invokes a static method, and returns aResultHandlewith the result, or null if the method is void.invokeVirtualMethod(MethodDescriptor descriptor, ResultHandle object, ResultHandle... args) Invokes a virtual method, and returns aResultHandlewith the result, or null if the method is void.private booleanisNonPrimitiveSafeJavaClass(String className) Returnstrueif the is a non-primitive Java type that is guaranteed to be absolutely safe to load from a constant.booleanisScopedWithin(BytecodeCreator other) Determine if this bytecode creator is scoped within the given bytecode creator.(package private) voidjumpTo(BytecodeCreator scope) Go the the top of the given scope.load(boolean val) Returns aResultHandlerepresenting the specified valueload(byte val) Returns aResultHandlerepresenting the specified valueload(char val) Returns aResultHandlerepresenting the specified valueload(double val) Returns aResultHandlerepresenting the specified valueload(float val) Returns aResultHandlerepresenting the specified valueload(int val) Returns aResultHandlerepresenting the specified valueload(long val) Returns aResultHandlerepresenting the specified valueload(short val) Returns aResultHandlerepresenting the specified valueImplementation detail: when the string to be loaded is larger thanMAX_STRING_LENGTH, then aStringBuilderis used to construct the final String.Returns aResultHandlerepresenting the specified class Note that in almost all circumstances you are better off usingBytecodeCreator.loadClassFromTCCL(String), as it can load classes that are not visible from the current class.private ResultHandleprivate ResultHandleloadClassConstant(String className) loadClassFromTCCL(String className) Returns aResultHandlerepresenting the specified class This method can load all classes, including package private classes that are not visible to the current bytecode.loadNull()Returns aResultHandlerepresentingnull}(package private) voidloadResultHandle(org.objectweb.asm.MethodVisitor methodVisitor, ResultHandle handle, BytecodeCreatorImpl bc, String expectedType) (package private) voidloadResultHandle(org.objectweb.asm.MethodVisitor methodVisitor, ResultHandle handle, BytecodeCreatorImpl bc, String expectedType, boolean dontCast) private intlongArithmeticOpcode(int intOpcode) private Class<?> matchPossiblyPrimitive(String className) multiply(ResultHandle a1, ResultHandle a2) Multiplies the two result handles together and returns the resultnewArray(String type, ResultHandle length) newInstance(MethodDescriptor descriptor, ResultHandle... args) Creates a new instance of a given type, by calling the specified constructor, and returns aResultHandlerepresenting the resultreadArrayValue(ResultHandle array, ResultHandle index) readInstanceField(FieldDescriptor fieldDescriptor, ResultHandle instance) Reads an instance field and returns aResultHandlerepresenting the result.readStaticField(FieldDescriptor fieldDescriptor) Reads a static field and returns aResultHandlerepresenting the result.remainder(ResultHandle a1, ResultHandle a2) Computes the remainder after division of the first result handle by the second and returns the resultprivate ResultHandle[]requireNonNullHandles(ResultHandle[] handles) (package private) ResultHandle[]resolve(BytecodeCreator creator, ResultHandle... handles) (package private) final ResultHandleresolve(ResultHandle handle) (package private) final ResultHandle[]resolve(ResultHandle... handles) (package private) ResultHandleresolve(ResultHandle handle, BytecodeCreator creator) voidreturnValue(ResultHandle returnValue) Represents a return statement.(package private) static voidstoreResultHandle(org.objectweb.asm.MethodVisitor methodVisitor, ResultHandle handle) stringSwitch(ResultHandle value) Create a new switch construct for a string value.subtract(ResultHandle a1, ResultHandle a2) Subtracts the second result handle from the first result and returns the resultvoidthrowException(ResultHandle exception) Throws an exceptiontryBlock()Add atryblock.whileLoop(Function<BytecodeCreator, BranchResult> conditionFun) Create a new while loop statement.voidwriteArrayValue(ResultHandle array, ResultHandle index, ResultHandle value) voidwriteInstanceField(FieldDescriptor fieldDescriptor, ResultHandle instance, ResultHandle value) Writes the specified value to an instance fieldprotected voidwriteInteriorOperations(org.objectweb.asm.MethodVisitor visitor) protected voidwriteOperations(org.objectweb.asm.MethodVisitor visitor) voidwriteStaticField(FieldDescriptor fieldDescriptor, ResultHandle value) Writes the specified value to an static fieldMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.quarkus.gizmo.BytecodeCreator
breakScope, checkCast, close, continueScope, createVariable, increment, instanceOf, invokeInterfaceMethod, invokeSpecialInterfaceMethod, invokeSpecialMethod, invokeStaticInterfaceMethod, invokeStaticMethod, invokeVirtualMethod, load, loadClass, loadClass, loadClassFromTCCL, loadClassFromTCCL, marshalAsArray, newArray, newArray, newArray, newInstance, readArrayValue, readInstanceField, readStaticField, returnBoolean, returnInt, returnNull, returnVoid, throwException, throwException, writeArrayValue, writeInstanceField, writeStaticField
-
Field Details
-
THREAD_CURRENT_THREAD
-
THREAD_GET_TCCL
-
CL_FOR_NAME
-
DEBUG_SCOPES
private static final boolean DEBUG_SCOPES -
functionCountersByClass
-
FUNCTION
- See Also:
-
SAFE_CLASSES_TO_LOAD_AS_CONSTANTS
-
MAX_STRING_LENGTH
static final int MAX_STRING_LENGTH- See Also:
-
operations
-
method
-
owner
-
top
private final org.objectweb.asm.Label top -
bottom
private final org.objectweb.asm.Label bottom -
stack
-
boxingMap
-
boxingMethodMap
-
cachedTccl
-
-
Constructor Details
-
BytecodeCreatorImpl
BytecodeCreatorImpl(BytecodeCreatorImpl enclosing, MethodCreatorImpl methodCreator) -
BytecodeCreatorImpl
BytecodeCreatorImpl(BytecodeCreatorImpl enclosing, boolean useThisMethod) -
BytecodeCreatorImpl
BytecodeCreatorImpl(BytecodeCreatorImpl enclosing)
-
-
Method Details
-
getTop
org.objectweb.asm.Label getTop() -
getBottom
org.objectweb.asm.Label getBottom() -
getThis
- Specified by:
getThisin interfaceBytecodeCreator- Returns:
- A
ResultHandlethat represents the current object
-
invokeVirtualMethod
public ResultHandle invokeVirtualMethod(MethodDescriptor descriptor, ResultHandle object, ResultHandle... args) Description copied from interface:BytecodeCreatorInvokes a virtual method, and returns aResultHandlewith the result, or null if the method is void.- Specified by:
invokeVirtualMethodin interfaceBytecodeCreator- Parameters:
descriptor- The method descriptorobject- AResultHandlerepresenting the object to invoke onargs- The method parameters- Returns:
- The method result, or null if a void method
-
invokeInterfaceMethod
public ResultHandle invokeInterfaceMethod(MethodDescriptor descriptor, ResultHandle object, ResultHandle... args) Description copied from interface:BytecodeCreatorInvokes a interface method, and returns aResultHandlewith the result, or null if the method is void.- Specified by:
invokeInterfaceMethodin interfaceBytecodeCreator- Parameters:
descriptor- The method descriptorobject- AResultHandlerepresenting the object to invoke onargs- The method parameters- Returns:
- The method result, or null if a void method
-
invokeStaticMethod
Description copied from interface:BytecodeCreatorInvokes a static method, and returns aResultHandlewith the result, or null if the method is void.- Specified by:
invokeStaticMethodin interfaceBytecodeCreator- Parameters:
descriptor- The method descriptorargs- The method parameters- Returns:
- The method result, or null if a void method
-
invokeStaticInterfaceMethod
Description copied from interface:BytecodeCreatorInvokes a static method of an interface, and returns aResultHandlewith the result, or null if the method is void.- Specified by:
invokeStaticInterfaceMethodin interfaceBytecodeCreator- Parameters:
descriptor- The method descriptorargs- The method parameters- Returns:
- The method result, or null if a void method
-
invokeSpecialMethod
public ResultHandle invokeSpecialMethod(MethodDescriptor descriptor, ResultHandle object, ResultHandle... args) Description copied from interface:BytecodeCreatorInvokes a special method, and returns aResultHandlewith the result, or null if the method is void.Special methods are constructor invocations, or invocations on a superclass method of the current class.
- Specified by:
invokeSpecialMethodin interfaceBytecodeCreator- Parameters:
descriptor- The method descriptorobject- AResultHandlerepresenting the object to invoke onargs- The method parameters- Returns:
- The method result, or null if a void method
-
invokeSpecialInterfaceMethod
public ResultHandle invokeSpecialInterfaceMethod(MethodDescriptor descriptor, ResultHandle object, ResultHandle... args) Description copied from interface:BytecodeCreatorInvokes a special interface method, and returns aResultHandlewith the result, or null if the method is void.Special interface method invocations are invocations of a superinterface method of the current class.
- Specified by:
invokeSpecialInterfaceMethodin interfaceBytecodeCreator- Parameters:
descriptor- The method descriptorobject- AResultHandlerepresenting the object to invoke onargs- The method parameters- Returns:
- The method result, or null if a void method
-
newInstance
Description copied from interface:BytecodeCreatorCreates a new instance of a given type, by calling the specified constructor, and returns aResultHandlerepresenting the result- Specified by:
newInstancein interfaceBytecodeCreator- Parameters:
descriptor- The constructor descriptorargs- The constructor parameters- Returns:
- The new instance
-
newArray
- Specified by:
newArrayin interfaceBytecodeCreator
-
load
Implementation detail: when the string to be loaded is larger thanMAX_STRING_LENGTH, then aStringBuilderis used to construct the final String. This is done because strings constants cannot be larger thanMAX_STRING_LENGTH.- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
load
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified value- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
load
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified value- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
load
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified value- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
load
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified value- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
load
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified value- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
load
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified value- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
load
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified value- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
load
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified value- Specified by:
loadin interfaceBytecodeCreator- Parameters:
val- The value- Returns:
- A
ResultHandlerepresenting the specified value
-
loadClass
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified class Note that in almost all circumstances you are better off usingBytecodeCreator.loadClassFromTCCL(String), as it can load classes that are not visible from the current class. This method should only be used if you are sure that the class being loaded will be accessible from the generated bytecode.- Specified by:
loadClassin interfaceBytecodeCreator- Parameters:
className- The class name- Returns:
- A
ResultHandlerepresenting the specified class
-
loadClassFromTCCL
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresenting the specified class This method can load all classes, including package private classes that are not visible to the current bytecode.- Specified by:
loadClassFromTCCLin interfaceBytecodeCreator- Parameters:
className- The class name- Returns:
- A
ResultHandlerepresenting the specified class
-
loadClass
-
loadClassConstant
-
matchPossiblyPrimitive
-
isNonPrimitiveSafeJavaClass
Returnstrueif the is a non-primitive Java type that is guaranteed to be absolutely safe to load from a constant.Note that it's not safe to load all JDK classes using this, see this for an example.
-
loadNull
Description copied from interface:BytecodeCreatorReturns aResultHandlerepresentingnull}- Specified by:
loadNullin interfaceBytecodeCreator- Returns:
- A
ResultHandlerepresentingnull}
-
writeInstanceField
public void writeInstanceField(FieldDescriptor fieldDescriptor, ResultHandle instance, ResultHandle value) Description copied from interface:BytecodeCreatorWrites the specified value to an instance field- Specified by:
writeInstanceFieldin interfaceBytecodeCreator- Parameters:
fieldDescriptor- The field to write toinstance- AResultHandlerepresenting the instance that contains the fieldvalue- AResultHandlerepresenting the value
-
readInstanceField
Description copied from interface:BytecodeCreatorReads an instance field and returns aResultHandlerepresenting the result. The result of the read is stored in a local variable, so even if the field value changes theResultHandlewill represent the same result.- Specified by:
readInstanceFieldin interfaceBytecodeCreator- Parameters:
fieldDescriptor- The field to read frominstance- AResultHandlerepresenting the instance that contains the field- Returns:
- A
ResultHandlerepresenting the field value at the current point in time
-
writeStaticField
Description copied from interface:BytecodeCreatorWrites the specified value to an static field- Specified by:
writeStaticFieldin interfaceBytecodeCreator- Parameters:
fieldDescriptor- The field to write tovalue- AResultHandlerepresenting the value
-
readStaticField
Description copied from interface:BytecodeCreatorReads a static field and returns aResultHandlerepresenting the result. The result of the read is stored in a local variable, so even if the field value changes theResultHandlewill represent the same result.- Specified by:
readStaticFieldin interfaceBytecodeCreator- Parameters:
fieldDescriptor- The field to read from- Returns:
- A
ResultHandlerepresenting the field value at the current point in time
-
arrayLength
- Specified by:
arrayLengthin interfaceBytecodeCreator
-
readArrayValue
- Specified by:
readArrayValuein interfaceBytecodeCreator
-
writeArrayValue
- Specified by:
writeArrayValuein interfaceBytecodeCreator
-
createVariable
Description copied from interface:BytecodeCreatorCreate a local variable which can be assigned within this scope.- Specified by:
createVariablein interfaceBytecodeCreator- Parameters:
typeDescr- the type descriptor of the variable's type (must not benull)- Returns:
- the assignable local variable (not
null)
-
assign
Description copied from interface:BytecodeCreatorAssign the given value to the given assignable target.- Specified by:
assignin interfaceBytecodeCreator- Parameters:
target- the assignment target (must not benull)value- the value to assign (must not benull)
-
checkCast
Description copied from interface:BytecodeCreatorPerform a check cast operation which transforms the type of the given result handle.- Specified by:
checkCastin interfaceBytecodeCreator- Parameters:
resultHandle- the result handlecastTarget- the cast target type descriptor- Returns:
- a new result handle with updated type
-
convertPrimitive
Description copied from interface:BytecodeCreatorConverts givenvalue, which must be of a primitive type, to the givenconversionTarget, which must be a primitive type, using primitive conversions defined by the Java language specification.Returns
valuedirectly when its static type is the same asconversionTarget.Throws an exception if any of the arguments is
null. Throws an exception when the static type ofvalueis not a primitive type or whenconversionTargetis not a primitive type. Throws an exception if no primitive conversion exists from the type ofvalueto theconversionTarget. (Note that "throws an exception" in this paragraph does not mean that a bytecode sequence for throwing an exception is emitted; instead, the methodconvertPrimitivethrows an exception directly and eagerly.)- Specified by:
convertPrimitivein interfaceBytecodeCreator- Parameters:
value- the value to be convertedconversionTarget- the primitive type to which thevalueshould be converted- Returns:
- the converted value
-
isScopedWithin
Description copied from interface:BytecodeCreatorDetermine if this bytecode creator is scoped within the given bytecode creator.- Specified by:
isScopedWithinin interfaceBytecodeCreator- Parameters:
other- the other bytecode creator- Returns:
trueif this bytecode creator is scoped within the given creator,falseotherwise
-
continueScope
Description copied from interface:BytecodeCreatorGo to the top of the given scope.- Specified by:
continueScopein interfaceBytecodeCreator- Parameters:
scope- the scope to continue
-
breakScope
Description copied from interface:BytecodeCreatorGo to the end of the given scope.- Specified by:
breakScopein interfaceBytecodeCreator- Parameters:
scope- the scope to break out of
-
createScope
Description copied from interface:BytecodeCreatorCreate a nested scope. Bytecode added to the nested scope will be inserted at this point of the enclosing scope.- Specified by:
createScopein interfaceBytecodeCreator- Returns:
- the nested scope
-
jumpTo
Go the the top of the given scope. UnlikecontinueScope(BytecodeCreator)this method does not verify if this bytecode creator is scoped within the given bytecode creator.- Parameters:
scope-
-
storeResultHandle
-
loadResultHandle
void loadResultHandle(org.objectweb.asm.MethodVisitor methodVisitor, ResultHandle handle, BytecodeCreatorImpl bc, String expectedType) -
loadResultHandle
void loadResultHandle(org.objectweb.asm.MethodVisitor methodVisitor, ResultHandle handle, BytecodeCreatorImpl bc, String expectedType, boolean dontCast) -
emitLoadConstant
private static void emitLoadConstant(org.objectweb.asm.MethodVisitor methodVisitor, Object constant) -
tryBlock
Description copied from interface:BytecodeCreatorAdd atryblock.- Specified by:
tryBlockin interfaceBytecodeCreator- Returns:
- the
tryblock
-
compareLong
Description copied from interface:BytecodeCreatorCompares twolongvalues and pushes the resulting integer to the stack. Ifvalue1is greater thanvalue2, the result is 1; ifvalue1is equal tovalue2, the result is 0; ifvalue1is less thanvalue2, the result is -1. One of theif*methods should be used to process the result. Both parameters must be of typelong.- Specified by:
compareLongin interfaceBytecodeCreator- Parameters:
value1- firstlongvalue to comparevalue2- secondlongvalue to compare- Returns:
- the comparison result
-
compareFloat
public ResultHandle compareFloat(ResultHandle value1, ResultHandle value2, boolean nanComparesAsGreater) Description copied from interface:BytecodeCreatorCompares twofloatvalues and pushes the resulting integer to the stack. Ifvalue1is greater thanvalue2, the result is 1; ifvalue1is equal tovalue2, the result is 0; ifvalue1is less thanvalue2, the result is -1. One of theif*methods should be used to process the result. Both parameters must be of typefloat.If one of the values is NaN, the result is 1 if
nanComparesAsGreateris true and -1 if not.- Specified by:
compareFloatin interfaceBytecodeCreator- Parameters:
value1- firstlongvalue to comparevalue2- secondlongvalue to comparenanComparesAsGreater- whether presence of NaN should result in "greater"- Returns:
- the comparison result
-
compareDouble
public ResultHandle compareDouble(ResultHandle value1, ResultHandle value2, boolean nanComparesAsGreater) Description copied from interface:BytecodeCreatorCompares twodoublevalues and pushes the resulting integer to the stack. Ifvalue1is greater thanvalue2, the result is 1; ifvalue1is equal tovalue2, the result is 0; ifvalue1is less thanvalue2, the result is -1. One of theif*methods should be used to process the result. Both parameters must be of typedouble.If one of the values is NaN, the result is 1 if
nanComparesAsGreateris true and -1 if not.- Specified by:
compareDoublein interfaceBytecodeCreator- Parameters:
value1- firstlongvalue to comparevalue2- secondlongvalue to comparenanComparesAsGreater- whether presence of NaN should result in "greater"- Returns:
- the comparison result
-
emitCompare
private ResultHandle emitCompare(int opcode, String expectedType, ResultHandle value1, ResultHandle value2) -
ifNonZero
Description copied from interface:BytecodeCreatorAn if statement.resultHandle must be an integer type or boolean. If this value is true or non-zero the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifNonZeroin interfaceBytecodeCreator- Parameters:
resultHandle- The result to compare with zero- Returns:
- The branch result that is used to build the if statement
-
ifNull
Description copied from interface:BytecodeCreatorAn if statement. If the value isnulltheBranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifNullin interfaceBytecodeCreator- Parameters:
resultHandle-- Returns:
- The branch result that is used to build the if statement
-
ifZero
Description copied from interface:BytecodeCreatorAn if statement.resultHandle must be an integer type or boolean. If this value is false or zero the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifZeroin interfaceBytecodeCreator- Parameters:
resultHandle- The result to compare with zero- Returns:
- The branch result that is used to build the if statement
-
ifTrue
Description copied from interface:BytecodeCreatorAn if statement. An alias forBytecodeCreator.ifNonZero(ResultHandle).- Specified by:
ifTruein interfaceBytecodeCreator- Parameters:
resultHandle- The result to compare with zero- Returns:
- The branch result that is used to build the if statement
-
ifFalse
Description copied from interface:BytecodeCreatorAn if statement. An alias forBytecodeCreator.ifZero(ResultHandle).- Specified by:
ifFalsein interfaceBytecodeCreator- Parameters:
resultHandle- The result to compare with zero- Returns:
- The branch result that is used to build the if statement
-
ifNotNull
Description copied from interface:BytecodeCreatorAn if statement. If the value is notnulltheBranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifNotNullin interfaceBytecodeCreator- Parameters:
resultHandle-- Returns:
- The branch result that is used to build the if statement
-
ifGreaterThanZero
Description copied from interface:BytecodeCreatorAn if statement.resultHandle must be an integer type. If this value is greater than zero the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifGreaterThanZeroin interfaceBytecodeCreator- Parameters:
resultHandle-- Returns:
- The branch result that is used to build the if statement
-
ifGreaterEqualZero
Description copied from interface:BytecodeCreatorAn if statement.resultHandle must be an integer type. If this value is greater or equals to zero the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifGreaterEqualZeroin interfaceBytecodeCreator- Parameters:
resultHandle-- Returns:
- The branch result that is used to build the if statement
-
ifLessThanZero
Description copied from interface:BytecodeCreatorAn if statement.resultHandle must be an integer type. If this value is lower than zero the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifLessThanZeroin interfaceBytecodeCreator- Parameters:
resultHandle-- Returns:
- The branch result that is used to build the if statement
-
ifLessEqualZero
Description copied from interface:BytecodeCreatorAn if statement.resultHandle must be an integer type. If this value is lower or equals to zero the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifLessEqualZeroin interfaceBytecodeCreator- Parameters:
resultHandle-- Returns:
- The branch result that is used to build the if statement
-
ifIntegerEqual
Description copied from interface:BytecodeCreatorAn if statement.Values must be integer types. If value1 is equal to value2 the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifIntegerEqualin interfaceBytecodeCreator- Parameters:
value1-value2-- Returns:
- The branch result that is used to build the if statement
-
ifIntegerGreaterThan
Description copied from interface:BytecodeCreatorAn if statement.Values must be integer types. If value1 is greater than value2 the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifIntegerGreaterThanin interfaceBytecodeCreator- Parameters:
value1-value2-- Returns:
- The branch result that is used to build the if statement
-
ifIntegerGreaterEqual
Description copied from interface:BytecodeCreatorAn if statement.Values must be integer types. If value1 is greater or equal to value2 the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifIntegerGreaterEqualin interfaceBytecodeCreator- Parameters:
value1-value2-- Returns:
- The branch result that is used to build the if statement
-
ifIntegerLessThan
Description copied from interface:BytecodeCreatorAn if statement.Values must be integer types. If value1 is less than value2 the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifIntegerLessThanin interfaceBytecodeCreator- Parameters:
value1-value2-- Returns:
- The branch result that is used to build the if statement
-
instanceOf
Description copied from interface:BytecodeCreatorChecks if the given resultHandle is an instance of the target type- Specified by:
instanceOfin interfaceBytecodeCreator- Parameters:
resultHandle- the result handlecastTarget- the cast target class- Returns:
- a boolean result handle with the result of the instanceof call
-
ifIntegerLessEqual
Description copied from interface:BytecodeCreatorAn if statement.Values must be integer types. If value1 is less or equal to value2 the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifIntegerLessEqualin interfaceBytecodeCreator- Parameters:
value1-value2-- Returns:
- The branch result that is used to build the if statement
-
ifReferencesEqual
Description copied from interface:BytecodeCreatorAn if statement.If references are equal (object identity) the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.- Specified by:
ifReferencesEqualin interfaceBytecodeCreator- Parameters:
ref1-ref2-- Returns:
- The branch result that is used to build the if statement
-
ifReferencesNotEqual
Description copied from interface:BytecodeCreatorAn if statement.If references are not equal (as in object identity) the
BranchResult.trueBranch()code will be executed, otherwise theBranchResult.falseBranch()will be run.This method is dual to
BytecodeCreator.ifReferencesEqual(ResultHandle, ResultHandle)and can be used to emit bytecode that is closer to what javac emits, when useful.- Specified by:
ifReferencesNotEqualin interfaceBytecodeCreator- Parameters:
ref1-ref2-- Returns:
- The branch result that is used to build the if statement
-
ifThenElse
Description copied from interface:BytecodeCreatorCreate a new if-then-else construct.The
IfThenElse.then()block is executed if the condition result handle evaluates totrue.- Specified by:
ifThenElsein interfaceBytecodeCreator- Parameters:
value-- Returns:
- the if-then-else construct
-
getMethodParam
- Specified by:
getMethodParamin interfaceBytecodeCreator- Parameters:
methodNo- The method parameter number, zero indexed- Returns:
- A
ResultHandlerepresenting the parameter
-
createFunction
Description copied from interface:BytecodeCreatorCreates an instance of a functional interfaceThe resulting
FunctionCreatorcan be used to both define the functions bytecode, and to get aResultHandlethat represents the instance of the function.- Specified by:
createFunctionin interfaceBytecodeCreator- Parameters:
functionalInterface- A functional interface- Returns:
- The function builder
-
returnValue
Description copied from interface:BytecodeCreatorRepresents a return statement. If this is a void method the return value must be null, otherwise it must be aResultHandleof the correct type which will be returned from the method.- Specified by:
returnValuein interfaceBytecodeCreator- Parameters:
returnValue- The value to return
-
throwException
Description copied from interface:BytecodeCreatorThrows an exception- Specified by:
throwExceptionin interfaceBytecodeCreator- Parameters:
exception- A result handle representing the exception to throw
-
whileLoop
Description copied from interface:BytecodeCreatorCreate a new while loop statement.- Specified by:
whileLoopin interfaceBytecodeCreator- Parameters:
conditionFun- A function used to create the condition. The true branch continues executing the block and the false branch terminates the statement.- Returns:
- the while loop statement
-
forEach
Description copied from interface:BytecodeCreatorCreate a new for-each loop construct.- Specified by:
forEachin interfaceBytecodeCreator- Parameters:
iterable-- Returns:
- the for-each construct
-
add
Description copied from interface:BytecodeCreatorAdds the two result handles together and returns the result- Specified by:
addin interfaceBytecodeCreator- Parameters:
a1- The first number, aka the augenda2- The second number, aka the addend- Returns:
- The result
-
subtract
Description copied from interface:BytecodeCreatorSubtracts the second result handle from the first result and returns the result- Specified by:
subtractin interfaceBytecodeCreator- Parameters:
a1- The first number, aka the minuenda2- The second number, aka the subtrahend- Returns:
- The result
-
multiply
Description copied from interface:BytecodeCreatorMultiplies the two result handles together and returns the result- Specified by:
multiplyin interfaceBytecodeCreator- Parameters:
a1- The first number, aka the multipliera2- The second number, aka the multiplicand- Returns:
- The result
-
divide
Description copied from interface:BytecodeCreatorDivides the first result handle by the second and returns the result- Specified by:
dividein interfaceBytecodeCreator- Parameters:
a1- The first number, aka the numeratora2- The second number, aka the denominator- Returns:
- The result
-
remainder
Description copied from interface:BytecodeCreatorComputes the remainder after division of the first result handle by the second and returns the result- Specified by:
remainderin interfaceBytecodeCreator- Parameters:
a1- The first number, aka the numeratora2- The second number, aka the denominator- Returns:
- The result
-
bitwiseAnd
Description copied from interface:BytecodeCreatorComputes the bitwise AND of the two result handles and returns the result- Specified by:
bitwiseAndin interfaceBytecodeCreator- Parameters:
a1- The first numbera2- The second number- Returns:
- The result
-
bitwiseOr
Description copied from interface:BytecodeCreatorComputes the bitwise OR of the two result handles and returns the result- Specified by:
bitwiseOrin interfaceBytecodeCreator- Parameters:
a1- The first numbera2- The second number- Returns:
- The result
-
bitwiseXor
Description copied from interface:BytecodeCreatorComputes the bitwise XOR of the two result handles and returns the result- Specified by:
bitwiseXorin interfaceBytecodeCreator- Parameters:
a1- The first numbera2- The second number- Returns:
- The result
-
stringSwitch
Description copied from interface:BytecodeCreatorCreate a new switch construct for a string value.- Specified by:
stringSwitchin interfaceBytecodeCreator- Parameters:
value- The string value to switch on- Returns:
- the switch construct
-
enumSwitch
Description copied from interface:BytecodeCreatorCreate a new switch construct for an enum constant.- Specified by:
enumSwitchin interfaceBytecodeCreator- Type Parameters:
E-- Parameters:
value- The enum constant to switch onenumClass-- Returns:
- the switch construct
-
emitBinaryArithmetic
-
longArithmeticOpcode
private int longArithmeticOpcode(int intOpcode) -
floatArithmeticOpcode
private int floatArithmeticOpcode(int intOpcode) -
doubleArithmeticOpcode
private int doubleArithmeticOpcode(int intOpcode) -
allocateResult
-
allocateLocalVariables
protected int allocateLocalVariables(int localVarCount) -
findActiveResultHandles
-
writeOperations
protected void writeOperations(org.objectweb.asm.MethodVisitor visitor) -
writeInteriorOperations
protected void writeInteriorOperations(org.objectweb.asm.MethodVisitor visitor) -
checkScope
-
dumpScope
-
checkScope
-
resolve
-
resolve
-
resolve
-
resolve
-
getMethod
MethodCreatorImpl getMethod() -
getOwner
BytecodeCreatorImpl getOwner() -
ifValue
-
ifValues
private BranchResult ifValues(ResultHandle resultHandle1, ResultHandle resultHandle2, int opcode, String opType) -
requireNonNullHandles
-
createNewInstanceOp
BytecodeCreatorImpl.Operation createNewInstanceOp(ResultHandle handle, MethodDescriptor descriptor, ResultHandle[] args)
-