    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 ExprCmd extends GuardedCmd
    031    {
    032      // Denotes assert or assume
    033      public int cmd;
    034
    035      public /*@ non_null @*/ Expr pred;
    036
    037      public int loc;
    038
    039
    040      public final int getTag() { return cmd; }
    041
    042      private void postCheck() {
    043        boolean goodtag =
    044          (cmd == TagConstants.ASSERTCMD || cmd == TagConstants.ASSUMECMD);
    045        Assert.notFalse(goodtag);
    046      }
    047
    048      public int getStartLoc() { return loc; }
    049
    050
    051    // Generated boilerplate constructors:
    052
    053      /**
    054       * Construct a raw ExprCmd 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 ExprCmd() {}    //@ nowarn Invariant,NonNullInit;
    061
    062
    063    // Generated boilerplate methods:
    064
    065      public final int childCount() {
    066         return 1;
    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.pred;
    078         else index--;
    079
    080         throw new IndexOutOfBoundsException("AST child index " + indexPre);
    081      }   //@ nowarn Exception;
    082
    083      public final String toString() {
    084         return "[ExprCmd"
    085            + " cmd = " + this.cmd
    086            + " pred = " + this.pred
    087            + " loc = " + this.loc
    088            + "]";
    089      }
    090
    091      public final void accept(javafe.ast.Visitor v) {
    092        if (v instanceof Visitor) ((Visitor)v).visitExprCmd(this);
    093      }
    094
    095      public final Object accept(javafe.ast.VisitorArgResult v, Object o) {
    096        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitExprCmd(this, o); else return null;
    097      }
    098
    099      public void check() {
    100         super.check();
    101         this.pred.check();
    102         postCheck();
    103      }
    104
    105      //@ ensures \result != null;
    106      public static ExprCmd make(int cmd, /*@ non_null @*/ Expr pred, int loc) {
    107         //@ set I_will_establish_invariants_afterwards = true;
    108         ExprCmd result = new ExprCmd();
    109         result.cmd = cmd;
    110         result.pred = pred;
    111         result.loc = loc;
    112         return result;
    113      }
    114    }