com.veromodo.tempo.sem.type
Class GenericizeType

java.lang.Object
  extended by com.veromodo.tempo.sem.type.TypeVisitor
      extended by com.veromodo.tempo.sem.type.GenericizeType

public class GenericizeType
extends TypeVisitor

This class is responsible for analyzing a type tree to turn it into a generic type. It will automatically do the following - If there are no TypeParameters at all, the function behaves like the identity function (no changes) - If the type is a single parameter, the function behaves like the identity - If the type is a composite, it is analyzed to 'hoist' the generic that may appear within the type. in that case the inductive step is fairly simple. For a type constructor C(T1,T2) , we hoist T1 to get T1' we hoist T2 to get T2' we extract the list of parameters in T1' we extract the list of parameters in T2' we take the union of the two list of parameters if (T1!=T1' || T2!=T2') we create a new type C(T1',T2') otherwise, we return the original C(T1,T2) along with the union of the parameter list. -If the type is a generic(T) we hoist T to T' and collect the parameters, then we discard the generic -Finally, when the hoisting is complete at the root, if there is a least 1 parameter, a generic is created at the root.

Author:
ldm

Constructor Summary
GenericizeType(TypeFactory tf)
           
 
Method Summary
 void applyTypeAugmentedReal(TypeAugmentedReal n)
           
 void applyTypeBasicAutomaton(TypeBasicAutomaton n)
           
 void applyTypeBool(TypeBool n)
           
 void applyTypeChar(TypeChar n)
           
 void applyTypeCompositeAutomaton(TypeCompositeAutomaton n)
           
 void applyTypeConstructor(TypeConstructor n)
           
 void applyTypeDiscreteReal(TypeDiscreteReal n)
           
 void applyTypeEnum(TypeEnum n)
           
 void applyTypeEnumValue(TypeEnumValue n)
           
 void applyTypeError(TypeError n)
           
 void applyTypeFloat(TypeFloat n)
           
 void applyTypeFunction(TypeFunction n)
           
 void applyTypeFunctionalGeneric(TypeFunctionalGeneric n)
           
 void applyTypeGeneric(TypeGeneric n)
           
 void applyTypeId(TypeId n)
           
 void applyTypeInstance(TypeInstance n)
           
 void applyTypeInt(TypeInt n)
           
 void applyTypeInt32(TypeInt32 n)
           
 void applyTypeList(TypeList n)
           
 void applyTypeMap(TypeMap n)
           
 void applyTypeMatrix(TypeArray n)
           
 void applyTypeMeta(TypeMeta n)
           
 void applyTypeNat(TypeNat n)
           
 void applyTypeParameter(TypeParameter n)
           
 void applyTypeReal(TypeReal n)
           
 void applyTypeSum(TypeSum n)
           
 void applyTypeTuple(TypeTuple n)
           
 void applyTypeVariable(TypeVariable n)
           
 void applyTypeVoid(TypeVoid n)
           
 Type run(Type t)
           
 
Methods inherited from class com.veromodo.tempo.sem.type.TypeVisitor
applyTypeAutomaton, applyTypeFunctional, applyTypeIndexed, doIt
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericizeType

public GenericizeType(TypeFactory tf)
Method Detail

run

public Type run(Type t)

applyTypeNat

public void applyTypeNat(TypeNat n)
Overrides:
applyTypeNat in class TypeVisitor

applyTypeBool

public void applyTypeBool(TypeBool n)
Overrides:
applyTypeBool in class TypeVisitor

applyTypeError

public void applyTypeError(TypeError n)
Overrides:
applyTypeError in class TypeVisitor

applyTypeFloat

public void applyTypeFloat(TypeFloat n)
Overrides:
applyTypeFloat in class TypeVisitor

applyTypeDiscreteReal

public void applyTypeDiscreteReal(TypeDiscreteReal n)
Overrides:
applyTypeDiscreteReal in class TypeVisitor

applyTypeAugmentedReal

public void applyTypeAugmentedReal(TypeAugmentedReal n)
Overrides:
applyTypeAugmentedReal in class TypeVisitor

applyTypeId

public void applyTypeId(TypeId n)
Overrides:
applyTypeId in class TypeVisitor

applyTypeInt

public void applyTypeInt(TypeInt n)
Overrides:
applyTypeInt in class TypeVisitor

applyTypeInt32

public void applyTypeInt32(TypeInt32 n)
Overrides:
applyTypeInt32 in class TypeVisitor

applyTypeVoid

public void applyTypeVoid(TypeVoid n)
Overrides:
applyTypeVoid in class TypeVisitor

applyTypeReal

public void applyTypeReal(TypeReal n)
Overrides:
applyTypeReal in class TypeVisitor

applyTypeChar

public void applyTypeChar(TypeChar n)
Overrides:
applyTypeChar in class TypeVisitor

applyTypeMeta

public void applyTypeMeta(TypeMeta n)
Overrides:
applyTypeMeta in class TypeVisitor

applyTypeParameter

public void applyTypeParameter(TypeParameter n)
Overrides:
applyTypeParameter in class TypeVisitor

applyTypeList

public void applyTypeList(TypeList n)
Overrides:
applyTypeList in class TypeVisitor

applyTypeSum

public void applyTypeSum(TypeSum n)
Overrides:
applyTypeSum in class TypeVisitor

applyTypeTuple

public void applyTypeTuple(TypeTuple n)
Overrides:
applyTypeTuple in class TypeVisitor

applyTypeMatrix

public void applyTypeMatrix(TypeArray n)
Overrides:
applyTypeMatrix in class TypeVisitor

applyTypeConstructor

public void applyTypeConstructor(TypeConstructor n)
Overrides:
applyTypeConstructor in class TypeVisitor

applyTypeFunction

public void applyTypeFunction(TypeFunction n)
Overrides:
applyTypeFunction in class TypeVisitor

applyTypeGeneric

public void applyTypeGeneric(TypeGeneric n)
Overrides:
applyTypeGeneric in class TypeVisitor

applyTypeFunctionalGeneric

public void applyTypeFunctionalGeneric(TypeFunctionalGeneric n)
Overrides:
applyTypeFunctionalGeneric in class TypeVisitor

applyTypeMap

public void applyTypeMap(TypeMap n)
Overrides:
applyTypeMap in class TypeVisitor

applyTypeEnum

public void applyTypeEnum(TypeEnum n)
Overrides:
applyTypeEnum in class TypeVisitor

applyTypeEnumValue

public void applyTypeEnumValue(TypeEnumValue n)
Overrides:
applyTypeEnumValue in class TypeVisitor

applyTypeVariable

public void applyTypeVariable(TypeVariable n)
Overrides:
applyTypeVariable in class TypeVisitor

applyTypeBasicAutomaton

public void applyTypeBasicAutomaton(TypeBasicAutomaton n)
Overrides:
applyTypeBasicAutomaton in class TypeVisitor

applyTypeCompositeAutomaton

public void applyTypeCompositeAutomaton(TypeCompositeAutomaton n)
Overrides:
applyTypeCompositeAutomaton in class TypeVisitor

applyTypeInstance

public void applyTypeInstance(TypeInstance n)
Overrides:
applyTypeInstance in class TypeVisitor