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

/**
 * @production TypeName : {@link Name};
 * @ast node
 * @declaredat JavaDemoNames.ast:19
 */
public class TypeName extends Name implements Cloneable {
  /**
   * @apilevel internal
   */
  @SuppressWarnings({"unchecked", "cast"})
  public TypeName clone() throws CloneNotSupportedException {
    TypeName node = (TypeName) 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 TypeName copy() {
    try {
      TypeName node = (TypeName) 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 TypeName fullCopy() {
    TypeName tree = (TypeName) 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 TypeName() {
    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() {
  }
  /**
   * 
   * @ast method
   * 
   */

  public TypeName(String p0) {
    setname(p0);
  }
  /**
   * 
     * @apilevel low-level
     
   * @ast method
   * 
   */

  protected int numChildren() {
    return 0;
  }
  /**
   * 
     * @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 : "";
  }
  /**
   * @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:27
   */

  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 lookupType(getname()) != null ?
        lookupType(getname()) : unknownType();  }
  /**
   * @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:157
   */

  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 Kind.PACKAGE_OR_TYPE_NAME;  }
  /**
   * @apilevel internal
   */
  public ASTNode rewriteTo() {    return super.rewriteTo();
  }}
