Skip to content
Snippets Groups Projects
Select Git revision
  • 5c2658813e0b83eddb3a79d3a6db27fea8c83020
  • main default protected
2 results

Equal.java

Blame
  • Equal.java 11.06 KiB
    /* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.5 */
    package org.jastadd.ag.ast;
    import java.util.*;
    /**
     * @ast node
     * @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\ag.ast:9
     * @astdecl Equal : BinaryRelation ::= Left:Term Right:Term;
     * @production Equal : {@link BinaryRelation};
    
     */
    public class Equal extends BinaryRelation implements Cloneable {
      /**
       * @aspect ReferenceCreation
       * @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:99
       */
      public static Equal createRef(String ref) {
        Unresolved$Equal unresolvedNode = new Unresolved$Equal();
        unresolvedNode.setUnresolved$Token(ref);
        unresolvedNode.setUnresolved$ResolveOpposite(true);
        return unresolvedNode;
      }
      /**
       * @aspect ReferenceCreation
       * @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:105
       */
      public static Equal createRefDirection(String ref) {
        Unresolved$Equal unresolvedNode = new Unresolved$Equal();
        unresolvedNode.setUnresolved$Token(ref);
        unresolvedNode.setUnresolved$ResolveOpposite(false);
        return unresolvedNode;
      }
      /**
       * @aspect ResolverTrigger
       * @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:332
       */
      public void resolveAll() {
        super.resolveAll();
      }
      /**
       * @aspect RefResolverHelpers
       * @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:643
       */
      Unresolved$Node$Interface as$Unresolved() {
        return null;
      }
      /**
       * @aspect RefResolverHelpers
       * @declaredat E:\\project\\20211201\\src\\gen\\jastadd\\agRefResolver.jadd:649
       */
      boolean is$Unresolved() {
        return false;
      }
      /**
       * @declaredat ASTNode:1
       */
      public Equal() {
        super();
      }
      /**
       * Initializes the child array to the correct size.
       * Initializes List and Opt nta children.
       * @apilevel internal
       * @ast method
       * @declaredat ASTNode:10
       */
      public void init$Children() {
        children = new ASTNode[2];  getChild_handler = new ASTNode$DepGraphNode[children.length];
        state().enterConstruction();
        state().exitConstruction();
      }
      /**
       * @declaredat ASTNode:15
       */
      @ASTNodeAnnotation.Constructor(
        name = {"Left", "Right"},
        type = {"Term", "Term"},
        kind = {"Child", "Child"}
      )
      public Equal(Term p0, Term p1) {
    state().enterConstruction();
        setChild(p0, 0);
        setChild(p1, 1);
    state().exitConstruction();
      }
      /** @apilevel low-level 
       * @declaredat ASTNode:27
       */
      protected int numChildren() {
        
        state().addHandlerDepTo(numChildren_handler);
        return 2;
      }
      /**
       * @apilevel internal
       * @declaredat ASTNode:35
       */
      public boolean mayHaveRewrite() {
        return false;
      }
      /** @apilevel internal 
       * @declaredat ASTNode:39
       */
      public void flushAttrCache() {
      }
      /** @apilevel internal 
       * @declaredat ASTNode:42
       */
      public void flushCollectionCache() {
      }
      /** @apilevel internal 
       * @declaredat ASTNode:45
       */
      public Equal clone() throws CloneNotSupportedException {
        Equal node = (Equal) super.clone();
        return node;
      }
      /** @apilevel internal 
       * @declaredat ASTNode:50
       */
      public Equal copy() {
        try {
          Equal node = (Equal) clone();
          node.parent = null;
          if (children != null) {
            node.children = (ASTNode[]) children.clone();
          }
          node.inc_state = inc_CLONED;
          for (int i = 0; node.children != null && i < node.children.length; i++) {
            node.children[i] = null;
          }
          inc_copyHandlers(node);
          return node;
        } catch (CloneNotSupportedException e) {
          throw new Error("Error: clone not supported for " + getClass().getName());
        }
      }
      /**
       * Create a deep copy of the AST subtree at this node.
       * The copy is dangling, i.e. has no parent.
       * @return dangling copy of the subtree at this node
       * @apilevel low-level
       * @deprecated Please use treeCopy or treeCopyNoTransform instead
       * @declaredat ASTNode:74
       */
      @Deprecated
      public Equal fullCopy() {
        return treeCopyNoTransform();
      }
      /**
       * Create a deep copy of the AST subtree at this node.
       * The copy is dangling, i.e. has no parent.
       * @return dangling copy of the subtree at this node
       * @apilevel low-level
       * @declaredat ASTNode:84
       */
      public Equal treeCopyNoTransform() {
        Equal tree = (Equal) copy();
        if (children != null) {
          for (int i = 0; i < children.length; ++i) {
            ASTNode child = (ASTNode) children[i];
            if (child != null) {
              child = child.treeCopyNoTransform();
              tree.children[i] = child;
              child.parent = tree;
            }
          }
        }
        return tree;
      }
      /**
       * Create a deep copy of the AST subtree at this node.
       * The subtree of this node is traversed to trigger rewrites before copy.
       * The copy is dangling, i.e. has no parent.
       * @return dangling copy of the subtree at this node
       * @apilevel low-level
       * @declaredat ASTNode:105
       */
      public Equal treeCopy() {
        Equal tree = (Equal) copy();
        if (children != null) {
          for (int i = 0; i < children.length; ++i) {
            ASTNode child = (ASTNode) getChild(i);
            if (child != null) {
              child = child.treeCopy();
              tree.children[i] = child;
              child.parent = tree;
            }
          }
        }
        return tree;
      }
      /** @apilevel internal 
       * @declaredat ASTNode:120
       */
      protected boolean childIsNTA(int index) {
        return super.childIsNTA(index);
      }
      /**
       * @declaredat ASTNode:123
       */
      protected ASTNode$DepGraphNode eval_handler;
      /**
       * @declaredat ASTNode:124
       */
      protected void inc_copyHandlers(Equal copy) {
        super.inc_copyHandlers(copy);
    
            if (eval_handler != null) {
              copy.eval_handler = ASTNode$DepGraphNode.createAttrHandler(eval_handler, copy);
            }
      }
      /** @apilevel internal 
       * @declaredat ASTNode:133
       */
      public void reactToDependencyChange(String attrID, Object _parameters) {
        super.reactToDependencyChange(attrID, _parameters);
      }
      /**
       * @declaredat ASTNode:140
       */
      private boolean inc_throwAway_visited = false;
      /** @apilevel internal 
       * @declaredat ASTNode:142
       */
      public void inc_throwAway() {
      if (inc_throwAway_visited) {
        return;
      }
      inc_throwAway_visited = true;
      inc_state = inc_GARBAGE;
      super.inc_throwAway();
      if (eval_handler != null) {
        eval_handler.throwAway();
      }
      inc_throwAway_visited = false;
    }
      /**
       * @declaredat ASTNode:154
       */
      private boolean inc_cleanupListeners_visited = false;
      /**
       * @declaredat ASTNode:155
       */
      public void cleanupListeners() {
      if (inc_cleanupListeners_visited) {
        return;
      }
      inc_cleanupListeners_visited = true;
      if (eval_handler != null) {
        eval_handler.cleanupListeners();
      }
      super.cleanupListeners();
      inc_cleanupListeners_visited = false;
    }
      /**
       * @declaredat ASTNode:166
       */
      private boolean inc_cleanupListenersInTree_visited = false;
      /**
       * @declaredat ASTNode:167
       */
      public void cleanupListenersInTree() {
      if (inc_cleanupListenersInTree_visited) {
        return;
      }
      inc_cleanupListenersInTree_visited = true;
      cleanupListeners();
      for (int i = 0; children != null && i < children.length; i++) {
        ASTNode child = children[i];
        if (child == null) {
          continue;
        }
        child.cleanupListenersInTree();
      }
      inc_cleanupListenersInTree_visited = false;
    }
      /**
       * Replaces the Left child.
       * @param node The new node to replace the Left child.
       * @apilevel high-level
       */
      public Equal setLeft(Term node) {
        setChild(node, 0);
        return this;
      }
      /**
       * Retrieves the Left child.
       * @return The current node used as the Left child.
       * @apilevel high-level
       */
      @ASTNodeAnnotation.Child(name="Left")
      public Term getLeft() {
        return (Term) getChild(0);
      }
      /**
       * Retrieves the Left child.
       * <p><em>This method does not invoke AST transformations.</em></p>
       * @return The current node used as the Left child.
       * @apilevel low-level
       */
      public Term getLeftNoTransform() {
        return (Term) getChildNoTransform(0);
      }
      /**
       * Replaces the Right child.
       * @param node The new node to replace the Right child.
       * @apilevel high-level
       */
      public Equal setRight(Term node) {
        setChild(node, 1);
        return this;
      }
      /**
       * Retrieves the Right child.
       * @return The current node used as the Right child.
       * @apilevel high-level
       */
      @ASTNodeAnnotation.Child(name="Right")
      public Term getRight() {
        return (Term) getChild(1);
      }
      /**
       * Retrieves the Right child.
       * <p><em>This method does not invoke AST transformations.</em></p>
       * @return The current node used as the Right child.
       * @apilevel low-level
       */
      public Term getRightNoTransform() {
        return (Term) getChildNoTransform(1);
      }
      /** @apilevel internal */
      private void eval_reset() {
        state().trace().flushAttr(this, "Relation.eval()", "", eval_value);
        eval_computed = null;
      }
      /** @apilevel internal */
      protected ASTState.Cycle eval_computed = null;
    
      /** @apilevel internal */
      protected boolean eval_value;
    
      /**
       * @attribute syn
       * @aspect Connectives
       * @declaredat E:\\project\\20211201\\src\\main\\jastadd\\hanoi\\Constraints.jrag:33
       */
      @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN)
      @ASTNodeAnnotation.Source(aspect="Connectives", declaredAt="E:\\project\\20211201\\src\\main\\jastadd\\hanoi\\Constraints.jrag:17")
      public boolean eval() {
        ASTState state = state();
        
        if (eval_handler == null) {
          eval_handler = new ASTNode$DepGraphNode(this, "eval", null, ASTNode.inc_EMPTY) {
            @Override public void reactToDependencyChange() {
              {
                eval_computed = null;
                eval_handler.notifyDependencies();
                Equal.this.state().trace().flushIncAttr(Equal.this, "eval", "", "");
              }
            }
          };
        }
        state().addHandlerDepTo(eval_handler);
        
        
        
        
        
        if (eval_computed == ASTState.NON_CYCLE || eval_computed == state().cycle()) {
          state().trace().cacheRead(this, "Relation.eval()", "", eval_value);
          return eval_value;
        }
        
        state().enterAttrStoreEval(eval_handler);
        eval_value = eval_compute();
        if (state().inCircle()) {
          eval_computed = state().cycle();
          state().trace().cacheWrite(this, "Relation.eval()", "", eval_value);
        } else {
          eval_computed = ASTState.NON_CYCLE;
          state().trace().cacheWrite(this, "Relation.eval()", "", eval_value);
        }
        
        state().exitAttrStoreEval(eval_handler);
        
        
        
        
        
        
        return eval_value;
      }
      /** @apilevel internal */
      private boolean eval_compute() {
              return this.getLeft().eval() == this.getRight().eval();
          }
      /** @apilevel internal */
      public ASTNode rewriteTo() {
        return super.rewriteTo();
      }
      /** @apilevel internal */
      public boolean canRewrite() {
        return false;
      }
    
    }