public final class LocalVariable extends Expression
This does nothing to enforce required constraints, e.g.:
start() and end() are valid and exist in the
method.
index is otherwise unused and that only one variable
is active at a time with the index.
Note: This class does not attempt to make use of the convenience methods on generator adapter
such as CodeBuilder#newLocal(Type) or CodeBuilder#loadArg(int) that make it
easier to work with local variables (and calculating local variable indexes). Instead we push
this responsibility onto our caller. This is because CodeBuilder doesn't make it possible to
generate local variable debugging tables in this case (e.g. there is no way to map a method
parameter index to a local variable index).
Expression.Feature, Expression.Featureslocation| Modifier and Type | Method and Description |
|---|---|
LocalVariable |
asCheap()
Returns an equivalent expression where
Expression.isCheap() returns true. |
LocalVariable |
asNonNullable()
Returns an equivalent expression where
Expression.isNonNullable() returns true. |
static LocalVariable |
createLocal(String name,
int index,
org.objectweb.asm.Type type,
org.objectweb.asm.Label start,
org.objectweb.asm.Label end) |
static LocalVariable |
createThisVar(TypeInfo owner,
org.objectweb.asm.Label start,
org.objectweb.asm.Label end) |
protected void |
doGen(CodeBuilder mv)
Generate code to evaluate the expression.
|
org.objectweb.asm.Label |
end()
A label defining the latest point at which this variable is defined.
|
protected void |
extraToStringProperties(com.google.common.base.MoreObjects.ToStringHelper helper)
Subclasses can override this to supply extra properties for the toString method.
|
int |
index() |
org.objectweb.asm.Label |
start()
A label defining the earliest point at which this variable is defined.
|
Statement |
store(Expression expr)
Return a
Statement that stores the value of the given expression into this variable. |
Statement |
store(Expression expr,
org.objectweb.asm.Label firstVarInstruction)
Return a
Statement that stores the value of the given expression into this variable. |
void |
tableEntry(CodeBuilder mv)
Write a local variable table entry for this variable.
|
String |
variableName()
The name of the variable, ends up in debugging tables.
|
areAllCheap, areAllCheap, asNullable, checkAssignableTo, checkAssignableTo, checkedCast, checkedCast, checkTypes, features, invoke, invokeVoid, isCheap, isNonNullable, labelEnd, labelStart, resultType, toStatement, toString, withSourceLocationgen, tracepublic static LocalVariable createThisVar(TypeInfo owner, org.objectweb.asm.Label start, org.objectweb.asm.Label end)
public static LocalVariable createLocal(String name, int index, org.objectweb.asm.Type type, org.objectweb.asm.Label start, org.objectweb.asm.Label end)
public String variableName()
public int index()
public org.objectweb.asm.Label start()
public org.objectweb.asm.Label end()
public LocalVariable asCheap()
ExpressionExpression.isCheap() returns true.asCheap in class Expressionpublic LocalVariable asNonNullable()
ExpressionExpression.isNonNullable() returns true.asNonNullable in class Expressionpublic void tableEntry(CodeBuilder mv)
protected void doGen(CodeBuilder mv)
ExpressionThe generated code satisfies the invariant that the top of the runtime stack will contain a
value with this Expression.resultType() immediately after evaluation of the code.
doGen in class Expressionpublic Statement store(Expression expr)
Statement that stores the value of the given expression into this variable.public Statement store(Expression expr, org.objectweb.asm.Label firstVarInstruction)
Statement that stores the value of the given expression into this variable.expr - The expression to storefirstVarInstruction - A label to use to mark the store instructionprotected void extraToStringProperties(com.google.common.base.MoreObjects.ToStringHelper helper)
ExpressionextraToStringProperties in class Expression