Class SymTypeSourceInfo

java.lang.Object
de.monticore.types.check.SymTypeSourceInfo

public class SymTypeSourceInfo extends Object
Stores information where a SymTypeExpression comes from. This additional information can be used in CoCos/code-generation, etc.

There will be no info available if using TypeCheck1.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected WeakReference<de.monticore.ast.ASTNode>
    Usage of a WeakReference over an Optional is mostly symbolic; NEVER rely on this information, but if it is available, it may be of use.
    protected Optional<de.monticore.symboltable.ISymbol>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    deep clone
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    _internal_setSourceNode(de.monticore.ast.ASTNode source)
    first and foremost called in Type4Ast
    Optional<de.monticore.ast.ASTNode>
    Source ASTNode of the SymTypeExpression, e.g., if the SymTypeExpression has been calculated as the type of a specific ASTNode, this ASTNode may(!) be returned (no other ASTNode is returned).
    Optional<de.monticore.symboltable.ISymbol>
    Source symbol of the SymTypeExpression, e.g., if a variable "int x" is resolved, the type symbol will be int, but the source symbol will be the variable symbol x.
    void
    setSourceSymbol(de.monticore.symboltable.ISymbol source)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sourceSymbol

      protected Optional<de.monticore.symboltable.ISymbol> sourceSymbol
    • sourceNode

      protected WeakReference<de.monticore.ast.ASTNode> sourceNode
      Usage of a WeakReference over an Optional is mostly symbolic; NEVER rely on this information, but if it is available, it may be of use.
  • Constructor Details

    • SymTypeSourceInfo

      public SymTypeSourceInfo()
    • SymTypeSourceInfo

      public SymTypeSourceInfo(SymTypeSourceInfo other)
      deep clone
  • Method Details

    • getSourceSymbol

      public Optional<de.monticore.symboltable.ISymbol> getSourceSymbol()
      Source symbol of the SymTypeExpression, e.g., if a variable "int x" is resolved, the type symbol will be int, but the source symbol will be the variable symbol x.

      This information can be used for CoCos, code generators, etc.

      WARNING: modifying the SymTypeExpression (e.g., normalization) can remove this information. This is deliberate.

      This replaces getDefiningSymbol() of TypeCheck1.

    • setSourceSymbol

      public void setSourceSymbol(de.monticore.symboltable.ISymbol source)
    • getSourceNode

      public Optional<de.monticore.ast.ASTNode> getSourceNode()
      Source ASTNode of the SymTypeExpression, e.g., if the SymTypeExpression has been calculated as the type of a specific ASTNode, this ASTNode may(!) be returned (no other ASTNode is returned).

      This is ONLY meant to be used to create better log messages! As (especially during type inference) SymTypeExpressions are moved around, cloned, and modified A LOT, therefore, it cannot be assumed that this holds reliable information. The information should still be useful in most cases, though.

    • _internal_setSourceNode

      public void _internal_setSourceNode(de.monticore.ast.ASTNode source)
      first and foremost called in Type4Ast