harpoon.Temp
Class Temp

java.lang.Object
  extended by harpoon.Temp.Temp
All Implemented Interfaces:
Serializable, Cloneable, Comparable<Temp>, ReferenceUnique
Direct Known Subclasses:
LocalCffRegAlloc.PreassignTemp, TempChain, TwoWordTemp

public class Temp
extends Object
implements Cloneable, Comparable<Temp>, ReferenceUnique, Serializable

The Temp class represents a temporary variable. This class maintains static state to allow us to allocate guaranteed-unique names for our temps.

Version:
$Id: Temp.java,v 1.18 2004/02/08 01:59:47 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
TypeMap, ConstMap, TempList, Serialized Form

Field Summary
static ArrayFactory<Temp> arrayFactory
          Returns an array of Temps.
static ArrayFactory<Temp[]> doubleArrayFactory
          Returns an array of Temp[]s.
static Indexer INDEXER
          A net.cscott.jutil.Indexer specifically for working only with Temps generated by this.tempFactory().
 
Constructor Summary
Temp(Temp t)
          Creates a new temp based on the name of an existing temp.
Temp(TempFactory tf)
          Creates a unique temporary variable, using default prefix ("t").
Temp(TempFactory tf, String prefix)
          Creates a unique temporary with a suggested name.
 
Method Summary
 Temp clone()
          Clones a Temp using the same TempFactory.
 Temp clone(TempFactory tf)
          Clones a Temp into a different TempFactory.
 int compareTo(Temp o)
          Comparable interface: sorted by fullname().
 String fullname()
          Returns the full name of this temporary, including scope information.
 int hashCode()
          Returns a hashcode for this temporary.
 String name()
          Returns the common name of this Temp; scope information not included.
 TempFactory tempFactory()
          Returns the tempFactory of this temporary.
static TempFactory tempFactory(String scope)
          Returns a new TempFactory with the given scope.
 String toString()
          Returns a string representation of this temporary.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

INDEXER

public static Indexer INDEXER
A net.cscott.jutil.Indexer specifically for working only with Temps generated by this.tempFactory().


arrayFactory

public static final ArrayFactory<Temp> arrayFactory
Returns an array of Temps.


doubleArrayFactory

public static final ArrayFactory<Temp[]> doubleArrayFactory
Returns an array of Temp[]s.

Constructor Detail

Temp

public Temp(TempFactory tf)
Creates a unique temporary variable, using default prefix ("t").


Temp

public Temp(Temp t)
Creates a new temp based on the name of an existing temp.


Temp

public Temp(TempFactory tf,
            String prefix)
Creates a unique temporary with a suggested name. Trailing digits will be stripped from the suggested name, and a digit string will be appended to make the name unique within the scope of the TempFactory.

Parameters:
prefix - the name prefix. prefix may not be null.
Method Detail

fullname

public String fullname()
Returns the full name of this temporary, including scope information.


name

public String name()
Returns the common name of this Temp; scope information not included.


toString

public String toString()
Returns a string representation of this temporary.

Overrides:
toString in class Object

tempFactory

public TempFactory tempFactory()
Returns the tempFactory of this temporary.


clone

public Temp clone(TempFactory tf)
Clones a Temp into a different TempFactory.


clone

public Temp clone()
Clones a Temp using the same TempFactory.

Overrides:
clone in class Object

hashCode

public int hashCode()
Returns a hashcode for this temporary. The hashcode is formed from the scope name and the temporary name.

Overrides:
hashCode in class Object

compareTo

public int compareTo(Temp o)
Comparable interface: sorted by fullname().

Specified by:
compareTo in interface Comparable<Temp>

tempFactory

public static TempFactory tempFactory(String scope)
Returns a new TempFactory with the given scope.