public class CompileStack
extends java.lang.Object
implements org.objectweb.asm.Opcodes
Some Notes:
AsmClassGenerator
Modifier and Type | Class and Description |
---|---|
static class |
CompileStack.BlockRecorder |
protected static class |
CompileStack.LabelRange |
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASM4, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DOUBLE, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F_APPEND, F_CHOP, F_FULL, F_NEW, F_SAME, F_SAME1, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAT, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, H_GETFIELD, H_GETSTATIC, H_INVOKEINTERFACE, H_INVOKESPECIAL, H_INVOKESTATIC, H_INVOKEVIRTUAL, H_NEWINVOKESPECIAL, H_PUTFIELD, H_PUTSTATIC, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INTEGER, INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LONG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, NULL, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7
Constructor and Description |
---|
CompileStack(WriterController wc) |
Modifier and Type | Method and Description |
---|---|
void |
addExceptionBlock(org.objectweb.asm.Label start,
org.objectweb.asm.Label end,
org.objectweb.asm.Label goal,
java.lang.String sig) |
void |
applyBlockRecorder() |
void |
applyFinallyBlocks(org.objectweb.asm.Label label,
boolean isBreakLabel) |
void |
clear()
Clears the state of the class.
|
boolean |
containsVariable(java.lang.String name) |
org.objectweb.asm.Label |
createLocalLabel(java.lang.String name)
creates a new named label
|
int |
defineTemporaryVariable(java.lang.String name,
boolean store)
creates a temporary variable.
|
int |
defineTemporaryVariable(java.lang.String name,
ClassNode node,
boolean store)
creates a temporary variable.
|
int |
defineTemporaryVariable(Variable var,
boolean store)
creates a temporary variable.
|
BytecodeVariable |
defineVariable(Variable v,
boolean initFromStack)
Defines a new Variable using an AST variable.
|
BytecodeVariable |
defineVariable(Variable v,
ClassNode variableType,
boolean initFromStack) |
org.objectweb.asm.Label |
getBreakLabel() |
org.objectweb.asm.Label |
getContinueLabel() |
org.objectweb.asm.Label |
getLabel(java.lang.String name)
Returns the label for the given name
|
org.objectweb.asm.Label |
getNamedBreakLabel(java.lang.String name)
Used for
break foo inside a loop to end the
execution of the marked loop. |
org.objectweb.asm.Label |
getNamedContinueLabel(java.lang.String name)
Used for
continue foo inside a loop to continue
the execution of the marked loop. |
VariableScope |
getScope() |
BytecodeVariable |
getVariable(java.lang.String variableName) |
BytecodeVariable |
getVariable(java.lang.String variableName,
boolean mustExist)
Returns a normal variable.
|
boolean |
hasBlockRecorder() |
void |
init(VariableScope el,
Parameter[] parameters)
initializes this class for a MethodNode.
|
boolean |
isImplicitThis() |
boolean |
isInSpecialConstructorCall() |
boolean |
isLHS() |
void |
pop() |
void |
popBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock) |
void |
popImplicitThis() |
void |
popLHS() |
void |
pushBlockRecorder(CompileStack.BlockRecorder recorder) |
void |
pushBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock) |
void |
pushBooleanExpression()
because a boolean Expression may not be evaluated completely
it is important to keep the registers clean
|
void |
pushImplicitThis(boolean implicitThis) |
void |
pushInSpecialConstructorCall() |
void |
pushLHS(boolean lhs) |
void |
pushLoop(java.lang.String labelName)
Should be called when decending into a loop that does
not define a scope.
|
void |
pushLoop(VariableScope el,
java.lang.String labelName)
Should be called when decending into a loop that defines
also a scope.
|
void |
pushState() |
org.objectweb.asm.Label |
pushSwitch()
Creates a new break label and a element for the state stack
so pop has to be called later
|
void |
pushVariableScope(VariableScope el)
Causes the statestack to add an element and sets
the given scope as new current variable scope.
|
void |
removeVar(int tempIndex) |
void |
writeExceptionTable(CompileStack.BlockRecorder block,
org.objectweb.asm.Label goal,
java.lang.String sig) |
public CompileStack(WriterController wc)
public void pushState()
public org.objectweb.asm.Label getContinueLabel()
public org.objectweb.asm.Label getBreakLabel()
public void removeVar(int tempIndex)
public void pop()
public VariableScope getScope()
public int defineTemporaryVariable(Variable var, boolean store)
var
- defines type and namestore
- defines if the toplevel argument of the stack should be storedpublic BytecodeVariable getVariable(java.lang.String variableName)
public BytecodeVariable getVariable(java.lang.String variableName, boolean mustExist)
If mustExist
is true and the normal variable doesn't exist,
then this method will throw a GroovyBugError. It is not the intention of
this method to let this happen! And the exception should not be used for
flow control - it is just acting as an assertion. If the exception is thrown
then it indicates a bug in the class using CompileStack.
This method can also not be used to return a temporary variable.
Temporary variables are not normal variables.
variableName
- name of the variablemustExist
- throw exception if variable does not existmustExist
not true)public int defineTemporaryVariable(java.lang.String name, boolean store)
name
- defines type and namestore
- defines if the toplevel argument of the stack should be storedpublic int defineTemporaryVariable(java.lang.String name, ClassNode node, boolean store)
name
- defines the namenode
- defines the nodestore
- defines if the toplevel argument of the stack should be storedpublic void clear()
public void addExceptionBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label goal, java.lang.String sig)
public void init(VariableScope el, Parameter[] parameters)
public void pushVariableScope(VariableScope el)
public void pushLoop(VariableScope el, java.lang.String labelName)
public void pushLoop(java.lang.String labelName)
public org.objectweb.asm.Label getNamedBreakLabel(java.lang.String name)
break foo
inside a loop to end the
execution of the marked loop. This method will return the
break label of the loop if there is one found for the name.
If not, the current break label is returned.public org.objectweb.asm.Label getNamedContinueLabel(java.lang.String name)
continue foo
inside a loop to continue
the execution of the marked loop. This method will return
the break label of the loop if there is one found for the
name. If not, getLabel is used.public org.objectweb.asm.Label pushSwitch()
public void pushBooleanExpression()
public BytecodeVariable defineVariable(Variable v, boolean initFromStack)
initFromStack
- if true the last element of the
stack will be used to initialize
the new variable. If false null
will be used.public BytecodeVariable defineVariable(Variable v, ClassNode variableType, boolean initFromStack)
public boolean containsVariable(java.lang.String name)
name
- the name of the variable of interestpublic org.objectweb.asm.Label getLabel(java.lang.String name)
public org.objectweb.asm.Label createLocalLabel(java.lang.String name)
public void applyFinallyBlocks(org.objectweb.asm.Label label, boolean isBreakLabel)
public void applyBlockRecorder()
public boolean hasBlockRecorder()
public void pushBlockRecorder(CompileStack.BlockRecorder recorder)
public void pushBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)
public void popBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)
public void writeExceptionTable(CompileStack.BlockRecorder block, org.objectweb.asm.Label goal, java.lang.String sig)
public boolean isLHS()
public void pushLHS(boolean lhs)
public void popLHS()
public void pushImplicitThis(boolean implicitThis)
public boolean isImplicitThis()
public void popImplicitThis()
public boolean isInSpecialConstructorCall()
public void pushInSpecialConstructorCall()