public abstract class Statement extends BytecodeProducer
{'foo'} could be implemented as a statement
that writes to an output stream.
The generated code should satisfy the invariant that the runtime stack and local variables are are unchanged by the generated code (i.e. the frame map at the start of the statement is identical to the frame map at the end of the statement).
| Modifier and Type | Field and Description |
|---|---|
static Statement |
NULL_STATEMENT |
static Statement |
RETURN |
location| Modifier | Constructor and Description |
|---|---|
protected |
Statement() |
protected |
Statement(SourceLocation location) |
| Modifier and Type | Method and Description |
|---|---|
static Statement |
concat(Iterable<? extends Statement> statements)
Returns a statement that concatenates all the provided statements.
|
static Statement |
concat(Statement... statements)
Returns a statement that concatenates all the provided statements.
|
Statement |
labelStart(org.objectweb.asm.Label label)
Returns a new statement identical to this one but with the given label applied at the start of
the statement.
|
static Statement |
returnExpression(Expression expression)
Generates a statement that returns the value produced by the given expression.
|
static Statement |
throwExpression(Expression expression)
Generates a statement that throws the throwable produced by the given expression.
|
String |
toString() |
Statement |
withSourceLocation(SourceLocation location)
Returns a new
Statement with the source location attached. |
void |
writeIOExceptionMethod(int access,
org.objectweb.asm.commons.Method method,
org.objectweb.asm.ClassVisitor visitor)
Writes this statement to the
ClassVisitor as a method. |
void |
writeMethod(int access,
org.objectweb.asm.commons.Method method,
org.objectweb.asm.ClassVisitor visitor)
Writes this statement to the
ClassVisitor as a method. |
doGen, gen, tracepublic static final Statement NULL_STATEMENT
public static final Statement RETURN
protected Statement()
protected Statement(SourceLocation location)
public static Statement returnExpression(Expression expression)
This does not validate that the return type is appropriate. It is our callers responsibility to do that.
public static Statement throwExpression(Expression expression)
This does not validate that the throwable is compatible with the methods throws clause.
public static Statement concat(Statement... statements)
public static Statement concat(Iterable<? extends Statement> statements)
public final void writeMethod(int access,
org.objectweb.asm.commons.Method method,
org.objectweb.asm.ClassVisitor visitor)
ClassVisitor as a method.access - The access modifiers of the methodmethod - The method signaturevisitor - The class visitor to write it topublic final void writeIOExceptionMethod(int access,
org.objectweb.asm.commons.Method method,
org.objectweb.asm.ClassVisitor visitor)
ClassVisitor as a method.access - The access modifiers of the methodmethod - The method signaturevisitor - The class visitor to write it topublic final Statement labelStart(org.objectweb.asm.Label label)
public final Statement withSourceLocation(SourceLocation location)
Statement with the source location attached.