org.apache.bcel.verifier.statics

Class LocalVariableInfo


public class LocalVariableInfo
extends java.lang.Object

A utility class holding the information about the name and the type of a local variable in a given slot (== index). This information often changes in course of byte code offsets.
Version:
$Id: LocalVariableInfo.java 371539 2006-01-23 14:08:00Z tcurdt $
Author:
Enver Haase

Field Summary

private Hashtable
names
The names database.
private Hashtable
types
The types database.

Method Summary

void
add(String name, int startpc, int length, Type t)
Adds some information about this local variable (slot).
private void
add(int offset, String name, Type t)
Adds information about name and type for a given offset.
String
getName(int offset)
Returns the name of the local variable that uses this local variable slot at the given bytecode offset.
Type
getType(int offset)
Returns the type of the local variable that uses this local variable slot at the given bytecode offset.
private void
setName(int offset, String name)
Adds a name of a local variable and a certain slot to our 'names' (Hashtable) database.
private void
setType(int offset, Type t)
Adds a type of a local variable and a certain slot to our 'types' (Hashtable) database.

Field Details

names

private Hashtable names
The names database. KEY: String representing the offset integer.

types

private Hashtable types
The types database. KEY: String representing the offset integer.

Method Details

add

public void add(String name,
                int startpc,
                int length,
                Type t)
            throws LocalVariableInfoInconsistentException
Adds some information about this local variable (slot).
Throws:
LocalVariableInfoInconsistentException - if the new information conflicts with already gathered information.

add

private void add(int offset,
                 String name,
                 Type t)
            throws LocalVariableInfoInconsistentException
Adds information about name and type for a given offset.
Throws:
LocalVariableInfoInconsistentException - if the new information conflicts with already gathered information.

getName

public String getName(int offset)
Returns the name of the local variable that uses this local variable slot at the given bytecode offset. Care for legal bytecode offsets yourself, otherwise the return value might be wrong. May return 'null' if nothing is known about the type of this local variable slot at the given bytecode offset.

getType

public Type getType(int offset)
Returns the type of the local variable that uses this local variable slot at the given bytecode offset. Care for legal bytecode offsets yourself, otherwise the return value might be wrong. May return 'null' if nothing is known about the type of this local variable slot at the given bytecode offset.

setName

private void setName(int offset,
                     String name)
Adds a name of a local variable and a certain slot to our 'names' (Hashtable) database.

setType

private void setType(int offset,
                     Type t)
Adds a type of a local variable and a certain slot to our 'types' (Hashtable) database.