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