    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 ModifiesGroupPragma extends ModifierPragma
    031    {
    032        public int tag;
    033
    034        public /*@ non_null @*/ CondExprModifierPragmaVec items;
    035
    036        public /*@ non_null @*/ Expr precondition;
    037
    038        public int clauseLoc;
    039
    040
    041        public int getStartLoc() { return clauseLoc; }
    042
    043        static public ModifiesGroupPragma make(int tag, int loc) {
    044            ModifiesGroupPragma t = new ModifiesGroupPragma();
    045            t.tag = tag;
    046            t.clauseLoc = loc;
    047            t.precondition = null;
    048            t.items = CondExprModifierPragmaVec.make();
    049            return t;
    050        }
    051
    052        public void addElement(CondExprModifierPragma e) {
    053            items.addElement(e);
    054        }
    055
    056        public ModifiesGroupPragma append(ModifiesGroupPragma m) {
    057            items.append(m.items);
    058            return this;
    059        }
    060
    061        public ModifiesGroupPragma append(CondExprModifierPragmaVec ev) {
    062            items.append(ev);
    063            return this;
    064        }
    065
    066
    067    // Generated boilerplate constructors:
    068
    069        /**
    070         * Construct a raw ModifiesGroupPragma whose class invariant(s) have not
    071         * yet been established.  It is the caller's job to
    072         * initialize the returned node's fields so that any
    073         * class invariants hold.
    074         */
    075        //@ requires I_will_establish_invariants_afterwards;
    076        protected ModifiesGroupPragma() {}    //@ nowarn Invariant,NonNullInit;
    077
    078
    079    // Generated boilerplate methods:
    080
    081        public final int childCount() {
    082           int sz = 0;
    083           if (this.items != null) sz += this.items.size();
    084           return sz + 1;
    085        }
    086
    087        public final Object childAt(int index) {
    088                /*throws IndexOutOfBoundsException*/
    089           if (index < 0)
    090              throw new IndexOutOfBoundsException("AST child index " + index);
    091           int indexPre = index;
    092
    093           int sz;
    094
    095           sz = (this.items == null ? 0 : this.items.size());
    096           if (0 <= index && index < sz)
    097              return this.items.elementAt(index);
    098           else index -= sz;
    099
    100           if (index == 0) return this.precondition;
    101           else index--;
    102
    103           throw new IndexOutOfBoundsException("AST child index " + indexPre);
    104        }   //@ nowarn Exception;
    105
    106        public final String toString() {
    107           return "[ModifiesGroupPragma"
    108              + " tag = " + this.tag
    109              + " items = " + this.items
    110              + " precondition = " + this.precondition
    111              + " clauseLoc = " + this.clauseLoc
    112              + "]";
    113        }
    114
    115        public final int getTag() {
    116           return TagConstants.MODIFIESGROUPPRAGMA;
    117        }
    118
    119        public final void accept(javafe.ast.Visitor v) {
    120            if (v instanceof Visitor) ((Visitor)v).visitModifiesGroupPragma(this);
    121        }
    122
    123        public final Object accept(javafe.ast.VisitorArgResult v, Object o) {
    124            if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitModifiesGroupPragma(this, o); else return null;
    125        }
    126
    127        public void check() {
    128           for(int i = 0; i < this.items.size(); i++)
    129              this.items.elementAt(i).check();
    130           this.precondition.check();
    131        }
    132
    133        //@ ensures \result != null;
    134        public static ModifiesGroupPragma make(int tag, /*@ non_null @*/ CondExprModifierPragmaVec items, /*@ non_null @*/ Expr precondition, int clauseLoc) {
    135           //@ set I_will_establish_invariants_afterwards = true;
    136           ModifiesGroupPragma result = new ModifiesGroupPragma();
    137           result.tag = tag;
    138           result.items = items;
    139           result.precondition = precondition;
    140           result.clauseLoc = clauseLoc;
    141           return result;
    142        }
    143    }