Package de.monticore.types.check
Class TypeCalculator
java.lang.Object
de.monticore.types.check.TypeCalculator
- All Implemented Interfaces:
ITypeRelations
- Direct Known Subclasses:
TypeCheck3AsTypeCalculator
Deprecated.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IDeriveDeprecated.Configuration: Visitor for Function 2b: Deriving the SymTypeExpression from an AST Value - Literal.protected ISynthesizeDeprecated.Configuration: Visitor for Function 1: Synthesizing the SymTypeExpression from an AST Type.protected ITypeRelationsDeprecated.Configuration: Implementation for Function 4: Delegatee for ITypeRelations Calculate relations of types. -
Constructor Summary
ConstructorsConstructorDescriptionTypeCalculator(ISynthesize iSynthesize, IDerive iDerive) Deprecated.TypeCalculator(ISynthesize synthesizeSymType, IDerive iDerive, ITypeRelations iTypeRelations) Deprecated.Configuration as state: -
Method Summary
Modifier and TypeMethodDescriptionintcalculateInheritanceDistance(SymTypeExpression specific, SymTypeExpression general) Deprecated.calculate the minimum inheritance distance from the specific type to the general type e.g.intcalculateInheritanceDistance(SymTypePrimitive specific, SymTypePrimitive general) Deprecated.booleancompatible(SymTypeExpression left, SymTypeExpression right) Deprecated.Function 3: Given two SymTypeExpressions super, sub: This function answers, whether the right type is a subtype of the left type in an assignment.booleanisBoolean(SymTypeExpression type) Deprecated.booleanisByte(SymTypeExpression type) Deprecated.booleanisChar(SymTypeExpression type) Deprecated.booleanisDouble(SymTypeExpression type) Deprecated.booleanisFloat(SymTypeExpression type) Deprecated.booleanisInt(SymTypeExpression type) Deprecated.booleanDeprecated.booleanisLong(SymTypeExpression type) Deprecated.booleanDeprecated.booleanisOfTypeForAssign(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.booleanisShort(SymTypeExpression type) Deprecated.booleanisString(SymTypeExpression type) Deprecated.booleanisSubtypeOf(SymTypeExpression subType, SymTypeExpression superType) Deprecated.determines if one SymTypeExpression is a subtype of another SymTypeExpressionbooleanisVoid(SymTypeExpression type) Deprecated.Deprecated.Function 1d: extracting the SymTypeExpression from the AST MCQualifiedName Tests for this Function are combined in the Visitor tests (SynthesizeSymType.*Types.*Test)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(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.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)typeOf(ASTExpression expr) Deprecated.Function 2: Derive the SymTypeExpression from an Expression AST This defines the Type that an Expression has.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.
-
Field Details
-
iSynthesize
Deprecated.Configuration: Visitor for Function 1: Synthesizing the SymTypeExpression from an AST Type. May also be of a subclass; -
iDerive
Deprecated.Configuration: Visitor for Function 2b: Deriving the SymTypeExpression from an AST Value - Literal. May also be of a subclass; -
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 recognitioniTypeRelations- defines, what the relations of types are, this is delegated to, to provide theITypeRelations
-
TypeCalculator
Deprecated.
-
-
Method Details
-
symTypeFromAST
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
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
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
Deprecated.Function 1d: extracting the SymTypeExpression from the AST MCQualifiedName Tests for this Function are combined in the Visitor tests (SynthesizeSymType.*Types.*Test) -
typeOf
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
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
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
Deprecated.Description copied from interface:ITypeRelationsFunction 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:
compatiblein interfaceITypeRelations- Parameters:
left- Super-Typeright- Sub-Type (assignment-compatible to supertype?)
-
isSubtypeOf
Deprecated.Description copied from interface:ITypeRelationsdetermines if one SymTypeExpression is a subtype of another SymTypeExpression- Specified by:
isSubtypeOfin interfaceITypeRelations- Parameters:
subType- the SymTypeExpression that could be a subtype of the other SymTypeExpressionsuperType- the SymTypeExpression that could be a supertype of the other SymTypeExpression
-
calculateInheritanceDistance
Deprecated.Description copied from interface:ITypeRelationscalculate 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:
calculateInheritanceDistancein interfaceITypeRelations- Parameters:
specific- the specific typegeneral- the general type- Returns:
- 0 if they are the same type, else their minimum inheritance distance
-
calculateInheritanceDistance
Deprecated.- Specified by:
calculateInheritanceDistancein interfaceITypeRelations
-
isBoolean
Deprecated.- Specified by:
isBooleanin interfaceITypeRelations
-
isInt
Deprecated.- Specified by:
isIntin interfaceITypeRelations
-
isDouble
Deprecated.- Specified by:
isDoublein interfaceITypeRelations
-
isFloat
Deprecated.- Specified by:
isFloatin interfaceITypeRelations
-
isLong
Deprecated.- Specified by:
isLongin interfaceITypeRelations
-
isChar
Deprecated.- Specified by:
isCharin interfaceITypeRelations
-
isShort
Deprecated.- Specified by:
isShortin interfaceITypeRelations
-
isByte
Deprecated.- Specified by:
isBytein interfaceITypeRelations
-
isVoid
Deprecated.- Specified by:
isVoidin interfaceITypeRelations
-
isString
Deprecated.- Specified by:
isStringin interfaceITypeRelations
-
isIntegralType
Deprecated.- Specified by:
isIntegralTypein interfaceITypeRelations
-
isNumericType
Deprecated.- Specified by:
isNumericTypein interfaceITypeRelations
-
TypeCheck3andSymTypeRelations