Class Type4Ast

    • Field Detail

      • expr2type

        protected java.util.Map<de.monticore.ast.ASTNode,​SymTypeExpression> expr2type
        the actual map from expression to types, strictly seperated from the map for type identifiers we use ASTNode to support non-ASTExpression Nodes (e.g., literals) however, we do NOT support non-expression ASTNodes, e.g. in MyClass.myMethod(): the "MyClass" is not an expression by itself
      • typeID2type

        protected java.util.Map<de.monticore.ast.ASTNode,​SymTypeExpression> typeID2type
        the actual map from type identifier to types, strictly seperated from the map for expressions we use ASTNode to support non-ASTMCType Nodes (e.g. qualified Names) however, we do NOT support expression ASTNodes, e.g. other qualified names that represent a variable, rather than a type
    • Constructor Detail

      • Type4Ast

        public Type4Ast()
    • Method Detail

      • getExpression2Type

        protected java.util.Map<de.monticore.ast.ASTNode,​SymTypeExpression> getExpression2Type()
      • getTypeIdentifier2Type

        protected java.util.Map<de.monticore.ast.ASTNode,​SymTypeExpression> getTypeIdentifier2Type()
      • reset

        public void reset()
      • reset

        public void reset​(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.
      • hasTypeOfExpression

        public boolean hasTypeOfExpression​(ASTExpression astExpr)
        whether a type has been calculated for the expression
      • hasTypeOfExpression

        public boolean hasTypeOfExpression​(ASTLiteral astLit)
        whether a type has been calculated for the literal
      • internal_hasTypeOfExpression

        protected boolean internal_hasTypeOfExpression​(de.monticore.ast.ASTNode node)
      • hasPartialTypeOfExpression

        public boolean hasPartialTypeOfExpression​(ASTExpression astExpr)
      • hasPartialTypeOfExpression

        public boolean hasPartialTypeOfExpression​(ASTLiteral astLit)
      • internal_hasPartialTypeOfExpression

        protected boolean internal_hasPartialTypeOfExpression​(de.monticore.ast.ASTNode node)
      • hasTypeOfTypeIdentifier

        public boolean hasTypeOfTypeIdentifier​(ASTMCType mcType)
      • hasTypeOfTypeIdentifier

        public boolean hasTypeOfTypeIdentifier​(ASTMCReturnType mcReturnType)
      • hasTypeOfTypeIdentifier

        public boolean hasTypeOfTypeIdentifier​(ASTMCQualifiedName mcQName)
      • hasTypeOfTypeIdentifier

        public boolean hasTypeOfTypeIdentifier​(ASTMCTypeArgument mcTypeArg)
      • hasTypeOfTypeIdentifierForName

        public boolean hasTypeOfTypeIdentifierForName​(ASTExpression nameExpr)
      • internal_hasTypeOfTypeIdentifier

        protected boolean internal_hasTypeOfTypeIdentifier​(de.monticore.ast.ASTNode node)
        whether a type has been calculated for the type identifier
      • hasPartialTypeOfTypeIdentifier

        public boolean hasPartialTypeOfTypeIdentifier​(ASTMCType mcType)
      • hasPartialTypeOfTypeIdentifier

        public boolean hasPartialTypeOfTypeIdentifier​(ASTMCReturnType mcReturnType)
      • hasPartialTypeOfTypeIdentifier

        public boolean hasPartialTypeOfTypeIdentifier​(ASTMCQualifiedName mcQName)
      • hasPartialTypeOfTypeIdentifier

        public boolean hasPartialTypeOfTypeIdentifier​(ASTMCTypeArgument mcTypeArg)
      • hasPartialTypeOfTypeIdentifierForName

        public boolean hasPartialTypeOfTypeIdentifierForName​(ASTExpression nameExpr)
      • internal_hasPartialTypeOfTypeIdentifier

        protected boolean internal_hasPartialTypeOfTypeIdentifier​(de.monticore.ast.ASTNode node)
        whether a type has been calculated for the type identifier
      • internal_getTypeOfExpression

        protected SymTypeExpression internal_getTypeOfExpression​(de.monticore.ast.ASTNode node)
      • internal_getPartialTypeOfExpr

        protected SymTypeExpression internal_getPartialTypeOfExpr​(de.monticore.ast.ASTNode node)
        returns potentially partial type information of the expression internally used by type deriver
      • internal_getTypeOfTypeIdentifier

        protected SymTypeExpression internal_getTypeOfTypeIdentifier​(de.monticore.ast.ASTNode node)
        gets the type of the type identifier if it has been calculated
      • internal_getPartialTypeOfTypeId2

        @Deprecated
        public SymTypeExpression internal_getPartialTypeOfTypeId2​(de.monticore.ast.ASTNode node)
        Deprecated.
        do not use, only here until fix in grammar
      • internal_getPartialTypeOfTypeId

        protected SymTypeExpression internal_getPartialTypeOfTypeId​(de.monticore.ast.ASTNode node)
        returns potentially partial type information of the type identifier used by type deriver
      • setTypeOfExpression

        public void setTypeOfExpression​(ASTExpression astExpr,
                                        SymTypeExpression typeExpr)
        sets the type information of the expression, information may be partial
      • setTypeOfExpression

        public void setTypeOfExpression​(ASTLiteral astLit,
                                        SymTypeExpression typeExpr)
        sets the type information of the literal, information may be partial
      • internal_setTypeOfExpression

        protected void internal_setTypeOfExpression​(de.monticore.ast.ASTNode node,
                                                    SymTypeExpression typeExpr)
      • setTypeOfTypeIdentifierForName

        public void setTypeOfTypeIdentifierForName​(ASTNameExpression name,
                                                   SymTypeExpression type)
        a special case of the MCQualifiedName

        this is only used in cases there the type identifier 1. was parsed as an expression (instead of a MCQualifiedName) and 2. the AST can not be transformed to accommodate without non-conservative grammar changes

        In our Java-esque languages, this usually happens before ".", e.g., C in C.staticVar, C.staticMethod() C.this.var, C.super.method(), ... As the type id has been parsed as an expression, and nothing further is known without reflection, getting the type information cannot be type safe ("type safe" as in (partially) ensuring correct usage by the type checker), thus the uniqueness of the methods' names. note that (technically) not even ASTExpression applicable enough, due to some grammar extension points The getter is getPartialTypeOfTypeIdForName(ASTExpression)

      • internal_setTypeOfTypeIdentifier2

        @Deprecated
        public void internal_setTypeOfTypeIdentifier2​(de.monticore.ast.ASTNode node,
                                                      SymTypeExpression type)
        Deprecated.
        do not use, remove after fix of grammars
      • internal_setTypeOfTypeIdentifier

        protected void internal_setTypeOfTypeIdentifier​(de.monticore.ast.ASTNode node,
                                                        SymTypeExpression typeExpr)
        sets the type information of the type identifier, information may be partial
      • assertNoInferenceVars

        protected void assertNoInferenceVars​(de.monticore.ast.ASTNode node,
                                             SymTypeExpression type)
        If there are any inference variables to be (indirectly) stored in Type4Ast, either an internal programming error occurred, or no Type inference traverser has run and replaced it with an instantiation.
      • isQNameExpr

        protected boolean isQNameExpr​(ASTExpression expr)
        whether the expression represents a qualified name
      • node2InfoString

        protected java.lang.String node2InfoString​(de.monticore.ast.ASTNode node)
        helps with logging.