Package de.monticore.types.check
Class SymTypeExpression
- java.lang.Object
-
- de.monticore.types.check.SymTypeExpression
-
- All Implemented Interfaces:
java.lang.Comparable<SymTypeExpression>
- Direct Known Subclasses:
SymTypeArray,SymTypeInferenceVariable,SymTypeObscure,SymTypeOfFunction,SymTypeOfGenerics,SymTypeOfIntersection,SymTypeOfNull,SymTypeOfNumericWithSIUnit,SymTypeOfObject,SymTypeOfRegEx,SymTypeOfSIUnit,SymTypeOfTuple,SymTypeOfUnion,SymTypeOfWildcard,SymTypePrimitive,SymTypeVariable,SymTypeVoid
public abstract class SymTypeExpression extends java.lang.Object implements java.lang.Comparable<SymTypeExpression>
SymTypeExpression is the superclass for all typeexpressions, such as TypeConstants, TypeVariables and applications of Type-Constructors. It shares common functionality (such as comparison, printing)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<FunctionSymbol>functionListDeprecated, for removal: This API element is subject to removal in a future version.protected static java.lang.StringLOG_NAMEprotected SymTypeSourceInfosourceInfoprotected TypeSymboltypeSymbolDeprecated, for removal: This API element is subject to removal in a future version.TypeSymbols are to be found in the corresponding subclasses, however, not every subclass will have a type symbol
-
Constructor Summary
Constructors Constructor Description SymTypeExpression()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void_internal_setSourceInfo(SymTypeSourceInfo sourceInfo)used during deep-cloning, clones the SymTypeSourceInfovoidaccept(ISymTypeVisitor visitor)SymTypeArrayasArrayType()SymTypeOfFunctionasFunctionType()SymTypeOfGenericsasGenericType()SymTypeInferenceVariableasInferenceVariable()SymTypeOfIntersectionasIntersectionType()SymTypeOfNullasNullType()SymTypeOfNumericWithSIUnitasNumericWithSIUnitType()SymTypeOfObjectasObjectType()SymTypeObscureasObscureType()SymTypePrimitiveasPrimitive()SymTypeOfRegExasRegExType()SymTypeOfSIUnitasSIUnitType()SymTypeOfTupleasTupleType()SymTypeVariableasTypeVariable()SymTypeOfUnionasUnionType()SymTypeVoidasVoidType()SymTypeOfWildcardasWildcard()intcompareTo(SymTypeExpression o)SymTypeExpressiondeepClone()abstract booleandeepEquals(SymTypeExpression sym)java.util.List<VariableSymbol>getCorrectFields(java.lang.String fieldName, boolean outerIsType, boolean abstractTc)Deprecated, for removal: This API element is subject to removal in a future version.protected java.util.List<VariableSymbol>getCorrectFields(java.lang.String fieldName, boolean outerIsType, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<FunctionSymbol>getCorrectMethods(java.lang.String methodName, boolean outerIsType, boolean abstractTc)Deprecated, for removal: This API element is subject to removal in a future version.protected java.util.List<FunctionSymbol>getCorrectMethods(java.lang.String methodName, boolean outerIsType, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<VariableSymbol>getFieldList(java.lang.String fieldName, boolean abstractTc)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<VariableSymbol>getFieldList(java.lang.String fieldName, boolean outerIsType, boolean abstractTc)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<VariableSymbol>getFieldList(java.lang.String fieldName, boolean outerIsType, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<VariableSymbol>getFieldList(java.lang.String fieldName, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<FunctionSymbol>getMethodList(java.lang.String methodName, boolean abstractTc)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<FunctionSymbol>getMethodList(java.lang.String methodName, boolean outerIsType, boolean abstractTc)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<FunctionSymbol>getMethodList(java.lang.String methodName, boolean outerIsType, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)Deprecated, for removal: This API element is subject to removal in a future version.java.util.List<FunctionSymbol>getMethodList(java.lang.String methodname, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)Deprecated, for removal: This API element is subject to removal in a future version.SymTypeSourceInfogetSourceInfo()Contains information where this SymTypeExpression comes from.TypeSymbolgetTypeInfo()Returns an TypeSymbol representing the type Only to be called according tohasTypeInfo()booleanhasTypeInfo()Whether we can call getTypeInfobooleanisArrayType()Am I an array?booleanisFunctionType()Am I a function type (e.g.booleanisGenericType()Am I a generic type? (such as"List<Integer>")booleanisInferenceVariable()Am I a free type variable?booleanisIntersectionType()Am I an intersection type (e.g.booleanisNullType()Am I of null type?booleanisNumericWithSIUnitType()Am I a numeric with SIUnit type (e.g.,"[km/h]<float>")booleanisObjectType()Am I an object type? (e.g.booleanisObscureType()Can I not have a type derived from (e.g.booleanisPrimitive()Am I primitive? (such as "int") (default: no)booleanisRegExType()Am I a regex type (e.g.booleanisSIUnitType()Am I an SIUnit type (e.g., "[km/h]")booleanisTupleType()Am I a tuple type (e.g.booleanisTypeVariable()Am I a bound type variable?booleanisUnionType()Am I an union type (e.g.booleanisValidType()Deprecated, for removal: This API element is subject to removal in a future version.not well-thought-out and unusedbooleanisVoidType()Am I of void type?booleanisWildcard()Am I a wildcard (s.java.lang.Stringprint()print: Conversion to a compact string, such as"int","Person","List< A >"protected java.lang.StringprintAsJson()printAsJson: Umwandlung in einen kompakten Json Stringjava.lang.StringprintFullName()printFullName: prints the full name of the symbol, such as"java.util.List<java.lang.String>"voidreplaceTypeVariables(java.util.Map<TypeVarSymbol,SymTypeExpression> replaceMap)Deprecated, for removal: This API element is subject to removal in a future version.protected java.util.List<VariableSymbol>transformFieldList(java.lang.String fieldName, java.util.List<VariableSymbol> fields)Deprecated, for removal: This API element is subject to removal in a future version.protected java.util.List<FunctionSymbol>transformMethodList(java.lang.String methodName, java.util.List<FunctionSymbol> functions)Deprecated, for removal: This API element is subject to removal in a future version.
-
-
-
Field Detail
-
LOG_NAME
protected static final java.lang.String LOG_NAME
- See Also:
- Constant Field Values
-
functionList
@Deprecated(forRemoval=true) protected java.util.List<FunctionSymbol> functionList
Deprecated, for removal: This API element is subject to removal in a future version.
-
typeSymbol
@Deprecated(forRemoval=true) protected TypeSymbol typeSymbol
Deprecated, for removal: This API element is subject to removal in a future version.TypeSymbols are to be found in the corresponding subclasses, however, not every subclass will have a type symbol
-
sourceInfo
protected SymTypeSourceInfo sourceInfo
-
-
Method Detail
-
print
public java.lang.String print()
print: Conversion to a compact string, such as"int","Person","List< A >"
-
printFullName
public java.lang.String printFullName()
printFullName: prints the full name of the symbol, such as"java.util.List<java.lang.String>"- Returns:
-
printAsJson
protected java.lang.String printAsJson()
printAsJson: Umwandlung in einen kompakten Json String
-
isValidType
@Deprecated(forRemoval=true) public boolean isValidType()
Deprecated, for removal: This API element is subject to removal in a future version.not well-thought-out and unusedAm I a not valid type? e.g. unknown type, not all type variables set, pseudo types like typeVariables
-
isPrimitive
public boolean isPrimitive()
Am I primitive? (such as "int") (default: no)
-
asPrimitive
public SymTypePrimitive asPrimitive()
-
isGenericType
public boolean isGenericType()
Am I a generic type? (such as"List<Integer>")
-
asGenericType
public SymTypeOfGenerics asGenericType()
-
isTypeVariable
public boolean isTypeVariable()
Am I a bound type variable?
-
asTypeVariable
public SymTypeVariable asTypeVariable()
-
isInferenceVariable
public boolean isInferenceVariable()
Am I a free type variable?
-
asInferenceVariable
public SymTypeInferenceVariable asInferenceVariable()
-
isArrayType
public boolean isArrayType()
Am I an array?
-
asArrayType
public SymTypeArray asArrayType()
-
isVoidType
public boolean isVoidType()
Am I of void type?
-
asVoidType
public SymTypeVoid asVoidType()
-
isNullType
public boolean isNullType()
Am I of null type?
-
asNullType
public SymTypeOfNull asNullType()
-
isObjectType
public boolean isObjectType()
Am I an object type? (e.g. "String", "Person")
-
asObjectType
public SymTypeOfObject asObjectType()
-
isRegExType
public boolean isRegExType()
Am I a regex type (e.g. 'R"rege(x(es)?|xps?)"')
-
asRegExType
public SymTypeOfRegEx asRegExType()
-
isFunctionType
public boolean isFunctionType()
Am I a function type (e.g."String -> Integer")
-
asFunctionType
public SymTypeOfFunction asFunctionType()
-
isSIUnitType
public boolean isSIUnitType()
Am I an SIUnit type (e.g., "[km/h]")
-
asSIUnitType
public SymTypeOfSIUnit asSIUnitType()
-
isNumericWithSIUnitType
public boolean isNumericWithSIUnitType()
Am I a numeric with SIUnit type (e.g.,"[km/h]<float>")
-
asNumericWithSIUnitType
public SymTypeOfNumericWithSIUnit asNumericWithSIUnitType()
-
isTupleType
public boolean isTupleType()
Am I a tuple type (e.g. "(String, int)")
-
asTupleType
public SymTypeOfTuple asTupleType()
-
isUnionType
public boolean isUnionType()
Am I an union type (e.g. "(A|B)")?
-
asUnionType
public SymTypeOfUnion asUnionType()
-
isIntersectionType
public boolean isIntersectionType()
Am I an intersection type (e.g."(A&B)")
-
asIntersectionType
public SymTypeOfIntersection asIntersectionType()
-
isObscureType
public boolean isObscureType()
Can I not have a type derived from (e.g. "1 - student")?
-
asObscureType
public SymTypeObscure asObscureType()
-
isWildcard
public boolean isWildcard()
Am I a wildcard (s. generics)?
-
asWildcard
public SymTypeOfWildcard asWildcard()
-
deepClone
public SymTypeExpression deepClone()
-
deepEquals
public abstract boolean deepEquals(SymTypeExpression sym)
-
compareTo
public int compareTo(SymTypeExpression o)
- Specified by:
compareToin interfacejava.lang.Comparable<SymTypeExpression>
-
getMethodList
@Deprecated(forRemoval=true) public java.util.List<FunctionSymbol> getMethodList(java.lang.String methodName, boolean abstractTc)
Deprecated, for removal: This API element is subject to removal in a future version.
-
getMethodList
@Deprecated(forRemoval=true) public java.util.List<FunctionSymbol> getMethodList(java.lang.String methodname, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)
Deprecated, for removal: This API element is subject to removal in a future version.returns the list of methods the SymTypeExpression can access and filters these for a method with specific name the last calculated type in the type check was no type
-
getCorrectMethods
@Deprecated(forRemoval=true) public java.util.List<FunctionSymbol> getCorrectMethods(java.lang.String methodName, boolean outerIsType, boolean abstractTc)
Deprecated, for removal: This API element is subject to removal in a future version.
-
getCorrectMethods
@Deprecated(forRemoval=true) protected java.util.List<FunctionSymbol> getCorrectMethods(java.lang.String methodName, boolean outerIsType, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)
Deprecated, for removal: This API element is subject to removal in a future version.return the correct methods for the two situations: 1) the last calculated type in the type check was a type, then filter for non-static methods and add the static methods of this type 2) the last calculated type in the type check was an instance, then just resolve for methods- Parameters:
methodName- name of the method we search forouterIsType- true if last result of type check was type, false if it was an instanceabstractTc- true if the tc is not used for object-oriented languages- Returns:
- the correct methods for the specific case
-
transformMethodList
@Deprecated(forRemoval=true) protected java.util.List<FunctionSymbol> transformMethodList(java.lang.String methodName, java.util.List<FunctionSymbol> functions)
Deprecated, for removal: This API element is subject to removal in a future version.transforms the methods by replacing their type variables with the actual type arguments- Parameters:
methodName- name of the method we search forfunctions- methods that need to be transformed- Returns:
- transformed methods
-
replaceTypeVariables
@Deprecated(forRemoval=true) public void replaceTypeVariables(java.util.Map<TypeVarSymbol,SymTypeExpression> replaceMap)
Deprecated, for removal: This API element is subject to removal in a future version.
-
getMethodList
@Deprecated(forRemoval=true) public java.util.List<FunctionSymbol> getMethodList(java.lang.String methodName, boolean outerIsType, boolean abstractTc)
Deprecated, for removal: This API element is subject to removal in a future version.
-
getMethodList
@Deprecated(forRemoval=true) public java.util.List<FunctionSymbol> getMethodList(java.lang.String methodName, boolean outerIsType, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)
Deprecated, for removal: This API element is subject to removal in a future version.returns the correct methods in both cases: 1) the last result was a type, 2) the last result was an instance- Parameters:
methodName- name of the method we search forouterIsType- true if the last result was a type, false if it was an instance- Returns:
- the correct methods for the specific case
-
getFieldList
@Deprecated(forRemoval=true) public java.util.List<VariableSymbol> getFieldList(java.lang.String fieldName, boolean abstractTc)
Deprecated, for removal: This API element is subject to removal in a future version.
-
getFieldList
@Deprecated(forRemoval=true) public java.util.List<VariableSymbol> getFieldList(java.lang.String fieldName, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)
Deprecated, for removal: This API element is subject to removal in a future version.returns the list of fields the SymTypeExpression can access and filters these for a field with specific name
-
getFieldList
@Deprecated(forRemoval=true) public java.util.List<VariableSymbol> getFieldList(java.lang.String fieldName, boolean outerIsType, boolean abstractTc)
Deprecated, for removal: This API element is subject to removal in a future version.
-
getFieldList
@Deprecated(forRemoval=true) public java.util.List<VariableSymbol> getFieldList(java.lang.String fieldName, boolean outerIsType, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)
Deprecated, for removal: This API element is subject to removal in a future version.returns the correct fields in both cases: 1) the last result was a type, 2) the last result was an instance- Parameters:
fieldName- name of the field we search forouterIsType- true if the last result was a type, false if it was an instance- Returns:
- the correct fields for the specific case
-
getCorrectFields
@Deprecated(forRemoval=true) public java.util.List<VariableSymbol> getCorrectFields(java.lang.String fieldName, boolean outerIsType, boolean abstractTc)
Deprecated, for removal: This API element is subject to removal in a future version.
-
getCorrectFields
@Deprecated(forRemoval=true) protected java.util.List<VariableSymbol> getCorrectFields(java.lang.String fieldName, boolean outerIsType, boolean abstractTc, de.monticore.symboltable.modifiers.AccessModifier modifier)
Deprecated, for removal: This API element is subject to removal in a future version.return the correct fields for the two situations: 1) the last calculated type in the type check was a type, then filter for non-static fields and add the static fields of this type 2) the last calculated type in the type check was an instance, then just resolve for fields- Parameters:
fieldName- name of the field we search forouterIsType- true if last result of type check was type, false if it was an instance- Returns:
- the correct fields for the specific case
-
transformFieldList
@Deprecated(forRemoval=true) protected java.util.List<VariableSymbol> transformFieldList(java.lang.String fieldName, java.util.List<VariableSymbol> fields)
Deprecated, for removal: This API element is subject to removal in a future version.transforms the fields by replacing their type variables with the actual type arguments- Parameters:
fieldName- name of the field we search forfields- fields that need to be transformed- Returns:
- transformed fields
-
hasTypeInfo
public boolean hasTypeInfo()
Whether we can call getTypeInfo
-
getTypeInfo
public TypeSymbol getTypeInfo()
Returns an TypeSymbol representing the type Only to be called according tohasTypeInfo()As most SymTypeExpressions do not have a TypeSymbol (this is legacy), this method will log a warning and is expected to be overridden, if a TypeSymbol exists.
-
getSourceInfo
public SymTypeSourceInfo getSourceInfo()
Contains information where this SymTypeExpression comes from. Used in CoCos, code-generation, etc.not considered during
deepEquals(SymTypeExpression).
-
_internal_setSourceInfo
public void _internal_setSourceInfo(SymTypeSourceInfo sourceInfo)
used during deep-cloning, clones the SymTypeSourceInfo
-
accept
public void accept(ISymTypeVisitor visitor)
-
-