    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 escjava.ast;
    013
    014    import java.util.Hashtable;
    015    import java.util.Set;
    016    import java.util.ArrayList;
    017
    018    import javafe.ast.*;
    019    import javafe.util.Assert;
    020    import javafe.util.Location;
    021    import escjava.ParsedRoutineSpecs;
    022
    023    // Convention: unless otherwise noted, integer fields named "loc" refer
    024    // to the location of the first character of the syntactic unit
    025
    026    //# TagBase javafe.tc.TagConstants.LAST_TAG + 1
    027    //# VisitorRoot javafe.ast.Visitor
    028
    029
    030    public class DependsPragma extends TypeDeclElemPragma
    031    {
    032      public int tag;
    033
    034      public /*@ non_null @*/ Expr target;
    035
    036      public /*@ non_null @*/ ExprVec exprs;
    037
    038      public int loc;
    039
    040
    041      public final int getTag() { return tag; }
    042
    043      public int getStartLoc() { return loc; }
    044      public int getEndLoc() { return exprs.elementAt(exprs.size()-1).getEndLoc(); }
    045
    046
    047    // Generated boilerplate constructors:
    048
    049      /**
    050       * Construct a raw DependsPragma whose class invariant(s) have not
    051       * yet been established.  It is the caller's job to
    052       * initialize the returned node's fields so that any
    053       * class invariants hold.
    054       */
    055      //@ requires I_will_establish_invariants_afterwards;
    056      protected DependsPragma() {}    //@ nowarn Invariant,NonNullInit;
    057
    058
    059    // Generated boilerplate methods:
    060
    061      public final int childCount() {
    062         int sz = 0;
    063         if (this.exprs != null) sz += this.exprs.size();
    064         return sz + 1;
    065      }
    066
    067      public final Object childAt(int index) {
    068              /*throws IndexOutOfBoundsException*/
    069         if (index < 0)
    070            throw new IndexOutOfBoundsException("AST child index " + index);
    071         int indexPre = index;
    072
    073         int sz;
    074
    075         if (index == 0) return this.target;
    076         else index--;
    077
    078         sz = (this.exprs == null ? 0 : this.exprs.size());
    079         if (0 <= index && index < sz)
    080            return this.exprs.elementAt(index);
    081         else index -= sz;
    082
    083         throw new IndexOutOfBoundsException("AST child index " + indexPre);
    084      }   //@ nowarn Exception;
    085
    086      public final String toString() {
    087         return "[DependsPragma"
    088            + " tag = " + this.tag
    089            + " target = " + this.target
    090            + " exprs = " + this.exprs
    091            + " loc = " + this.loc
    092            + "]";
    093      }
    094
    095      public final void accept(javafe.ast.Visitor v) {
    096        if (v instanceof Visitor) ((Visitor)v).visitDependsPragma(this);
    097      }
    098
    099      public final Object accept(javafe.ast.VisitorArgResult v, Object o) {
    100        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitDependsPragma(this, o); else return null;
    101      }
    102
    103      public void check() {
    104         this.target.check();
    105         for(int i = 0; i < this.exprs.size(); i++)
    106            this.exprs.elementAt(i).check();
    107      }
    108
    109      //@ ensures \result != null;
    110      public static DependsPragma make(int tag, /*@ non_null @*/ Expr target, /*@ non_null @*/ ExprVec exprs, int loc) {
    111         //@ set I_will_establish_invariants_afterwards = true;
    112         DependsPragma result = new DependsPragma();
    113         result.tag = tag;
    114         result.target = target;
    115         result.exprs = exprs;
    116         result.loc = loc;
    117         return result;
    118      }
    119    }