    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    /**
    023     * Represents a ObjectDesignator of the form "TypeName . "
    024     *
    025     * <p> Is created from AmbiguousVariableAccess/AmbiguousMethodInvocation
    026     * by the name resolution code.
    027     * The <code>type</code> must be an instance of either <code>TypeName</code>
    028     * or <code>TypeSig</code>  (found in <code>javafe.tc</code>).
    029     * If <code>type</code> is a <code>TypeName</code>, then an explicit
    030     * type name was given in the program text; if <code>type</code>
    031     * is a <code>TypeSig</code>, then the type was inferred.
    032     */
    033
    034    public class TypeObjectDesignator extends ObjectDesignator
    035    {
    036      //@ invariant type instanceof TypeName || type instanceof javafe.tc.TypeSig;
    037      public /*@ non_null @*/ Type type;
    038
    039
    040      private void postCheck() {
    041        Assert.notNull(type);
    042      }
    043
    044        public int getStartLoc() {
    045            if (!(type instanceof javafe.tc.TypeSig))
    046                return type.getStartLoc();
    047
    048            return locDot;
    049        }
    050
    051      public Type type() { return type; }
    052
    053      //* Manual maker to ensure invariant on type satisfied
    054      //@ requires type instanceof TypeName || type instanceof javafe.tc.TypeSig;
    055      //
    056      //@ requires locDot != javafe.util.Location.NULL;
    057      //@ ensures \result != null;
    058      public static TypeObjectDesignator make(int locDot,
    059                                              /*@ non_null @*/ Type type) {
    060         //@ set I_will_establish_invariants_afterwards = true;
    061         TypeObjectDesignator result = new TypeObjectDesignator();
    062         result.locDot = locDot;
    063         result.type = type;
    064         return result;
    065      }
    066
    067
    068    // Generated boilerplate constructors:
    069
    070      /**
    071       * Construct a raw TypeObjectDesignator whose class invariant(s) have not
    072       * yet been established.  It is the caller's job to
    073       * initialize the returned node's fields so that any
    074       * class invariants hold.
    075       */
    076      //@ requires I_will_establish_invariants_afterwards;
    077      protected TypeObjectDesignator() {}    //@ nowarn Invariant,NonNullInit;
    078
    079
    080    // Generated boilerplate methods:
    081
    082      public final int childCount() {
    083         return 1;
    084      }
    085
    086      public final Object childAt(int index) {
    087              /*throws IndexOutOfBoundsException*/
    088         if (index < 0)
    089            throw new IndexOutOfBoundsException("AST child index " + index);
    090         int indexPre = index;
    091
    092         int sz;
    093
    094         if (index == 0) return this.type;
    095         else index--;
    096
    097         throw new IndexOutOfBoundsException("AST child index " + indexPre);
    098      }   //@ nowarn Exception;
    099
    100      public final String toString() {
    101         return "[TypeObjectDesignator"
    102            + " locDot = " + this.locDot
    103            + " type = " + this.type
    104            + "]";
    105      }
    106
    107      public final int getTag() {
    108         return TagConstants.TYPEOBJECTDESIGNATOR;
    109      }
    110
    111      public final void accept(Visitor v) { v.visitTypeObjectDesignator(this); }
    112
    113      public final Object accept(VisitorArgResult v, Object o) {return v.visitTypeObjectDesignator(this, o); }
    114
    115      public void check() {
    116         super.check();
    117         this.type.check();
    118         postCheck();
    119      }
    120
    121    }