Package io.airlift.bytecode.expression
Class BytecodeExpression
- java.lang.Object
-
- io.airlift.bytecode.expression.BytecodeExpression
-
- All Implemented Interfaces:
BytecodeNode
- Direct Known Subclasses:
ArithmeticBytecodeExpression,Variable
public abstract class BytecodeExpression extends Object implements BytecodeNode
A BytecodeExpression is chain of Java like expressions that results in at most a single value being pushed on the stack. The chain starts with a constant, local variable, static field, static method or invoke dynamic followed by zero or more invocations, field dereferences, array element fetches, or casts. The expression can optionally be terminated by a set expression, and in this case no value is pushed on the stack.A BytecodeExpression is a BytecodeNode so it works with tools like tree dump.
This abstraction makes it easy to write generic byte code generators that can work with data that may come from a parameter, field or the result of a method invocation.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBytecodeExpression(ParameterizedType type)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.airlift.bytecode.BytecodeNode
getChildNodes
-
-
-
-
Constructor Detail
-
BytecodeExpression
protected BytecodeExpression(ParameterizedType type)
-
-
Method Detail
-
getType
public final ParameterizedType getType()
-
getBytecode
public abstract BytecodeNode getBytecode(MethodGenerationContext generationContext)
-
formatOneLine
protected abstract String formatOneLine()
-
getField
public final BytecodeExpression getField(Class<?> declaringClass, String name)
-
getField
public final BytecodeExpression getField(String name, Class<?> type)
-
getField
public final BytecodeExpression getField(Field field)
-
getField
public final BytecodeExpression getField(FieldDefinition field)
-
getField
public final BytecodeExpression getField(ParameterizedType declaringClass, String name, ParameterizedType type)
-
setField
public final BytecodeExpression setField(String name, BytecodeExpression value)
-
setField
public final BytecodeExpression setField(Field field, BytecodeExpression value)
-
setField
public final BytecodeExpression setField(FieldDefinition field, BytecodeExpression value)
-
cast
public final BytecodeExpression cast(Class<?> type)
-
cast
public final BytecodeExpression cast(ParameterizedType type)
-
invoke
public final BytecodeExpression invoke(Method method, BytecodeExpression... parameters)
-
invoke
public final BytecodeExpression invoke(MethodDefinition method, Iterable<? extends BytecodeExpression> parameters)
-
invoke
public final BytecodeExpression invoke(Method method, Iterable<? extends BytecodeExpression> parameters)
-
invoke
public final BytecodeExpression invoke(String methodName, Class<?> returnType, BytecodeExpression... parameters)
-
invoke
public final BytecodeExpression invoke(String methodName, Class<?> returnType, Iterable<? extends BytecodeExpression> parameters)
-
invoke
public final BytecodeExpression invoke(String methodName, ParameterizedType returnType, Iterable<? extends BytecodeExpression> parameters)
-
invoke
public final BytecodeExpression invoke(String methodName, Class<?> returnType, Iterable<? extends Class<?>> parameterTypes, BytecodeExpression... parameters)
-
invoke
public final BytecodeExpression invoke(String methodName, ParameterizedType returnType, Iterable<ParameterizedType> parameterTypes, BytecodeExpression... parameters)
-
invoke
public final BytecodeExpression invoke(String methodName, ParameterizedType returnType, Iterable<ParameterizedType> parameterTypes, Iterable<? extends BytecodeExpression> parameters)
-
getElement
public final BytecodeExpression getElement(int index)
-
getElement
public final BytecodeExpression getElement(BytecodeExpression index)
-
setElement
public final BytecodeExpression setElement(int index, BytecodeExpression value)
-
setElement
public final BytecodeExpression setElement(BytecodeExpression index, BytecodeExpression value)
-
length
public final BytecodeExpression length()
-
ret
public final BytecodeExpression ret()
-
pop
public final BytecodeExpression pop()
-
accept
public final void accept(org.objectweb.asm.MethodVisitor visitor, MethodGenerationContext generationContext)- Specified by:
acceptin interfaceBytecodeNode
-
accept
public final <T> T accept(BytecodeNode parent, BytecodeVisitor<T> visitor)
- Specified by:
acceptin interfaceBytecodeNode
-
instanceOf
public BytecodeExpression instanceOf(Class<?> type)
-
-