    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 AssertStmt extends Stmt
    023    {
    024      public /*@ non_null @*/ Expr pred;
    025
    026      public Expr label;
    027
    028      //@ invariant loc != javafe.util.Location.NULL;
    029      public int loc;
    030
    031      public IfStmt ifStmt;
    032      public int getStartLoc() { return loc; }
    033      public int getEndLoc() {
    034            return (label == null ? pred.getEndLoc() : label.getEndLoc());
    035      }
    036
    037
    038    // Generated boilerplate constructors:
    039
    040      /**
    041       * Construct a raw AssertStmt whose class invariant(s) have not
    042       * yet been established.  It is the caller's job to
    043       * initialize the returned node's fields so that any
    044       * class invariants hold.
    045       */
    046      //@ requires I_will_establish_invariants_afterwards;
    047      protected AssertStmt() {}    //@ nowarn Invariant,NonNullInit;
    048
    049
    050    // Generated boilerplate methods:
    051
    052      public final int childCount() {
    053         return 2;
    054      }
    055
    056      public final Object childAt(int index) {
    057              /*throws IndexOutOfBoundsException*/
    058         if (index < 0)
    059            throw new IndexOutOfBoundsException("AST child index " + index);
    060         int indexPre = index;
    061
    062         int sz;
    063
    064         if (index == 0) return this.pred;
    065         else index--;
    066
    067         if (index == 0) return this.label;
    068         else index--;
    069
    070         throw new IndexOutOfBoundsException("AST child index " + indexPre);
    071      }   //@ nowarn Exception;
    072
    073      public final String toString() {
    074         return "[AssertStmt"
    075            + " pred = " + this.pred
    076            + " label = " + this.label
    077            + " loc = " + this.loc
    078            + "]";
    079      }
    080
    081      public final int getTag() {
    082         return TagConstants.ASSERTSTMT;
    083      }
    084
    085      public final void accept(Visitor v) { v.visitAssertStmt(this); }
    086
    087      public final Object accept(VisitorArgResult v, Object o) {return v.visitAssertStmt(this, o); }
    088
    089      public void check() {
    090         super.check();
    091         this.pred.check();
    092      }
    093
    094      //@ requires loc != javafe.util.Location.NULL;
    095      //@ ensures \result != null;
    096      public static AssertStmt make(/*@ non_null @*/ Expr pred, Expr label, int loc) {
    097         //@ set I_will_establish_invariants_afterwards = true;
    098         AssertStmt result = new AssertStmt();
    099         result.pred = pred;
    100         result.label = label;
    101         result.loc = loc;
    102         return result;
    103      }
    104    }