001    // -*- mode: java -*-
002    /* Copyright 2000, 2001, Compaq Computer Corporation */
003    
004    /* IF THIS IS A JAVA FILE, DO NOT EDIT IT!  
005    
006       Most Java files in this directory which are part of the Javafe AST
007       are automatically generated using the astgen comment (see
008       ESCTools/Javafe/astgen) from the input file 'hierarchy.h'.  If you
009       wish to modify AST classes or introduce new ones, modify
010       'hierarchy.j.'
011     */
012    
013    package escjava.ast;
014    
015    import java.util.Hashtable;
016    import java.util.Set;
017    import java.util.ArrayList;
018    
019    import javafe.ast.*;
020    import javafe.util.Assert;
021    import javafe.util.Location;
022    import escjava.ParsedRoutineSpecs;
023    
024    // Convention: unless otherwise noted, integer fields named "loc" refer
025    // to the location of the first character of the syntactic unit
026    
027    //# TagBase javafe.tc.TagConstants.LAST_TAG + 1
028    //# VisitorRoot javafe.ast.Visitor
029    
030    
031    public class VarInCmd extends GuardedCmd
032    {
033      // denotes VAR v IN g END.
034      public /*@ non_null @*/ GenericVarDeclVec v;
035    
036      public /*@ non_null @*/ GuardedCmd g;
037    
038    
039      //@ public represents startLoc <- g.getStartLoc();
040      public /*@ pure @*/ int getStartLoc() { return g.getStartLoc(); }
041      /*@ also
042        @ public normal_behavior
043        @ ensures \result == g.getEndLoc();
044        @*/
045      public /*@ pure @*/ int getEndLoc() { return g.getEndLoc(); }
046    
047    
048    // Generated boilerplate constructors:
049    
050      //@ ensures this.v == v;
051      //@ ensures this.g == g;
052      protected VarInCmd(/*@ non_null @*/ GenericVarDeclVec v, /*@ non_null @*/ GuardedCmd g) {
053         super();
054         this.v = v;
055         this.g = g;
056      }
057    
058    // Generated boilerplate methods:
059    
060      public final int childCount() {
061         int sz = 0;
062         if (this.v != null) sz += this.v.size();
063         return sz + 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         sz = (this.v == null ? 0 : this.v.size());
075         if (0 <= index && index < sz)
076            return this.v.elementAt(index);
077         else index -= sz;
078    
079         if (index == 0) return this.g;
080         else index--;
081    
082         throw new IndexOutOfBoundsException("AST child index " + indexPre);
083      }   //@ nowarn Exception;
084    
085      public final /*@non_null*/String toString() {
086         return "[VarInCmd"
087            + " v = " + this.v
088            + " g = " + this.g
089            + "]";
090      }
091    
092      public final int getTag() {
093         return TagConstants.VARINCMD;
094      }
095    
096      public final void accept(javafe.ast.Visitor v) { 
097        if (v instanceof Visitor) ((Visitor)v).visitVarInCmd(this);
098      }
099    
100      public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
101        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitVarInCmd(this, o); else return null;
102      }
103    
104      public void check() {
105         super.check();
106         for(int i = 0; i < this.v.size(); i++)
107            this.v.elementAt(i).check();
108         this.g.check();
109      }
110    
111      //@ ensures \result != null;
112      public static VarInCmd make(/*@ non_null @*/ GenericVarDeclVec v, /*@ non_null @*/ GuardedCmd g) {
113         VarInCmd result = new VarInCmd(v, g);
114         return result;
115      }
116    }