Groovy 1.7.11

org.codehaus.groovy.classgen
[Java] Class CompileStack

java.lang.Object
  org.codehaus.groovy.classgen.CompileStack
All Implemented Interfaces:
org.objectweb.asm.Opcodes

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:

Authors:
Jochen Theodorou
See Also:
AsmClassGenerator


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)

initializes this class for a MethodNode.

void applyBlockRecorder()

void applyFinallyBlocks(org.objectweb.asm.Label label, boolean isBreakLabel)

void clear()

boolean containsVariable(String name)

Returns the label for the given name

org.objectweb.asm.Label createLocalLabel(String name)

int defineTemporaryVariable(def var, boolean store)

int defineTemporaryVariable(String name, boolean store)

int defineTemporaryVariable(String name, ClassNode node, boolean store)

Variable defineVariable(def v, boolean initFromStack)

@param name the name of the variable of interest

org.objectweb.asm.Label getBreakLabel()

org.objectweb.asm.Label getContinueLabel()

org.objectweb.asm.Label getLabel(String name)

protected org.objectweb.asm.Label getNamedBreakLabel(String name)

Creates a new break label and a element for the state stack so pop has to be called later

protected org.objectweb.asm.Label getNamedContinueLabel(String name)

because a boolean Expression may not be evaluated completly it is important to keep the registers clean

VariableScope getScope()

Variable getVariable(String variableName)

Variable getVariable(String variableName, boolean mustExist)

creates a temporary variable.

boolean hasBlockRecorder()

protected void init(VariableScope el, Parameter[] parameters, org.objectweb.asm.MethodVisitor mv, ClassNode cn)

Causes the statestack to add an element and sets the given scope as new current variable scope.

void pop()

void popBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)

void pushBlockRecorder(CompileStack.BlockRecorder recorder)

void pushBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)

protected void pushBooleanExpression()

protected void pushLoop(VariableScope el, String labelName)

protected void pushLoop(String labelName)

Used for continue foo inside a loop to continue the execution of the marked loop.

protected void pushState()

protected org.objectweb.asm.Label pushSwitch()

protected void pushVariableScope(VariableScope el)

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

addExceptionBlock

public void addExceptionBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label goal, String sig)
initializes this class for a MethodNode. This method will automatically define variables for the method parameters and will create references if needed. The created variables can be accessed by calling getVariable().


applyBlockRecorder

public void applyBlockRecorder()


applyFinallyBlocks

public void applyFinallyBlocks(org.objectweb.asm.Label label, boolean isBreakLabel)


clear

public void clear()


containsVariable

public boolean containsVariable(String name)
Returns the label for the given name


createLocalLabel

public org.objectweb.asm.Label createLocalLabel(String name)


defineTemporaryVariable

public int defineTemporaryVariable(def var, boolean store)


defineTemporaryVariable

public int defineTemporaryVariable(String name, boolean store)


defineTemporaryVariable

public int defineTemporaryVariable(String name, ClassNode node, boolean store)


defineVariable

public Variable defineVariable(def v, boolean initFromStack)
Parameters:
name - the name of the variable of interest
Returns:
true if a variable is already defined


getBreakLabel

public org.objectweb.asm.Label getBreakLabel()


getContinueLabel

public org.objectweb.asm.Label getContinueLabel()


getLabel

public org.objectweb.asm.Label getLabel(String name)


getNamedBreakLabel

protected org.objectweb.asm.Label getNamedBreakLabel(String name)
Creates a new break label and a element for the state stack so pop has to be called later


getNamedContinueLabel

protected org.objectweb.asm.Label getNamedContinueLabel(String name)
because a boolean Expression may not be evaluated completly it is important to keep the registers clean


getScope

public VariableScope getScope()


getVariable

public Variable getVariable(String variableName)


getVariable

public Variable getVariable(String variableName, boolean mustExist)
creates a temporary variable.
Parameters:
name - defines type and name
store - defines if the toplevel argument of the stack should be stored
Returns:
the index used for this temporary variable


hasBlockRecorder

public boolean hasBlockRecorder()


init

protected void init(VariableScope el, Parameter[] parameters, org.objectweb.asm.MethodVisitor mv, ClassNode cn)
Causes the statestack to add an element and sets the given scope as new current variable scope. Creates a element for the state stack so pop has to be called later


pop

public void pop()


popBlockRecorderVisit

public void popBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)


pushBlockRecorder

public void pushBlockRecorder(CompileStack.BlockRecorder recorder)


pushBlockRecorderVisit

public void pushBlockRecorderVisit(CompileStack.BlockRecorder finallyBlock)


pushBooleanExpression

protected void pushBooleanExpression()


pushLoop

protected void pushLoop(VariableScope el, String labelName)


pushLoop

protected void pushLoop(String labelName)
Used for 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.


pushState

protected void pushState()


pushSwitch

protected org.objectweb.asm.Label pushSwitch()


pushVariableScope

protected void pushVariableScope(VariableScope el)


removeVar

public void removeVar(int tempIndex)


writeExceptionTable

public void writeExceptionTable(CompileStack.BlockRecorder block, org.objectweb.asm.Label goal, String sig)


 

Copyright © 2003-2010 The Codehaus. All rights reserved.