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