harpoon.IR.Tree
Class DerivationGenerator

java.lang.Object
  extended by harpoon.IR.Tree.DerivationGenerator
All Implemented Interfaces:
TreeDerivation

public class DerivationGenerator
extends Object
implements TreeDerivation

DerivationGenerator takes a partial map of Tree.Exps-to-type/derivations and answers type/derivation queries as if the complete map were present. In particular, only Tree.TEMPs and Tree.MEMs are typically explicitly typed in the map; types for the rest of the Tree.Exps can be inferred from these.

Version:
$Id: DerivationGenerator.java,v 1.4 2002/04/10 03:05:44 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>

Constructor Summary
DerivationGenerator()
          Creates a DerivationGenerator.
 
Method Summary
 Tree.CloneCallback cloneCallback(TreeDerivation oldDeriv)
           
 Derivation.DList derivation(Exp exp)
          Returns the derivation of a given tree expression exp.
 void putDerivation(Exp exp, Derivation.DList derivation)
          Add a mapping from the given Tree.Exp exp to the given Derivation.DList derivation.
 void putType(Exp exp, HClass type)
          Add a mapping from the given Tree.Exp exp to the given HClass type to this DerivationGenerator.
 void putTypeAndTemp(Exp exp, HClass type, Temp temp)
          Add a mapping from the given Tree.Exp exp to the given HClass type to the DerivationGenerator, indicating that this value lives in Temp temp.
 void remove(Exp exp)
          Remove all type and derivation mappings for the given Tree.Exp.
 HClass typeMap(Exp exp)
          Returns the type of a given tree expression exp.
 void update(Exp oldE, Exp newE)
          Transfer typing from one exp to another.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DerivationGenerator

public DerivationGenerator()
Creates a DerivationGenerator.

Method Detail

typeMap

public HClass typeMap(Exp exp)
               throws TypeMap.TypeNotKnownException
Description copied from interface: TreeDerivation
Returns the type of a given tree expression exp. If the type of the Tree.Exp is not known, throws TypeNotKnownException. If the Tree.Exp represents a derived pointer, null is returned, in which case the derivation() method must return a non-null value. HClass.Void is returned to indicate the type of a null pointer; as a special case, it is also returned to indicate the type of an opaque pointer value which does not correspond to a java object pointer or some derivation thereof and thus should not be traced during garbage collection.

Specified by:
typeMap in interface TreeDerivation
Parameters:
exp - The tree expression to examine.
Returns:
the type of exp
Throws:
TypeMap.TypeNotKnownException - if the TreeDerivation does not have any information about exp.
See Also:
TypeMap

derivation

public Derivation.DList derivation(Exp exp)
                            throws TypeMap.TypeNotKnownException
Description copied from interface: TreeDerivation
Returns the derivation of a given tree expression exp. If the derivation of the Tree.Exp is not known, throws TypeNotKnownException. If the Tree.Exp represents a non-derived base pointer, returns null, in which case the typeMap() method must return a non-null value.

Specified by:
derivation in interface TreeDerivation
Parameters:
exp - The tree expression to examine.
Returns:
the derivation of exp
Throws:
TypeMap.TypeNotKnownException - if the TreeDerivation does not have any information about exp.
See Also:
Derivation

putType

public void putType(Exp exp,
                    HClass type)
Add a mapping from the given Tree.Exp exp to the given HClass type to this DerivationGenerator.


putTypeAndTemp

public void putTypeAndTemp(Exp exp,
                           HClass type,
                           Temp temp)
Add a mapping from the given Tree.Exp exp to the given HClass type to the DerivationGenerator, indicating that this value lives in Temp temp.


putDerivation

public void putDerivation(Exp exp,
                          Derivation.DList derivation)
Add a mapping from the given Tree.Exp exp to the given Derivation.DList derivation.


update

public void update(Exp oldE,
                   Exp newE)
Transfer typing from one exp to another.


remove

public void remove(Exp exp)
Remove all type and derivation mappings for the given Tree.Exp. Used for memory management purposes.


cloneCallback

public Tree.CloneCallback cloneCallback(TreeDerivation oldDeriv)