|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xalan.xsltc.compiler.util.MethodGenerator.LocalVariableRegistry
protected class MethodGenerator.LocalVariableRegistry
Keeps track of all local variables used in the method.
The
MethodGen#addLocalVariable(String,Type,InstructionHandle,InstructionHandle)
and
MethodGen#addLocalVariable(String,Type,int,InstructionHandle,InstructionHandle)
methods of MethodGen
will only keep track of
LocalVariableGen
object until it'ss removed by a call to
MethodGen#removeLocalVariable(LocalVariableGen)
.
In order to support efficient copying of local variables to outlined
methods by
MethodGenerator.outline(InstructionHandle,InstructionHandle,String,ClassGenerator)
,
this class keeps track of all local variables defined by the method.
Field Summary | |
---|---|
protected java.util.HashMap |
_nameToLVGMap
Maps a name to a LocalVariableGen |
protected java.util.ArrayList |
_variables
A java.lang.ArrayList of all
LocalVariableGen s created for this method, indexed by the
slot number of the local variable. |
Constructor Summary | |
---|---|
protected |
MethodGenerator.LocalVariableRegistry()
|
Method Summary | |
---|---|
protected LocalVariableGen[] |
getLocals(boolean includeRemoved)
Gets all LocalVariableGen objects for this method. |
protected LocalVariableGen |
lookUpByName(java.lang.String name)
Given the name of a variable, finds a LocalVariableGen
corresponding to it. |
protected LocalVariableGen |
lookupRegisteredLocalVariable(int slot,
int offset)
Find which LocalVariableGen , if any, is registered for a
particular JVM local stack frame slot at a particular position in the
byte code for the method. |
protected void |
registerByName(LocalVariableGen lvg)
Set up a mapping of the name of the specified LocalVariableGen object to the LocalVariableGen
itself. |
protected void |
registerLocalVariable(LocalVariableGen lvg)
Registers a org.apache.bcel.generic.LocalVariableGen
for this method. |
protected void |
removeByNameTracking(LocalVariableGen lvg)
Remove the mapping from the name of the specified LocalVariableGen to itself. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.ArrayList _variables
A java.lang.ArrayList
of all
LocalVariableGen
s created for this method, indexed by the
slot number of the local variable. The JVM stack frame of local
variables is divided into "slots". A single slot can be used to
store more than one variable in a method, without regard to type, so
long as the byte code keeps the ranges of the two disjoint.
If only one registration of use of a particular slot occurs, the
corresponding entry of _variables
contains the
LocalVariableGen
; if more than one occurs, the
corresponding entry contains all such LocalVariableGen
s
registered for the same slot; and if none occurs, the entry will be
null
.
protected java.util.HashMap _nameToLVGMap
LocalVariableGen
Constructor Detail |
---|
protected MethodGenerator.LocalVariableRegistry()
Method Detail |
---|
protected void registerLocalVariable(LocalVariableGen lvg)
org.apache.bcel.generic.LocalVariableGen
for this method.
Preconditions:
lvg
does not
overlap with the range of instructions for any
LocalVariableGen
with the same slot index previously
registered for this method. (Unchecked.)
lvg
- The variable to be registeredprotected LocalVariableGen lookupRegisteredLocalVariable(int slot, int offset)
Find which LocalVariableGen
, if any, is registered for a
particular JVM local stack frame slot at a particular position in the
byte code for the method.
Preconditions:
InstructionList#setPositions()
has been called for
the InstructionList
associated with this
MethodGenerator
.
slot
- the JVM local stack frame slot numberoffset
- the position in the byte code
LocalVariableGen
for the local variable
stored in the relevant slot at the relevant offset; null
if there is none.protected void registerByName(LocalVariableGen lvg)
Set up a mapping of the name of the specified
LocalVariableGen
object to the LocalVariableGen
itself.
This is a bit of a hack. XSLTC is relying on the fact that the
name that is being looked up won't be duplicated, which isn't
guaranteed. It replaces code which used to call
MethodGen#getLocalVariables()
and looped through the
LocalVariableGen
objects it contained to find the one
with the specified name. However, getLocalVariables()
has the side effect of setting the start and end for any
LocalVariableGen
which did not already have them
set, which causes problems for outlining..
See also lookUpByName(String)
and
removeByNameTracking(LocalVariableGen)
lvg
- a LocalVariableGen
protected void removeByNameTracking(LocalVariableGen lvg)
LocalVariableGen
to itself.
See also registerByName(LocalVariableGen)
and
lookUpByName(String)
lvg
- a LocalVariableGen
protected LocalVariableGen lookUpByName(java.lang.String name)
Given the name of a variable, finds a LocalVariableGen
corresponding to it.
See also registerByName(LocalVariableGen)
and
removeByNameTracking(LocalVariableGen)
name
-
protected LocalVariableGen[] getLocals(boolean includeRemoved)
Gets all LocalVariableGen
objects for this method.
When the includeRemoved
argument has the value
false
, this method replaces uses of
MethodGen#getLocalVariables()
which has
a side-effect of setting the start and end range for any
LocalVariableGen
if either was null
. That
side-effect causes problems for outlining of code in XSLTC.
includeRemoved
- Specifies whether all local variables ever
declared should be returned (true
) or only those not
removed (false
)
LocalVariableGen
containing all the
local variables
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |