/* This file was generated with JastAdd2 (http://jastadd.org) version jenkins-JastAdd2-432 */
package AST;

/**
 * @production Dot : {@link Name} ::= <span class="component">Left:{@link Name}</span> <span class="component">Right:{@link Name}</span>;
 * @ast node
 * @declaredat JavaDemoNames.ast:16
 */
public class Dot extends Name implements Cloneable {
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public Dot clone() throws CloneNotSupportedException {
    Dot node = (Dot) super.clone();
    node.type_visited = -1;
    node.type_computed = false;
    node.type_value = null;
    node.predKind_visited = -1;
    node.predKind_computed = false;
    node.predKind_value = null;
    node.in$Circle(false);
    node.is$Final(false);
    return node;
  }
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public Dot copy() {
    try {
      Dot node = (Dot) clone();
      node.parent = null;
      if(children != null) {
        node.children = (ASTNode[]) children.clone();
      }
      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
   */
  @SuppressWarnings({"unchecked", "cast"})
  public Dot fullCopy() {
    Dot tree = (Dot) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) children[i];
        if(child != null) {
          child = child.fullCopy();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /**
   * 
   * @ast method
   * 
   */

  public Dot() {
    super();
  }
  /**
   * 
     * Initializes the child array to the correct size.
     * Initializes List and Opt nta children.
     * @apilevel internal
     * @ast method
     
   * @ast method
   * 
   */

  public void init$Children() {
    children = new ASTNode[2];
  }
  /**
   * 
   * @ast method
   * 
   */

  public Dot(String p0, Name p1, Name p2) {
    setname(p0);
    setChild(p1, 0);
    setChild(p2, 1);
  }
  /**
   * 
     * @apilevel low-level
     
   * @ast method
   * 
   */

  protected int numChildren() {
    return 2;
  }
  /**
   * 
     * @apilevel internal
     
   * @ast method
   * 
   */

  public boolean mayHaveRewrite() {
    return false;
  }
  /**
   * 
      * @apilevel low-level
      
   * @ast method
   * 
   */

  public void flushCache() {
    super.flushCache();
    type_visited = -1;
    type_computed = false;
    type_value = null;
    predKind_visited = -1;
    predKind_computed = false;
    predKind_value = null;
  }
  /**
   * 
      * @apilevel internal
      
   * @ast method
   * 
   */

  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /**
   * 
     * Replaces the lexeme name.
     * @param value The new value for the lexeme name.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public void setname(String value) {
    tokenString_name = value;
  }
  /**
   * 
     * Retrieves the value for the lexeme name.
     * @return The value for the lexeme name.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public String getname() {
    return tokenString_name != null ? tokenString_name : "";
  }
  /**
   * 
     * Replaces the Left child.
     * @param node The new node to replace the Left child.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public void setLeft(Name node) {
    setChild(node, 0);
  }
  /**
   * 
     * Retrieves the Left child.
     * @return The current node used as the Left child.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public Name getLeft() {
    return (Name) 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
     
   * @ast method
   * 
   */

  public Name getLeftNoTransform() {
    return (Name) getChildNoTransform(0);
  }
  /**
   * 
     * Replaces the Right child.
     * @param node The new node to replace the Right child.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public void setRight(Name node) {
    setChild(node, 1);
  }
  /**
   * 
     * Retrieves the Right child.
     * @return The current node used as the Right child.
     * @apilevel high-level
     
   * @ast method
   * 
   */

  public Name getRight() {
    return (Name) 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
     
   * @ast method
   * 
   */

  public Name getRightNoTransform() {
    return (Name) getChildNoTransform(1);
  }
  /**
   * @apilevel internal
   */
  protected int type_visited = -1;
  /**
   * @apilevel internal
   */
  protected boolean type_computed = false;
  /**
   * @apilevel internal
   */
  protected ClassDecl type_value;
  /**
   * @attribute syn
   * @aspect JavaDemoNames
   * @declaredat JavaDemoNames.jrag:24
   */

  public ClassDecl type() {
    
    
        
    if(type_computed) {
      return type_value;
    }
    ASTNode$State state = state();
    if (type_visited == state().boundariesCrossed) {
      throw new RuntimeException("Circular definition of attr: type in class: ast.AST.SynDecl");
    }
    type_visited = state().boundariesCrossed;
    int num = state.boundariesCrossed;
    boolean isFinal = this.is$Final();
    type_value = type_compute();
      if(isFinal && num == state().boundariesCrossed){ type_computed = true; }
    type_visited = -1;
        return type_value;
  }
  /**
   * @apilevel internal
   */
  private ClassDecl type_compute() {  return getRight().type();  }
  /**
   * @apilevel internal
   */
  protected int predKind_visited = -1;
  /**
   * @apilevel internal
   */
  protected boolean predKind_computed = false;
  /**
   * @apilevel internal
   */
  protected Kind predKind_value;
  /**
   * @attribute syn
   * @aspect JavaDemoNames
   * @declaredat JavaDemoNames.jrag:154
   */

  public Kind predKind() {
    
    
        
    if(predKind_computed) {
      return predKind_value;
    }
    ASTNode$State state = state();
    if (predKind_visited == state().boundariesCrossed) {
      throw new RuntimeException("Circular definition of attr: predKind in class: ast.AST.SynDecl");
    }
    predKind_visited = state().boundariesCrossed;
    int num = state.boundariesCrossed;
    boolean isFinal = this.is$Final();
    predKind_value = predKind_compute();
      if(isFinal && num == state().boundariesCrossed){ predKind_computed = true; }
    predKind_visited = -1;
        return predKind_value;
  }
  /**
   * @apilevel internal
   */
  private Kind predKind_compute() {  return getLeft().predKind();  }
  /**
   * @declaredat JavaDemoNames.jrag:119
   * @apilevel internal
   */
  public Variable Define_Variable_lookupVariable(ASTNode caller, ASTNode child, String name) {
    if(caller == getRightNoTransform()) {
      return getLeft().type().memberField(name);
    }
    else {      return getParent().Define_Variable_lookupVariable(this, caller, name);
    }
  }
  /**
   * @declaredat JavaDemoNames.jrag:122
   * @apilevel internal
   */
  public ClassDecl Define_ClassDecl_lookupType(ASTNode caller, ASTNode child, String name) {
    if(caller == getRightNoTransform()) {
      return getLeft().qualifiedLookupType(name);
    }
    else {      return getParent().Define_ClassDecl_lookupType(this, caller, name);
    }
  }
  /**
   * @declaredat JavaDemoNames.jrag:152
   * @apilevel internal
   */
  public Kind Define_Kind_kind(ASTNode caller, ASTNode child) {
    if(caller == getLeftNoTransform()) {
      return getRight().predKind();
    }
    else {      return getParent().Define_Kind_kind(this, caller);
    }
  }
  /**
   * @declaredat JavaDemoNames.jrag:191
   * @apilevel internal
   */
  public boolean Define_boolean_hasPackage(ASTNode caller, ASTNode child, String name) {
    if(caller == getRightNoTransform()) {
      return getLeft().qualifiedHasPackage(name);
    }
    else {      return getParent().Define_boolean_hasPackage(this, caller, name);
    }
  }
  /**
   * @apilevel internal
   */
  public ASTNode rewriteTo() {    return super.rewriteTo();
  }}
