de.uka.ipd.sdq.ByCounter.instrumentation
Class LocalVariableManager

java.lang.Object
  extended by de.uka.ipd.sdq.ByCounter.instrumentation.LocalVariableManager

public final class LocalVariableManager
extends java.lang.Object

Class for managing the indices for local variables in bytecode. For all getNew* methods, the outcome depends on the setting of getUseHighRegisters().

Author:
Martin Krogmann

Constructor Summary
LocalVariableManager(boolean useHighRegisters)
           
 
Method Summary
 int getNewIntArrayVar(org.objectweb.asm.MethodVisitor mv)
          Register a new int[].
 int getNewIntVar(org.objectweb.asm.MethodVisitor mv)
          Register a new int and initialize it with 0.
 int getNewLongArrayVar(org.objectweb.asm.MethodVisitor mv)
          Register a new long[].
 int getNewLongVar(org.objectweb.asm.MethodVisitor mv)
          Register a new long and initialize it with 0.
 int getNewStringArrayVar(org.objectweb.asm.MethodVisitor mv)
          Register a new String[].
 int getNewVarFor(java.lang.String readableDescr, org.objectweb.asm.MethodVisitor mv, org.objectweb.asm.Type type, int localVarSize)
          Register a new variable of type 'type'.
 boolean getUseHighRegisters()
           
 void setLVS(org.objectweb.asm.commons.LocalVariablesSorter pLvars)
          Sets the LocalVariableSorter that is used to generate new locals.
 void setUseHighRegisters(boolean useHighRegisters)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocalVariableManager

public LocalVariableManager(boolean useHighRegisters)
Method Detail

getNewIntArrayVar

public int getNewIntArrayVar(org.objectweb.asm.MethodVisitor mv)
Register a new int[]. Does not initialize it.

Parameters:
mv - The MethodVisitor to use for inserting initialisation instructions.
Returns:
The variable index/identifier.

getNewIntVar

public int getNewIntVar(org.objectweb.asm.MethodVisitor mv)
Register a new int and initialize it with 0.

Parameters:
mv - The MethodVisitor to use for inserting initialisation instructions.
Returns:
The variable index/identifier.

getNewLongArrayVar

public int getNewLongArrayVar(org.objectweb.asm.MethodVisitor mv)
Register a new long[]. Does not initialize it.

Parameters:
mv - The MethodVisitor to use for inserting initialisation instructions.
Returns:
The variable index/identifier.

getNewLongVar

public int getNewLongVar(org.objectweb.asm.MethodVisitor mv)
Register a new long and initialize it with 0.

Parameters:
mv - The MethodVisitor to use for inserting initialisation instructions.
Returns:
The variable index/identifier.

getNewStringArrayVar

public int getNewStringArrayVar(org.objectweb.asm.MethodVisitor mv)
Register a new String[]. Does not initialize it.

Parameters:
mv - The MethodVisitor to use for inserting initialisation instructions.
Returns:
The variable index/identifier.

getNewVarFor

public int getNewVarFor(java.lang.String readableDescr,
                        org.objectweb.asm.MethodVisitor mv,
                        org.objectweb.asm.Type type,
                        int localVarSize)
Register a new variable of type 'type'. Do not use unless a more specialised method does not exist (yet).

Parameters:
readableDescr - A readable description of the type. Used for debugging purposes only.
mv - The MethodVisitor to use for inserting initialisation instructions.
type - The type of the new local.
localVarSize - The number of local variables that the var blocks. This is 1 for int, 2 for long, 1 for Object etc.
Returns:
The variable index/identifier.

getUseHighRegisters

public boolean getUseHighRegisters()
Returns:
True when register numbers near the MAX_LOCALS constant are used. False otherwise.

setLVS

public void setLVS(org.objectweb.asm.commons.LocalVariablesSorter pLvars)
Sets the LocalVariableSorter that is used to generate new locals. This must be called before this Manager is used.

Parameters:
pLvars - LocalVariableSorter

setUseHighRegisters

public void setUseHighRegisters(boolean useHighRegisters)
Parameters:
useHighRegisters - When true, use register numbers near the MAX_LOCALS constant.