edu.umd.cs.findbugs.ba.vna

Class LoadedFieldSet

public class LoadedFieldSet extends Object

Object which stores which fields are loaded and stored by the instructions in a method (including through inner-class access methods), and also which fields are loaded/stored by the overall method. The main purpose is for doing redundant load elimination and forward substitution more efficiently, but it might be useful in other situations.

Author: David Hovemeyer

Nested Class Summary
static classLoadedFieldSet.LoadStoreCount
Count number of times a field is loaded and/or stored in the method.
Constructor Summary
LoadedFieldSet(MethodGen methodGen)
Constructor.
Method Summary
voidaddLoad(InstructionHandle handle, XField field)
Add a load of given field at given instruction.
voidaddStore(InstructionHandle handle, XField field)
Add a store of given field at given instruction.
XFieldgetField(InstructionHandle handle)
Get the field loaded or stored at given instruction, if any.
LoadedFieldSet.LoadStoreCountgetLoadStoreCount(XField field)
Get the number of times given field is loaded and stored within the method.
booleaninstructionIsLoad(InstructionHandle handle)
Return whether or not the given instruction is a load.
booleanisLoaded(XField field)
Return whether or not the given field is loaded by any instruction in the method.

Constructor Detail

LoadedFieldSet

public LoadedFieldSet(MethodGen methodGen)
Constructor. Constructs an empty object.

Parameters: methodGen the method being analyzed for loads/stores

Method Detail

addLoad

public void addLoad(InstructionHandle handle, XField field)
Add a load of given field at given instruction.

Parameters: handle the instruction field the field

addStore

public void addStore(InstructionHandle handle, XField field)
Add a store of given field at given instruction.

Parameters: handle the instruction field the field

getField

public XField getField(InstructionHandle handle)
Get the field loaded or stored at given instruction, if any.

Parameters: handle the instruction

Returns: the field loaded or stored at the instruction, or null if the instruction is not a load or store

getLoadStoreCount

public LoadedFieldSet.LoadStoreCount getLoadStoreCount(XField field)
Get the number of times given field is loaded and stored within the method.

Parameters: field the field

Returns: the load/store count object

instructionIsLoad

public boolean instructionIsLoad(InstructionHandle handle)
Return whether or not the given instruction is a load.

Parameters: handle the instruction

Returns: true if the instruction is a load, false if not

isLoaded

public boolean isLoaded(XField field)
Return whether or not the given field is loaded by any instruction in the method.

Parameters: field the field

Returns: true if the field is loaded somewhere in the method, false if it is never loaded

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.