polyglot.ext.param.types
Class Subst_c

java.lang.Object
  extended by polyglot.ext.param.types.Subst_c
All Implemented Interfaces:
java.io.Serializable, Subst
Direct Known Subclasses:
CofferSubst_c

public class Subst_c
extends java.lang.Object
implements Subst

Utility class that performs substitutions on type objects using a map. Subclasses must define how the substititions are performed and how to cache substituted types.

See Also:
Serialized Form

Nested Class Summary
 class Subst_c.ConstructorXform
          Function object for transforming constructors.
 class Subst_c.FieldXform
          Function object for transforming fields.
 class Subst_c.MethodXform
          Function object for transforming methods.
 class Subst_c.TypeXform
          Function object for transforming types.
 
Field Summary
protected  java.util.Map cache
          Cache of types.
protected  java.util.Map subst
          Map from formal parameters (of type Param) to actuals.
protected  ParamTypeSystem ts
           
 
Constructor Summary
Subst_c(ParamTypeSystem ts, java.util.Map subst, java.util.Map cache)
           
 
Method Summary
 java.util.Iterator entries()
          Entries of the underlying substitution map.
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 ClassType substClassType(ClassType t)
          Perform substitutions on a class type.
 ConstructorInstance substConstructor(ConstructorInstance ci)
          Perform substitutions on a constructor.
 java.util.List substConstructorList(java.util.List list)
          Perform substititions on a list of ConstructorInstance.
 FieldInstance substField(FieldInstance fi)
          Perform substitutions on a field.
 java.util.List substFieldList(java.util.List list)
          Perform substititions on a list of FieldInstance.
 java.util.Map substitutions()
          The underlying substitution map.
 MethodInstance substMethod(MethodInstance mi)
          Perform substitutions on a method.
 java.util.List substMethodList(java.util.List list)
          Perform substititions on a list of MethodInstance.
 PClass substPClass(PClass pclazz)
          Perform substitution on a PClass.
protected  java.lang.Object substSubstValue(java.lang.Object value)
          When adding a new substitution A->B to the map, we need to check if there are already any existing substitutions, say C->A, and if so, replace them appropriately, in this case with C->B.
 Type substType(Type t)
          Perform substitutions on a type.
 java.util.List substTypeList(java.util.List list)
          Perform substititions on a list of Type.
 java.lang.String toString()
           
 ParamTypeSystem typeSystem()
          Type system
protected  Type uncachedSubstType(Type t)
          Perform substitutions on a type, without checking the cache.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

subst

protected java.util.Map subst
Map from formal parameters (of type Param) to actuals.


cache

protected transient java.util.Map cache
Cache of types.


ts

protected transient ParamTypeSystem ts
Constructor Detail

Subst_c

public Subst_c(ParamTypeSystem ts,
               java.util.Map subst,
               java.util.Map cache)
Method Detail

typeSystem

public ParamTypeSystem typeSystem()
Description copied from interface: Subst
Type system

Specified by:
typeSystem in interface Subst

entries

public java.util.Iterator entries()
Entries of the underlying substitution map.

Specified by:
entries in interface Subst
Returns:
an Iterator of Map.Entry.

substitutions

public java.util.Map substitutions()
The underlying substitution map.

Specified by:
substitutions in interface Subst

uncachedSubstType

protected Type uncachedSubstType(Type t)
Perform substitutions on a type, without checking the cache.


substSubstValue

protected java.lang.Object substSubstValue(java.lang.Object value)
When adding a new substitution A->B to the map, we need to check if there are already any existing substitutions, say C->A, and if so, replace them appropriately, in this case with C->B. This method allows subclasses to perform substitution on a value in the substitution map (B in the example above). Subclasses may need to override this if the keys and values are not the same object.


substClassType

public ClassType substClassType(ClassType t)
Perform substitutions on a class type. Substitutions are performed lazily.


substType

public Type substType(Type t)
Perform substitutions on a type.

Specified by:
substType in interface Subst

substPClass

public PClass substPClass(PClass pclazz)
Perform substitution on a PClass.

Specified by:
substPClass in interface Subst

substField

public FieldInstance substField(FieldInstance fi)
Perform substitutions on a field.

Specified by:
substField in interface Subst

substMethod

public MethodInstance substMethod(MethodInstance mi)
Perform substitutions on a method.

Specified by:
substMethod in interface Subst

substConstructor

public ConstructorInstance substConstructor(ConstructorInstance ci)
Perform substitutions on a constructor.

Specified by:
substConstructor in interface Subst

substTypeList

public java.util.List substTypeList(java.util.List list)
Perform substititions on a list of Type.

Specified by:
substTypeList in interface Subst

substMethodList

public java.util.List substMethodList(java.util.List list)
Perform substititions on a list of MethodInstance.

Specified by:
substMethodList in interface Subst

substConstructorList

public java.util.List substConstructorList(java.util.List list)
Perform substititions on a list of ConstructorInstance.

Specified by:
substConstructorList in interface Subst

substFieldList

public java.util.List substFieldList(java.util.List list)
Perform substititions on a list of FieldInstance.

Specified by:
substFieldList in interface Subst

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object