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    public class TypeName extends Type
024    {
025      // We always have associated locations:
026      //@ invariant syntax;
027    
028      public /*@ non_null @*/ Name name;
029    
030      //@ public represents startLoc <- name.getStartLoc();
031      public /*@ pure @*/ int getStartLoc() { return name.getStartLoc(); }
032      //@ also public normal_behavior
033      //@ ensures \result == name.getEndLoc();
034      public /*@ pure @*/ int getEndLoc() { return name.getEndLoc(); }
035    
036      // overloaded constructor for type names that
037      // do not have any type modifiers
038      static public /*@ non_null */ TypeName make(/*@ non_null @*/ Name name) {
039        return TypeName.make(null, name);
040      }
041    
042    
043    
044    // Generated boilerplate constructors:
045    
046      //@ ensures this.tmodifiers == tmodifiers;
047      //@ ensures this.name == name;
048      protected TypeName(TypeModifierPragmaVec tmodifiers, /*@ non_null @*/ Name name) {
049         super(tmodifiers);
050         this.name = name;
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 /*@non_null*/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         TypeName result = new TypeName(tmodifiers, name);
106         return result;
107      }
108    }