    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 class literal (Type . class)
    024     */
    025
    026    public class ClassLiteral extends Expr
    027    {
    028      //@ invariant type.syntax;
    029      public /*@ non_null @*/ Type type;
    030
    031      //@ invariant locDot != javafe.util.Location.NULL;
    032      public int locDot;
    033
    034
    035      public int getStartLoc() {
    036        return type.getStartLoc();
    037      }
    038
    039      public int getEndLoc() {
    040        return locDot;
    041      }
    042
    043
    044    // Generated boilerplate constructors:
    045
    046      /**
    047       * Construct a raw ClassLiteral whose class invariant(s) have not
    048       * yet been established.  It is the caller's job to
    049       * initialize the returned node's fields so that any
    050       * class invariants hold.
    051       */
    052      //@ requires I_will_establish_invariants_afterwards;
    053      protected ClassLiteral() {}    //@ nowarn Invariant,NonNullInit;
    054
    055
    056    // Generated boilerplate methods:
    057
    058      public final int childCount() {
    059         return 1;
    060      }
    061
    062      public final Object childAt(int index) {
    063              /*throws IndexOutOfBoundsException*/
    064         if (index < 0)
    065            throw new IndexOutOfBoundsException("AST child index " + index);
    066         int indexPre = index;
    067
    068         int sz;
    069
    070         if (index == 0) return this.type;
    071         else index--;
    072
    073         throw new IndexOutOfBoundsException("AST child index " + indexPre);
    074      }   //@ nowarn Exception;
    075
    076      public final String toString() {
    077         return "[ClassLiteral"
    078            + " type = " + this.type
    079            + " locDot = " + this.locDot
    080            + "]";
    081      }
    082
    083      public final int getTag() {
    084         return TagConstants.CLASSLITERAL;
    085      }
    086
    087      public final void accept(Visitor v) { v.visitClassLiteral(this); }
    088
    089      public final Object accept(VisitorArgResult v, Object o) {return v.visitClassLiteral(this, o); }
    090
    091      public void check() {
    092         super.check();
    093         this.type.check();
    094      }
    095
    096      //@ requires type.syntax;
    097      //@ requires locDot != javafe.util.Location.NULL;
    098      //@ ensures \result != null;
    099      public static ClassLiteral make(/*@ non_null @*/ Type type, int locDot) {
    100         //@ set I_will_establish_invariants_afterwards = true;
    101         ClassLiteral result = new ClassLiteral();
    102         result.type = type;
    103         result.locDot = locDot;
    104         return result;
    105      }
    106    }