|
Groovy 1.7.9 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.classgen.CompileStack
public class CompileStack extends Object
This class is a helper for AsmClassGenerator. It manages different aspects of the code of a code block like handling labels, defining variables, and scopes. After a MethodNode is visited clear should be called, for initialization the method init should be used.
Some Notes:
Nested Class Summary | |
---|---|
protected static class |
CompileStack.BlockRecorder
|
protected static class |
CompileStack.LabelRange
|
Method Summary | |
---|---|
void
|
addExceptionBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label goal, String sig)
|
void
|
applyBlockRecorder()
|
void
|
applyFinallyBlocks(org.objectweb.asm.Label label, boolean isBreakLabel)
|
void
|
clear()
Clears the state of the class. |
boolean
|
containsVariable(String name)
@param name the name of the variable of interest |
org.objectweb.asm.Label
|
createLocalLabel(String name)
creates a new named label |
int
|
defineTemporaryVariable(def var, boolean store)
creates a temporary variable. |
int
|
defineTemporaryVariable(String name, boolean store)
creates a temporary variable. |
int
|
defineTemporaryVariable(String name, ClassNode node, boolean store)
creates a temporary variable. |
Variable
|
defineVariable(def v, boolean initFromStack)
Defines a new Variable using an AST variable. |
org.objectweb.asm.Label
|
getBreakLabel()
|
org.objectweb.asm.Label
|
getContinueLabel()
|
org.objectweb.asm.Label
|
getLabel(String name)
Returns the label for the given name |
protected org.objectweb.asm.Label
|
getNamedBreakLabel(String name)
Used for |
protected org.objectweb.asm.Label
|
getNamedContinueLabel(String name)
Used for |
VariableScope
|
getScope()
|
Variable
|
getVariable(String variableName)
|
Variable
|
getVariable(String variableName, boolean mustExist)
Returns a normal variable. |
boolean
|
hasBlockRecorder()
|
protected void
|
init(VariableScope el, Parameter[] parameters, org.objectweb.asm.MethodVisitor mv, ClassNode cn)
initializes this class for a MethodNode. |
void
|
pop()
|
void
|
popBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)
|
void
|
pushBlockRecorder(CompileStack.BlockRecorder recorder)
|
void
|
pushBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)
|
protected void
|
pushBooleanExpression()
because a boolean Expression may not be evaluated completly it is important to keep the registers clean |
protected void
|
pushLoop(VariableScope el, String labelName)
Should be called when decending into a loop that defines also a scope. |
protected void
|
pushLoop(String labelName)
Should be called when decending into a loop that does not define a scope. |
protected void
|
pushState()
|
protected org.objectweb.asm.Label
|
pushSwitch()
Creates a new break label and a element for the state stack so pop has to be called later |
protected 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, String sig)
|
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Method Detail |
---|
public void addExceptionBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label goal, String sig)
public void applyBlockRecorder()
public void applyFinallyBlocks(org.objectweb.asm.Label label, boolean isBreakLabel)
public void clear()
public boolean containsVariable(String name)
name
- the name of the variable of interest
public org.objectweb.asm.Label createLocalLabel(String name)
public int defineTemporaryVariable(def var, boolean store)
var
- defines type and namestore
- defines if the toplevel argument of the stack should be stored
public int defineTemporaryVariable(String name, boolean store)
name
- defines type and namestore
- defines if the toplevel argument of the stack should be stored
public int defineTemporaryVariable(String name, ClassNode node, boolean store)
name
- defines the namenode
- defines the nodestore
- defines if the toplevel argument of the stack should be stored
public Variable defineVariable(def v, boolean initFromStack)
initFromStack
- if true the last element of the
stack will be used to initilize
the new variable. If false null
will be used.
public org.objectweb.asm.Label getBreakLabel()
public org.objectweb.asm.Label getContinueLabel()
public org.objectweb.asm.Label getLabel(String name)
protected org.objectweb.asm.Label getNamedBreakLabel(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.
protected org.objectweb.asm.Label getNamedContinueLabel(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 VariableScope getScope()
public Variable getVariable(String variableName)
public Variable getVariable(String variableName, boolean mustExist)
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 boolean hasBlockRecorder()
protected void init(VariableScope el, Parameter[] parameters, org.objectweb.asm.MethodVisitor mv, ClassNode cn)
public void pop()
public void popBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)
public void pushBlockRecorder(CompileStack.BlockRecorder recorder)
public void pushBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)
protected void pushBooleanExpression()
protected void pushLoop(VariableScope el, String labelName)
protected void pushLoop(String labelName)
protected void pushState()
protected org.objectweb.asm.Label pushSwitch()
protected void pushVariableScope(VariableScope el)
public void removeVar(int tempIndex)
public void writeExceptionTable(CompileStack.BlockRecorder block, org.objectweb.asm.Label goal, String sig)
Copyright © 2003-2010 The Codehaus. All rights reserved.