001    // -*- mode: java -*-
002    /* Copyright 2000, 2001, Compaq Computer Corporation */
003    
004    /* IF THIS IS A JAVA FILE, DO NOT EDIT IT!  
005    
006       Most Java files in this directory which are part of the Javafe AST
007       are automatically generated using the astgen comment (see
008       ESCTools/Javafe/astgen) from the input file 'hierarchy.h'.  If you
009       wish to modify AST classes or introduce new ones, modify
010       'hierarchy.j.'
011     */
012    
013    package javafe.ast;
014    
015    import javafe.util.Assert;
016    import javafe.util.Location;
017    import javafe.util.ErrorSet;
018    
019    // Convention: unless otherwise noted, integer fields named "loc" refer
020    // to the location of the first character of the syntactic unit
021    
022    
023    /**
024     * Represents a FormalParameter. 
025     */
026    
027    public class FormalParaDecl extends GenericVarDecl
028    {
029      //@ invariant !isInternal();
030    
031    
032    // Generated boilerplate constructors:
033    
034       //@ ensures this.modifiers == modifiers;
035       //@ ensures this.pmodifiers == pmodifiers;
036       //@ ensures this.id == id;
037       //@ ensures this.type == type;
038       //@ ensures this.locId == locId;
039       protected FormalParaDecl(int modifiers, ModifierPragmaVec pmodifiers, /*@ non_null @*/ Identifier id, /*@ non_null @*/ Type type, int locId) {
040          super(modifiers, pmodifiers, id, type, locId);
041       }
042    
043    // Generated boilerplate methods:
044    
045       public final int childCount() {
046          int sz = 0;
047          if (this.pmodifiers != null) sz += this.pmodifiers.size();
048          return sz + 2;
049       }
050    
051       public final Object childAt(int index) {
052               /*throws IndexOutOfBoundsException*/
053          if (index < 0)
054             throw new IndexOutOfBoundsException("AST child index " + index);
055          int indexPre = index;
056    
057          int sz;
058    
059          sz = (this.pmodifiers == null ? 0 : this.pmodifiers.size());
060          if (0 <= index && index < sz)
061             return this.pmodifiers.elementAt(index);
062          else index -= sz;
063    
064          if (index == 0) return this.id;
065          else index--;
066    
067          if (index == 0) return this.type;
068          else index--;
069    
070          throw new IndexOutOfBoundsException("AST child index " + indexPre);
071       }   //@ nowarn Exception;
072    
073       public final /*@non_null*/String toString() {
074          return "[FormalParaDecl"
075             + " modifiers = " + this.modifiers
076             + " pmodifiers = " + this.pmodifiers
077             + " id = " + this.id
078             + " type = " + this.type
079             + " locId = " + this.locId
080             + "]";
081       }
082    
083       public final int getTag() {
084          return TagConstants.FORMALPARADECL;
085       }
086    
087       public final void accept(Visitor v) { v.visitFormalParaDecl(this); }
088    
089       public final Object accept(VisitorArgResult v, Object o) {return v.visitFormalParaDecl(this, o); }
090    
091       public void check() {
092          super.check();
093          if (this.pmodifiers != null)
094             for(int i = 0; i < this.pmodifiers.size(); i++)
095                this.pmodifiers.elementAt(i).check();
096          if (this.id == null) throw new RuntimeException();
097          this.type.check();
098       }
099    
100       //@ ensures \result != null;
101       public static FormalParaDecl make(int modifiers, ModifierPragmaVec pmodifiers, /*@ non_null @*/ Identifier id, /*@ non_null @*/ Type type, int locId) {
102          FormalParaDecl result = new FormalParaDecl(modifiers, pmodifiers, id, type, locId);
103          return result;
104       }
105    }