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