Class SymTypeExpression

java.lang.Object
de.monticore.types.check.SymTypeExpression
All Implemented Interfaces:
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 Object implements 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 Details

    • LOG_NAME

      protected static final String LOG_NAME
      See Also:
    • functionList

      @Deprecated(forRemoval=true) protected 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
  • Constructor Details

    • SymTypeExpression

      public SymTypeExpression()
  • Method Details

    • print

      public String print()
      print: Conversion to a compact string, such as "int", "Person", "List< A >"
    • printFullName

      public String printFullName()
      printFullName: prints the full name of the symbol, such as "java.util.List<java.lang.String>"
      Returns:
    • printAsJson

      protected 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 unused
      Am 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:
      compareTo in interface Comparable<SymTypeExpression>
    • getMethodList

      @Deprecated(forRemoval=true) public List<FunctionSymbol> getMethodList(String methodName, boolean abstractTc)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getMethodList

      @Deprecated(forRemoval=true) public List<FunctionSymbol> getMethodList(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 List<FunctionSymbol> getCorrectMethods(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 List<FunctionSymbol> getCorrectMethods(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 for
      outerIsType - true if last result of type check was type, false if it was an instance
      abstractTc - true if the tc is not used for object-oriented languages
      Returns:
      the correct methods for the specific case
    • transformMethodList

      @Deprecated(forRemoval=true) protected List<FunctionSymbol> transformMethodList(String methodName, 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 for
      functions - methods that need to be transformed
      Returns:
      transformed methods
    • replaceTypeVariables

      @Deprecated(forRemoval=true) public void replaceTypeVariables(Map<TypeVarSymbol,SymTypeExpression> replaceMap)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getMethodList

      @Deprecated(forRemoval=true) public List<FunctionSymbol> getMethodList(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 List<FunctionSymbol> getMethodList(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 for
      outerIsType - 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 List<VariableSymbol> getFieldList(String fieldName, boolean abstractTc)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getFieldList

      @Deprecated(forRemoval=true) public List<VariableSymbol> getFieldList(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 List<VariableSymbol> getFieldList(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 List<VariableSymbol> getFieldList(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 for
      outerIsType - 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 List<VariableSymbol> getCorrectFields(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 List<VariableSymbol> getCorrectFields(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 for
      outerIsType - 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 List<VariableSymbol> transformFieldList(String fieldName, 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 for
      fields - 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 to hasTypeInfo()

      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)