Class TypeCache.Entry

  • Enclosing class:
    TypeCache

    public class TypeCache.Entry
    extends java.lang.Object
    Implements a type cache entry. Variables in an entry are relative to #var, which must be substituted finally with the actual top-level variable.
    Author:
    Holger Eichelberger
    • Constructor Detail

      • Entry

        private Entry​(AbstractVariable var)
        Creates a type cache entry.
        Parameters:
        var - the variable the constraint are bound to
    • Method Detail

      • addConstraint

        public void addConstraint​(ConstraintList target,
                                  boolean first,
                                  Constraint constraint,
                                  boolean register)
        Adds a constraint to this type cache entry.
        Parameters:
        target - the target list
        first - whether the constraint shall be added to front or back
        constraint - the constraint
        register - shall the constraint be registered in VariablesMap
      • hasMapping

        public boolean hasMapping()
        Returns whether this cache entry has a variable-accessor mapping. Such mappings are only present if additional constraint translations for this type are needed, e.g., to cope with changing constraint variables.
        Returns:
        true for mapping, false else
      • containsMapping

        public boolean containsMapping​(AbstractVariable var)
        Returns whether the current context contains a mapping for var.
        Parameters:
        var - the variable to look for
        Returns:
        true if there is a mapping, false else
      • getMapping

        public ConstraintSyntaxTree getMapping​(AbstractVariable var,
                                               AbstractVariable self)
        Returns the mapped access expression for var taking into account all current contexts of the stack starting with the current top-most one. If varMap is present, performs an on-the-fly instantiation of the mapped accessor. Intended for dynamically building up the mapping in the context stack.
        Parameters:
        var - the variable to return the mapping for
        self - the variable to instantiate the stored mapping for
        Returns:
        the mapped access expression or null if there is no registered mapping
      • getLocalMapping

        public ConstraintSyntaxTree getLocalMapping​(java.lang.String name,
                                                    AbstractVariable self)
        Returns the local mapping for the given variable name just from the current context. Names are registered once, to the most local (non-shadowed) variable. If varMap is present, performs an on-the-fly instantiation of the mapped accessor. Intended for dynamically building up the mapping in the context stack.
        Parameters:
        name - the name of the variable
        self - the variable to instantiate the stored mapping for
        Returns:
        the mapped access expression or null if there is no registered mapping
      • addParent

        public void addParent​(TypeCache.Entry entry,
                              TypeCache.IConstraintTarget target,
                              IDecisionVariable register,
                              AbstractVariable var)
        Adds a parent to this entry and causes constraint transfer. Shall be applied only to type-compatible types such as refined compounds or derived types.
        Parameters:
        entry - the entry
        target - the constraint target
        register - the variable to register against
        var - the replacing variable
      • transferConstraints

        private boolean transferConstraints​(TypeCache.IConstraintTarget target,
                                            IDecisionVariable register,
                                            AbstractVariable var)
        Transfers constraints.
        Parameters:
        target - the constraint target
        register - the variable to register against
        var - the replacing variable
        Returns:
        whether the transfer was done
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object