org.jikesrvm.compilers.opt.liveness
Class LiveSet

java.lang.Object
  extended by org.jikesrvm.compilers.opt.liveness.LiveSet

public class LiveSet
extends Object

This file provides a sorted set (of registers) ADT with the following public operations: clear() - empties the set contains(reg) - checks if reg is in the set add(reg) - adds reg to the set add(set2) - adds the contents of set2 to the set remove(reg) - removes reg from the set remove(set2) - removes the contents of set2 from the set enumerator() - returns an enumeration of the set toString() - returns a string version of the set isEmpty() - returns true, iff the set is empty


Field Summary
private static boolean DEBUG
          just used for debugging
private  LiveSetElement first
          The beginning of the list
 
Constructor Summary
LiveSet()
           
 
Method Summary
 boolean add(LiveSet additionList)
          adds the contents of set2 to the set
 void add(RegisterOperand item)
          create a new object from the passed parameter and add it to the list
 void clear()
          Empties the set
 boolean contains(Register item)
          Determines if the item passed is in the current set
private  LiveSetElement createAndAddToCurrentList(RegisterOperand register, LiveSetElement prevElement)
          Copy the newElement into a new object and add it to the list after prevElement.
 LiveSetEnumerator enumerator()
          Returns an enumerator of the list
private  LiveSetElement getNextPtr(LiveSetElement ptr)
          Inspects the passed ptr, if it is nonnull it returns its next field otherwise, it returns "first"
 boolean isEmpty()
          Is the current set empty?
 void remove(LiveSet removalList)
          removes the contents of the passed set from the currrent set, i.e., this = this - removeList
(package private)  void remove(RegisterOperand item)
          removes the passed reg from the set
 String toString()
          String-i-fy the current list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

first

private LiveSetElement first
The beginning of the list


DEBUG

private static final boolean DEBUG
just used for debugging

See Also:
Constant Field Values
Constructor Detail

LiveSet

public LiveSet()
Method Detail

clear

public final void clear()
Empties the set


contains

public boolean contains(Register item)
Determines if the item passed is in the current set

Parameters:
item - the register to search for
Returns:
whether the item was found

add

public void add(RegisterOperand item)
create a new object from the passed parameter and add it to the list

Parameters:
item - an object that contains the register to used in the newly created object

add

public boolean add(LiveSet additionList)
adds the contents of set2 to the set

Parameters:
additionList -
Returns:
whether any additions were made

remove

public void remove(LiveSet removalList)
removes the contents of the passed set from the currrent set, i.e., this = this - removeList

Parameters:
removalList - the list to remove from

remove

void remove(RegisterOperand item)
removes the passed reg from the set

Parameters:
item - the registerOperand holding the register of interest

isEmpty

public boolean isEmpty()
Is the current set empty?

Returns:
true iff the set is empty

toString

public String toString()
String-i-fy the current list

Overrides:
toString in class Object
Returns:
the string-i-fied version

enumerator

public final LiveSetEnumerator enumerator()
Returns an enumerator of the list

Returns:
an enumerator of the list

createAndAddToCurrentList

private LiveSetElement createAndAddToCurrentList(RegisterOperand register,
                                                 LiveSetElement prevElement)
Copy the newElement into a new object and add it to the list after prevElement. If prevElement is null, update the "start" data member by inserting at the begining.

Parameters:
register - the element to copy and insert
prevElement - the element on the current list to insert after or null, indicating insert at the front
Returns:
the element that is prior to the newly inserted element

getNextPtr

private LiveSetElement getNextPtr(LiveSetElement ptr)
Inspects the passed ptr, if it is nonnull it returns its next field otherwise, it returns "first"

Parameters:
ptr - the ptr to look at it
Returns:
the next field (if ptr is nonnull) or first (if ptr is null)