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