Class InferenceContext4Ast
- java.lang.Object
-
- de.monticore.types3.generics.context.InferenceContext4Ast
-
public class InferenceContext4Ast extends java.lang.ObjectStores 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
Fields Modifier and Type Field Description protected java.util.Map<de.monticore.ast.ASTNode,InferenceContext>expr2ctxthe 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 java.util.Map<de.monticore.ast.ASTNode,SymTypeExpression>expr2resolvedUsed to make free type variable replacement reproducible; Any SymTypeExpression that has been resolved or acquired in a comparable context is stored here.protected static java.lang.StringLOG_NAME
-
Constructor Summary
Constructors Constructor Description InferenceContext4Ast()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InferenceContextgetContextOfExpression(ASTExpression node)protected java.util.Map<de.monticore.ast.ASTNode,InferenceContext>getExpression2Context()SymTypeExpressiongetResolvedOfExpression(ASTExpression astExpr)booleanhasResolvedOfExpression(ASTExpression astExpr)protected java.lang.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 Detail
-
LOG_NAME
protected static final java.lang.String LOG_NAME
- See Also:
- Constant Field Values
-
expr2ctx
protected java.util.Map<de.monticore.ast.ASTNode,InferenceContext> 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
protected java.util.Map<de.monticore.ast.ASTNode,SymTypeExpression> 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!
-
-
Method Detail
-
getExpression2Context
protected java.util.Map<de.monticore.ast.ASTNode,InferenceContext> 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
public InferenceContext getContextOfExpression(ASTExpression node)
-
setContextOfExpression
public void setContextOfExpression(ASTExpression astExpr, InferenceContext context)
sets the type information of the expression, information may be partial
-
setTargetTypeOfExpression
public void setTargetTypeOfExpression(ASTExpression astExpr, SymTypeExpression targetType)
QOL method: sets the target type for a given expression
-
setResolvedOfExpression
public void setResolvedOfExpression(ASTExpression astExpr, SymTypeExpression resolved)
-
hasResolvedOfExpression
public boolean hasResolvedOfExpression(ASTExpression astExpr)
-
getResolvedOfExpression
public SymTypeExpression getResolvedOfExpression(ASTExpression astExpr)
-
node2InfoString
protected java.lang.String node2InfoString(de.monticore.ast.ASTNode node)
helps with logging.
-
-