Class TypeCheck3
- Direct Known Subclasses:
MapBasedTypeCheck3
It is designed as functional class (no state), allowing to plug in the appropriate implementation through subclasses. Those subclasses can deal with variants of Expression, Literal, and Type-classes that are used in the respective project. This class only knows about the three top Level grammars, ExpressionsBasis, MCLiteralsBasis, and MCBasicTypes, because it includes their main non-terminals in the signature.
The provided methods return the SymTypeExpression that corresponds to the provided AST-node. SymTypeExpressions are independent of the AST and can be stored in the symbol table, etc.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static TypeCheck3Static delegate responsible for ALL methods of this class; No further fields ought to be added to this class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract SymTypeExpression_symTypeFromAST(ASTMCQualifiedName mcQualifiedName) protected abstract SymTypeExpression_symTypeFromAST(ASTMCReturnType mcReturnType) protected abstract SymTypeExpression_symTypeFromAST(ASTMCType mcType) protected abstract SymTypeExpression_symTypeFromAST(ASTMCVoidType mcVoidType) protected abstract SymTypeExpression_typeOf(ASTExpression expr) protected SymTypeExpression_typeOf(ASTExpression expr, SymTypeExpression targetType) protected abstract SymTypeExpression_typeOf(ASTLiteral lit) protected static TypeCheck3protected static voidprotected static voidsetDelegate(TypeCheck3 delegate) static SymTypeExpressionsymTypeFromAST(ASTMCQualifiedName mcQualifiedName) Extracts the SymTypeExpression corresponding to the ASTMCQualifiedName.static SymTypeExpressionsymTypeFromAST(ASTMCReturnType mcReturnType) Extracts the SymTypeExpression corresponding to the return type.static SymTypeExpressionsymTypeFromAST(ASTMCType mcType) Extracts the SymTypeExpression corresponding to the ASTMCType.static SymTypeExpressionsymTypeFromAST(ASTMCVoidType mcVoidType) Extracts the SymTypeExpression corresponding to "void".static SymTypeExpressiontypeOf(ASTExpression expr) Derive the type of the expression.static SymTypeExpressiontypeOf(ASTExpression expr, SymTypeExpression targetType) Derives the type of the expression, using the expected target type as additional information.static SymTypeExpressiontypeOf(ASTLiteral lit) Derives the type of the literal.
-
Field Details
-
delegate
Static delegate responsible for ALL methods of this class; No further fields ought to be added to this class.This has to be initialized by an implementing subclass.
-
-
Constructor Details
-
TypeCheck3
public TypeCheck3()
-
-
Method Details
-
symTypeFromAST
Extracts the SymTypeExpression corresponding to the ASTMCType. -
symTypeFromAST
Extracts the SymTypeExpression corresponding to "void". "void" is not part of the ASTMCType-Hierarchy, while it is included in the SymTypeExpressions. -
symTypeFromAST
Extracts the SymTypeExpression corresponding to the return type. ASTMCReturnType is not part of the ASTMCType-Hierarchy, while it is included in the SymTypeExpressions. -
symTypeFromAST
Extracts the SymTypeExpression corresponding to the ASTMCQualifiedName. -
typeOf
Derive the type of the expression. Each typeable expression, in a fixed context, has exactly one type.Whenever possible, instead use
typeOf(ASTExpression, SymTypeExpression). -
typeOf
Derives the type of the expression, using the expected target type as additional information.E.g.:
List<int> myList = [];// [] returns an empty list Here, the type of [] is to be calculated. Without target type, it is known that a List is returned. However, the type argument of List is unknown. Using the target typeList<int>as additional information, allows to additionally derive the type argument int, resulting in derivingList<int>to be the expression []'s type.Note: it is up to the concrete implementation, whether the target type is used.
-
typeOf
Derives the type of the literal. -
_symTypeFromAST
-
_symTypeFromAST
-
_symTypeFromAST
-
_symTypeFromAST
-
_typeOf
-
_typeOf
-
_typeOf
-
setDelegate
-
resetDelegate
protected static void resetDelegate() -
getDelegate
-