    001    /* Copyright 2000, 2001, Compaq Computer Corporation */
    002
    003    /* IF THIS IS A JAVA FILE, DO NOT EDIT IT!
    004
    005       Most Java files in this directory which are part of the Javafe AST
    006       are automatically generated using the astgen comment (see
    007       ESCTools/Javafe/astgen) from the input file 'hierarchy.h'.  If you
    008       wish to modify AST classes or introduce new ones, modify
    009       'hierarchy.j.'
    010     */
    011
    012    package javafe.ast;
    013
    014    import javafe.util.Assert;
    015    import javafe.util.Location;
    016    import javafe.util.ErrorSet;
    017
    018    // Convention: unless otherwise noted, integer fields named "loc" refer
    019    // to the location of the first character of the syntactic unit
    020
    021
    022    public class TypeName extends Type
    023    {
    024      // We always have associated locations:
    025      //@ invariant syntax;
    026
    027      public /*@ non_null @*/ Name name;
    028
    029      public int getStartLoc() { return name.getStartLoc(); }
    030      public int getEndLoc() { return name.getEndLoc(); }
    031
    032      // overloaded constructor for type names that
    033      // do not have any type modifiers
    034      //@ ensures \result != null;
    035      static public TypeName make(/*@ non_null @*/ Name name) {
    036        return TypeName.make(null, name);
    037      }
    038
    039
    040
    041    // Generated boilerplate constructors:
    042
    043      /**
    044       * Construct a raw TypeName whose class invariant(s) have not
    045       * yet been established.  It is the caller's job to
    046       * initialize the returned node's fields so that any
    047       * class invariants hold.
    048       */
    049      //@ requires I_will_establish_invariants_afterwards;
    050      protected TypeName() {}    //@ nowarn Invariant,NonNullInit;
    051
    052
    053    // Generated boilerplate methods:
    054
    055      public final int childCount() {
    056         int sz = 0;
    057         if (this.tmodifiers != null) sz += this.tmodifiers.size();
    058         return sz + 1;
    059      }
    060
    061      public final Object childAt(int index) {
    062              /*throws IndexOutOfBoundsException*/
    063         if (index < 0)
    064            throw new IndexOutOfBoundsException("AST child index " + index);
    065         int indexPre = index;
    066
    067         int sz;
    068
    069         sz = (this.tmodifiers == null ? 0 : this.tmodifiers.size());
    070         if (0 <= index && index < sz)
    071            return this.tmodifiers.elementAt(index);
    072         else index -= sz;
    073
    074         if (index == 0) return this.name;
    075         else index--;
    076
    077         throw new IndexOutOfBoundsException("AST child index " + indexPre);
    078      }   //@ nowarn Exception;
    079
    080      public final String toString() {
    081         return "[TypeName"
    082            + " tmodifiers = " + this.tmodifiers
    083            + " name = " + this.name
    084            + "]";
    085      }
    086
    087      public final int getTag() {
    088         return TagConstants.TYPENAME;
    089      }
    090
    091      public final void accept(Visitor v) { v.visitTypeName(this); }
    092
    093      public final Object accept(VisitorArgResult v, Object o) {return v.visitTypeName(this, o); }
    094
    095      public void check() {
    096         super.check();
    097         if (this.tmodifiers != null)
    098            for(int i = 0; i < this.tmodifiers.size(); i++)
    099               this.tmodifiers.elementAt(i).check();
    100         this.name.check();
    101      }
    102
    103      //@ ensures \result != null;
    104      public static TypeName make(TypeModifierPragmaVec tmodifiers, /*@ non_null @*/ Name name) {
    105         //@ set I_will_establish_invariants_afterwards = true;
    106         TypeName result = new TypeName();
    107         result.tmodifiers = tmodifiers;
    108         result.name = name;
    109         return result;
    110      }
    111    }