Class TypeCalculator

java.lang.Object
de.monticore.types.check.TypeCalculator
All Implemented Interfaces:
ITypeRelations
Direct Known Subclasses:
TypeCheck3AsTypeCalculator

@Deprecated public class TypeCalculator extends Object implements ITypeRelations
Deprecated.
  • Field Details

    • iSynthesize

      protected ISynthesize iSynthesize
      Deprecated.
      Configuration: Visitor for Function 1: Synthesizing the SymTypeExpression from an AST Type. May also be of a subclass;
    • iDerive

      protected IDerive iDerive
      Deprecated.
      Configuration: Visitor for Function 2b: Deriving the SymTypeExpression from an AST Value - Literal. May also be of a subclass;
    • iTypeRelations

      protected ITypeRelations iTypeRelations
      Deprecated.
      Configuration: Implementation for Function 4: Delegatee for ITypeRelations Calculate relations of types.
  • Constructor Details

    • TypeCalculator

      public TypeCalculator(ISynthesize synthesizeSymType, IDerive iDerive, ITypeRelations iTypeRelations)
      Deprecated.
      Configuration as state:
      Parameters:
      synthesizeSymType - defines, which AST Types are mapped (and how)
      iDerive - defines, which AST Literals are handled through the Expression type recognition
      iTypeRelations - defines, what the relations of types are, this is delegated to, to provide the ITypeRelations
    • TypeCalculator

      @Deprecated public TypeCalculator(ISynthesize iSynthesize, IDerive iDerive)
      Deprecated.
  • Method Details

    • symTypeFromAST

      public SymTypeExpression symTypeFromAST(ASTMCType ast)
      Deprecated.
      Function 1: extracting the SymTypeExpression from an AST Type The SymTypeExpression is independent of the AST and can be stored in the SymTab etc. Tests for this Function are combined in the Visitor tests (SynthesizeSymType.*Types.*Test)
    • symTypeFromAST

      public SymTypeExpression symTypeFromAST(ASTMCVoidType ast)
      Deprecated.
      Function 1b: extracting the SymTypeExpression from the AST Type "void" ("void" is not in the ASTMCType hierarchy, while it is included in the SymTypeExpressions)
    • symTypeFromAST

      public SymTypeExpression symTypeFromAST(ASTMCReturnType ast)
      Deprecated.
      Function 1c: extracting the SymTypeExpression from the AST MCReturnType (MCReturnType is not in the ASTMCType hierarchy, while it is included in the SymTypeExpressions) Tests for this Function are combined in the Visitor tests (SynthesizeSymType.*Types.*Test)
    • symTypeFromAST

      public SymTypeExpression symTypeFromAST(ASTMCQualifiedName ast)
      Deprecated.
      Function 1d: extracting the SymTypeExpression from the AST MCQualifiedName Tests for this Function are combined in the Visitor tests (SynthesizeSymType.*Types.*Test)
    • typeOf

      public SymTypeExpression typeOf(ASTExpression expr)
      Deprecated.
      Function 2: Derive the SymTypeExpression from an Expression AST This defines the Type that an Expression has. Precondition: Free Variables in the AST are being looked u through the Symbol Table that needs to be in place; same for method calls etc.
    • typeOf

      public SymTypeExpression typeOf(ASTLiteral lit)
      Deprecated.
      Function 2b: Derive the SymTypeExpression of a Literal This defines the Type that a Literal has and will be used to determine the Type of Expressions. Tests for this Function are combined in the Visitor tests (DeriveSymType.*Literals.*Test)
    • isOfTypeForAssign

      public boolean isOfTypeForAssign(SymTypeExpression type, ASTExpression exp)
      Deprecated.
      Function 4: Checks whether the ASTExpression exp will result in a value that is of type, and thus can be e.g. stored, sent, etc. Essentially exp needs to be of a subtype to be assignment compatible. (as it is combined from other functions, it need not be overwritten)
      Parameters:
      type - the Type it needs to have (e.g. the Type of a variable used for assignment, or the type of a channel where to send a value)
      exp - the Expression that shall be checked for a given type
    • compatible

      public boolean compatible(SymTypeExpression left, SymTypeExpression right)
      Deprecated.
      Description copied from interface: ITypeRelations
      Function 3: Given two SymTypeExpressions super, sub: This function answers, whether the right type is a subtype of the left type in an assignment. (This allows to store/use values of type "sub" at all positions of type "super". Compatibility examples: compatible("int", "long") (in all directions) compatible("long", "int") (in all directions) compatible("double", "float") (in all directions) compatible("Person", "Student") (uni-directional)

      Incompatible: !compatible("double", "int") (in all directions)

      The concrete Typechecker has to decide on further issues, like !compatible("List<double>", "List<int>") where e.g. Java and OCL/P differ in their answers

      Specified by:
      compatible in interface ITypeRelations
      Parameters:
      left - Super-Type
      right - Sub-Type (assignment-compatible to supertype?)

    • isSubtypeOf

      public boolean isSubtypeOf(SymTypeExpression subType, SymTypeExpression superType)
      Deprecated.
      Description copied from interface: ITypeRelations
      determines if one SymTypeExpression is a subtype of another SymTypeExpression
      Specified by:
      isSubtypeOf in interface ITypeRelations
      Parameters:
      subType - the SymTypeExpression that could be a subtype of the other SymTypeExpression
      superType - the SymTypeExpression that could be a supertype of the other SymTypeExpression
    • calculateInheritanceDistance

      public int calculateInheritanceDistance(SymTypeExpression specific, SymTypeExpression general)
      Deprecated.
      Description copied from interface: ITypeRelations
      calculate the minimum inheritance distance from the specific type to the general type e.g. C extends B extends A: object of type C has distance of 2 to object of type A object of type B has distance of 1 to object of type A object of type A has distance of 0 to object of type A
      Specified by:
      calculateInheritanceDistance in interface ITypeRelations
      Parameters:
      specific - the specific type
      general - the general type
      Returns:
      0 if they are the same type, else their minimum inheritance distance
    • calculateInheritanceDistance

      public int calculateInheritanceDistance(SymTypePrimitive specific, SymTypePrimitive general)
      Deprecated.
      Specified by:
      calculateInheritanceDistance in interface ITypeRelations
    • isBoolean

      public boolean isBoolean(SymTypeExpression type)
      Deprecated.
      Specified by:
      isBoolean in interface ITypeRelations
    • isInt

      public boolean isInt(SymTypeExpression type)
      Deprecated.
      Specified by:
      isInt in interface ITypeRelations
    • isDouble

      public boolean isDouble(SymTypeExpression type)
      Deprecated.
      Specified by:
      isDouble in interface ITypeRelations
    • isFloat

      public boolean isFloat(SymTypeExpression type)
      Deprecated.
      Specified by:
      isFloat in interface ITypeRelations
    • isLong

      public boolean isLong(SymTypeExpression type)
      Deprecated.
      Specified by:
      isLong in interface ITypeRelations
    • isChar

      public boolean isChar(SymTypeExpression type)
      Deprecated.
      Specified by:
      isChar in interface ITypeRelations
    • isShort

      public boolean isShort(SymTypeExpression type)
      Deprecated.
      Specified by:
      isShort in interface ITypeRelations
    • isByte

      public boolean isByte(SymTypeExpression type)
      Deprecated.
      Specified by:
      isByte in interface ITypeRelations
    • isVoid

      public boolean isVoid(SymTypeExpression type)
      Deprecated.
      Specified by:
      isVoid in interface ITypeRelations
    • isString

      public boolean isString(SymTypeExpression type)
      Deprecated.
      Specified by:
      isString in interface ITypeRelations
    • isIntegralType

      public boolean isIntegralType(SymTypeExpression type)
      Deprecated.
      Specified by:
      isIntegralType in interface ITypeRelations
    • isNumericType

      public boolean isNumericType(SymTypeExpression type)
      Deprecated.
      Specified by:
      isNumericType in interface ITypeRelations