harpoon.Analysis.Quads
Class SimpleConstMap

java.lang.Object
  extended by harpoon.Analysis.Quads.SimpleConstMap
All Implemented Interfaces:
ConstMap

public class SimpleConstMap
extends Object
implements ConstMap

SimpleConstMap is a very simple implementation of ConstMap that reports whether a given Temp is defined by a CONST quad. Although simple, this is sufficient if an SCCOptimize pass has been run on the code factory at some point -- the SCCOptimize transformation will turn more complicated constant expressions into the simple ones that SimpleConstMap detects.

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

Constructor Summary
SimpleConstMap(HCode hc)
          Creates a SimpleConstMap which provides information about HCode hc.
 
Method Summary
 Object constMap(HCodeElement hce, Temp t)
          Determine the constant value of a given temporary in the context of a specific definition.
 boolean isConst(HCodeElement hce, Temp t)
          Determine whether a given temporary has a constant value at the specified definition point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleConstMap

public SimpleConstMap(HCode hc)
Creates a SimpleConstMap which provides information about HCode hc.

Method Detail

isConst

public boolean isConst(HCodeElement hce,
                       Temp t)
Description copied from interface: ConstMap
Determine whether a given temporary has a constant value at the specified definition point.

Specified by:
isConst in interface ConstMap
Parameters:
hce - the definition point.
t - the Temp to be examined.
Returns:
true is the given definition point can be proven to give the specified Temp a constant value, false otherwise.

constMap

public Object constMap(HCodeElement hce,
                       Temp t)
Description copied from interface: ConstMap
Determine the constant value of a given temporary in the context of a specific definition.

Specified by:
constMap in interface ConstMap
Parameters:
hce - the definition point.
t - the temporary to be examined.
Returns:
an object corresponding to the constant value of this temporary defined at this point. Values of base types get wrapped in objects in the standard way.