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