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 ArrayRangeRefExpr extends Expr
032    {
033      public int locOpenBracket;
034    
035      public /*@ non_null @*/ Expr array;
036    
037      public Expr lowIndex;
038    
039      public Expr highIndex;
040    
041    
042      //@ public represents startLoc <- locOpenBracket;
043      public /*@ pure @*/ int getStartLoc() { return locOpenBracket; }
044    
045      public void bogusMethod() { int i = bogusField; }
046    
047    
048    // Generated boilerplate constructors:
049    
050      //@ ensures this.locOpenBracket == locOpenBracket;
051      //@ ensures this.array == array;
052      //@ ensures this.lowIndex == lowIndex;
053      //@ ensures this.highIndex == highIndex;
054      protected ArrayRangeRefExpr(int locOpenBracket, /*@ non_null @*/ Expr array, Expr lowIndex, Expr highIndex) {
055         this.locOpenBracket = locOpenBracket;
056         this.array = array;
057         this.lowIndex = lowIndex;
058         this.highIndex = highIndex;
059      }
060    
061    // Generated boilerplate methods:
062    
063      public final int childCount() {
064         return 3;
065      }
066    
067      public final Object childAt(int index) {
068              /*throws IndexOutOfBoundsException*/
069         if (index < 0)
070            throw new IndexOutOfBoundsException("AST child index " + index);
071         int indexPre = index;
072    
073         int sz;
074    
075         if (index == 0) return this.array;
076         else index--;
077    
078         if (index == 0) return this.lowIndex;
079         else index--;
080    
081         if (index == 0) return this.highIndex;
082         else index--;
083    
084         throw new IndexOutOfBoundsException("AST child index " + indexPre);
085      }   //@ nowarn Exception;
086    
087      public final /*@non_null*/String toString() {
088         return "[ArrayRangeRefExpr"
089            + " locOpenBracket = " + this.locOpenBracket
090            + " array = " + this.array
091            + " lowIndex = " + this.lowIndex
092            + " highIndex = " + this.highIndex
093            + "]";
094      }
095    
096      public final int getTag() {
097         return TagConstants.ARRAYRANGEREFEXPR;
098      }
099    
100      public final void accept(javafe.ast.Visitor v) { 
101        if (v instanceof Visitor) ((Visitor)v).visitArrayRangeRefExpr(this);
102      }
103    
104      public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
105        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitArrayRangeRefExpr(this, o); else return null;
106      }
107    
108      public void check() {
109         this.array.check();
110         if (this.lowIndex != null)
111            this.lowIndex.check();
112         if (this.highIndex != null)
113            this.highIndex.check();
114      }
115    
116      //@ ensures \result != null;
117      public static ArrayRangeRefExpr make(int locOpenBracket, /*@ non_null @*/ Expr array, Expr lowIndex, Expr highIndex) {
118         ArrayRangeRefExpr result = new ArrayRangeRefExpr(locOpenBracket, array, lowIndex, highIndex);
119         return result;
120      }
121    }