Class InferenceContext4Ast
java.lang.Object
de.monticore.types3.generics.context.InferenceContext4Ast
Stores context information for expressions and type identifiers,
which are used (in some instances) to calculate the corresponding SymTypes.
The Type System uses contextual typing,
i.e., the type of an expression can be dependent on the context, e.g.:
List<A> as = new ArrayList<>();
List<B> bs = new ArrayList<>();
The information stored are also used to make free type variable replacement reproducible
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<de.monticore.ast.ASTNode, InferenceContext> the actual map from context to types, we use ASTNode to support non-ASTExpression Nodes, however, we do NOT support non-expression ASTNodes, e.g., in MyClass.myMethod(), the "MyClass" is not an expression by itself.protected Map<de.monticore.ast.ASTNode, SymTypeExpression> Used to make free type variable replacement reproducible; Any SymTypeExpression that has been resolved or acquired in a comparable context is stored here.protected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Map<de.monticore.ast.ASTNode, InferenceContext> getResolvedOfExpression(ASTExpression astExpr) booleanhasResolvedOfExpression(ASTExpression astExpr) protected Stringnode2InfoString(de.monticore.ast.ASTNode node) helps with logging.voidreset()voidresetContexts(de.monticore.ast.ASTNode rootNode) This removes the stored values of every node below and including the provided root.voidsetContextOfExpression(ASTExpression astExpr, InferenceContext context) sets the type information of the expression, information may be partialvoidsetResolvedOfExpression(ASTExpression astExpr, SymTypeExpression resolved) voidsetTargetTypeOfExpression(ASTExpression astExpr, SymTypeExpression targetType) QOL method: sets the target type for a given expression
-
Field Details
-
LOG_NAME
- See Also:
-
expr2ctx
the actual map from context to types, we use ASTNode to support non-ASTExpression Nodes, however, we do NOT support non-expression ASTNodes, e.g., in MyClass.myMethod(), the "MyClass" is not an expression by itself. -
expr2resolved
Used to make free type variable replacement reproducible; Any SymTypeExpression that has been resolved or acquired in a comparable context is stored here. Do not rely on this information for any other case!
-
-
Constructor Details
-
InferenceContext4Ast
public InferenceContext4Ast()
-
-
Method Details
-
getExpression2Context
-
reset
public void reset() -
resetContexts
public void resetContexts(de.monticore.ast.ASTNode rootNode) This removes the stored values of every node below and including the provided root. This can be required to, e.g., rerun the type checker multiple times during type inference.Does NOT reset the information required to make free type variable replacement reproducible!
-
getContextOfExpression
-
setContextOfExpression
sets the type information of the expression, information may be partial -
setTargetTypeOfExpression
QOL method: sets the target type for a given expression -
setResolvedOfExpression
-
hasResolvedOfExpression
-
getResolvedOfExpression
-
node2InfoString
helps with logging.
-