Package io.quarkus.gizmo
Class IfThenElseImpl
- java.lang.Object
-
- io.quarkus.gizmo.BytecodeCreatorImpl
-
- io.quarkus.gizmo.IfThenElseImpl
-
- All Implemented Interfaces:
BytecodeCreator,IfThenElse,java.lang.AutoCloseable
class IfThenElseImpl extends BytecodeCreatorImpl implements IfThenElse
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.quarkus.gizmo.BytecodeCreatorImpl
BytecodeCreatorImpl.AssignOperation, BytecodeCreatorImpl.BlockOperation, BytecodeCreatorImpl.IfOperation, BytecodeCreatorImpl.InvokeOperation, BytecodeCreatorImpl.JumpOperation, BytecodeCreatorImpl.NewInstanceOperation, BytecodeCreatorImpl.Operation
-
-
Field Summary
Fields Modifier and Type Field Description private static byteELSEprivate static byteELSEIFprivate static byteINITprivate BranchResultresultprivate bytestateprivate static byteTHEN-
Fields inherited from class io.quarkus.gizmo.BytecodeCreatorImpl
MAX_STRING_LENGTH, operations
-
-
Constructor Summary
Constructors Constructor Description IfThenElseImpl(BytecodeCreatorImpl enclosing, ResultHandle value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.IllegalStateExceptionelseAlreadyCreated()BytecodeCreatorelseIf(ResultHandle value)Creates a new else-if statement.BytecodeCreatorelseIf(java.util.function.Function<BytecodeCreator,ResultHandle> test)Creates a new else-if statement.BytecodeCreatorelseThen()This block is executed if no condition result handle was evaluated astrue.private java.lang.IllegalStateExceptioninitialThenNotCreated()BytecodeCreatorthen()This block is executed if the result handle that was passed toBytecodeCreator.ifThenElse(ResultHandle)is evaluated astrue.-
Methods inherited from class io.quarkus.gizmo.BytecodeCreatorImpl
add, allocateLocalVariables, arrayLength, assign, bitwiseAnd, bitwiseOr, bitwiseXor, breakScope, checkCast, checkScope, checkScope, compareDouble, compareFloat, compareLong, continueScope, convertPrimitive, createFunction, createNewInstanceOp, createScope, createVariable, divide, enumSwitch, findActiveResultHandles, forEach, getBottom, getMethod, getMethodParam, getOwner, getThis, getTop, ifFalse, ifGreaterEqualZero, ifGreaterThanZero, ifIntegerEqual, ifIntegerGreaterEqual, ifIntegerGreaterThan, ifIntegerLessEqual, ifIntegerLessThan, ifLessEqualZero, ifLessThanZero, ifNonZero, ifNotNull, ifNull, ifReferencesEqual, ifReferencesNotEqual, ifThenElse, ifTrue, ifZero, instanceOf, invokeInterfaceMethod, invokeSpecialInterfaceMethod, invokeSpecialMethod, invokeStaticInterfaceMethod, invokeStaticMethod, invokeVirtualMethod, isScopedWithin, jumpTo, load, load, load, load, load, load, load, load, load, loadClass, loadClassFromTCCL, loadNull, loadResultHandle, loadResultHandle, multiply, newArray, newInstance, readArrayValue, readInstanceField, readStaticField, remainder, resolve, resolve, resolve, resolve, returnValue, storeResultHandle, stringSwitch, subtract, throwException, tryBlock, whileLoop, writeArrayValue, writeInstanceField, writeInteriorOperations, writeOperations, writeStaticField
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods 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 Detail
-
state
private byte state
-
result
private BranchResult result
-
INIT
private static byte INIT
-
THEN
private static byte THEN
-
ELSEIF
private static byte ELSEIF
-
ELSE
private static byte ELSE
-
-
Constructor Detail
-
IfThenElseImpl
public IfThenElseImpl(BytecodeCreatorImpl enclosing, ResultHandle value)
-
-
Method Detail
-
then
public BytecodeCreator then()
Description copied from interface:IfThenElseThis block is executed if the result handle that was passed toBytecodeCreator.ifThenElse(ResultHandle)is evaluated astrue.- Specified by:
thenin interfaceIfThenElse- Returns:
- the
thenblock
-
elseIf
public BytecodeCreator elseIf(ResultHandle value)
Description copied from interface:IfThenElseCreates a new else-if statement. The block is executed if the condition result handle is evaluated astrue.Note that the condition result handle must already exist.
boolean test = foo.testIsOk(); if (someOtherCondition) { // do action "A" } else if (test) { // do action "B" }If you need to create the condition result handle inside the if-else statement then use theIfThenElse.elseIf(Function)method instead.- Specified by:
elseIfin interfaceIfThenElse- Returns:
- the
else-ifblock
-
elseIf
public BytecodeCreator elseIf(java.util.function.Function<BytecodeCreator,ResultHandle> test)
Description copied from interface:IfThenElseCreates a new else-if statement. The block is executed if the condition result handle returned from the function is evaluated astrue.The argument of the function represents the block that is executed when the else-if statement is evaluated.
In order to generate the bytecode for the "action B" branch in the following example:
if (someOtherCondition) { // do action "A" } else if (foo.testIsOk()) { // do action "B" }The code needs to look like:IfThenElse ifAction = method.ifThenElse(someOtherCondition); BytecodeCreator ifTestOk = ifValue.elseIf(b -> b.invokeVirtualMethod(testIsOkMethodDescriptor, fooInstance))); // do action "B"
- Specified by:
elseIfin interfaceIfThenElse- Returns:
- the
else-ifblock
-
elseThen
public BytecodeCreator elseThen()
Description copied from interface:IfThenElseThis block is executed if no condition result handle was evaluated astrue.- Specified by:
elseThenin interfaceIfThenElse- Returns:
- the
elseblock
-
initialThenNotCreated
private java.lang.IllegalStateException initialThenNotCreated()
-
elseAlreadyCreated
private java.lang.IllegalStateException elseAlreadyCreated()
-
-