Class BasicCopyVisitor

  • All Implemented Interfaces:
    IConstraintTreeVisitor
    Direct Known Subclasses:
    CopyVisitor, SubstitutionVisitor

    public class BasicCopyVisitor
    extends java.lang.Object
    implements IConstraintTreeVisitor
    Implements a basic constraint copy visitor. Allows leaving variable nodes as they are as well as mapping variables (although no mapping happens in this class).
    Author:
    Holger Eichelberger
    • Field Detail

      • copyVariables

        private boolean copyVariables
      • doInferDatatype

        private boolean doInferDatatype
      • copyConstants

        private boolean copyConstants
      • copyExpressions

        private boolean copyExpressions
    • Constructor Detail

      • BasicCopyVisitor

        protected BasicCopyVisitor()
        Creates a copy visitor leaving variable nodes as they are, copying constants, not inferring types on intermediary expressions.
    • Method Detail

      • setCopyVariables

        protected void setCopyVariables​(boolean copyVariables)
        Defines whether variables shall always be copied or whether instances shall be reused if possible.
        Parameters:
        copyVariables - copy variable node instances if true, reuse them if false
      • getCopyVariables

        protected boolean getCopyVariables()
        Returns variables shall always be copied or whether instances shall be reused if possible.
        Returns:
        copy variable node instances if true, reuse them if false
      • setDoInferDatatype

        protected void setDoInferDatatype​(boolean doInferDatatype)
        Defines whether ConstraintSytaxTree#inferDatatype shall be called on each partial expression.
        Parameters:
        doInferDatatype - call/validate the datatypes, false else (then caller is required to infer the datatype before usage of the resulting constraint)
      • setCopyConstants

        protected void setCopyConstants​(boolean copyConstants)
        Defines whether ConstraintSytaxTree#inferDatatype shall be called on each partial expression.
        Parameters:
        copyConstants - copy all constant nodes (true), reuse constant nodes (false))
      • setCopyExpressions

        protected void setCopyExpressions​(boolean copyExpressions)
        Defines whether (partial) expressions shall always be copied or only if needed.
        Parameters:
        copyExpressions - true for copy always, false else
      • getCopyExpressions

        protected boolean getCopyExpressions()
        Returns whether (partial) expressions shall always be copied or only if needed.
        Returns:
        true for copy always, false else
      • setResult

        protected void setResult​(ConstraintSyntaxTree cst)
        Allows inherited classed to overwrite visiting method and to return a partially translated cst.
        Parameters:
        cst - A partially copied cst.
      • getResult

        public ConstraintSyntaxTree getResult()
        Returns the copied syntax tree.
        Returns:
        the copied tree (may be null if no tree was visited).
      • clear

        public void clear()
        Clears this visitor for reuse.
      • mapVariable

        protected AbstractVariable mapVariable​(AbstractVariable var)
        Maps a variable.
        Parameters:
        var - the variable to be mapped
        Returns:
        the mapped variable or var