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 javafe.ast;
014    
015    import javafe.util.Assert;
016    import javafe.util.Location;
017    import javafe.util.ErrorSet;
018    
019    // Convention: unless otherwise noted, integer fields named "loc" refer
020    // to the location of the first character of the syntactic unit
021    
022    
023    /**
024     * Represents an ArrayInitializer. 
025     */
026    
027    public class ArrayInit extends VarInit
028    {
029      public /*@ non_null @*/ VarInitVec elems;
030    
031      //@ invariant locOpenBrace != javafe.util.Location.NULL;
032      public int locOpenBrace;
033    
034      //@ invariant locCloseBrace != javafe.util.Location.NULL;
035      public int locCloseBrace;
036    
037    
038      //@ public represents startLoc <- locOpenBrace;
039      public /*@ pure @*/ int getStartLoc() { return locOpenBrace; }
040      //@ also public normal_behavior
041      //@ ensures \result == locCloseBrace;
042      public /*@ pure @*/ int getEndLoc() { return locCloseBrace; }
043    
044    
045    // Generated boilerplate constructors:
046    
047      //@ ensures this.elems == elems;
048      //@ ensures this.locOpenBrace == locOpenBrace;
049      //@ ensures this.locCloseBrace == locCloseBrace;
050      protected ArrayInit(/*@ non_null @*/ VarInitVec elems, int locOpenBrace, int locCloseBrace) {
051         super();
052         this.elems = elems;
053         this.locOpenBrace = locOpenBrace;
054         this.locCloseBrace = locCloseBrace;
055      }
056    
057    // Generated boilerplate methods:
058    
059      public final int childCount() {
060         int sz = 0;
061         if (this.elems != null) sz += this.elems.size();
062         return sz + 0;
063      }
064    
065      public final Object childAt(int index) {
066              /*throws IndexOutOfBoundsException*/
067         if (index < 0)
068            throw new IndexOutOfBoundsException("AST child index " + index);
069         int indexPre = index;
070    
071         int sz;
072    
073         sz = (this.elems == null ? 0 : this.elems.size());
074         if (0 <= index && index < sz)
075            return this.elems.elementAt(index);
076         else index -= sz;
077    
078         throw new IndexOutOfBoundsException("AST child index " + indexPre);
079      }   //@ nowarn Exception;
080    
081      public final /*@non_null*/String toString() {
082         return "[ArrayInit"
083            + " elems = " + this.elems
084            + " locOpenBrace = " + this.locOpenBrace
085            + " locCloseBrace = " + this.locCloseBrace
086            + "]";
087      }
088    
089      public final int getTag() {
090         return TagConstants.ARRAYINIT;
091      }
092    
093      public final void accept(Visitor v) { v.visitArrayInit(this); }
094    
095      public final Object accept(VisitorArgResult v, Object o) {return v.visitArrayInit(this, o); }
096    
097      public void check() {
098         super.check();
099         for(int i = 0; i < this.elems.size(); i++)
100            this.elems.elementAt(i).check();
101      }
102    
103      //@ requires locOpenBrace != javafe.util.Location.NULL;
104      //@ requires locCloseBrace != javafe.util.Location.NULL;
105      //@ ensures \result != null;
106      public static ArrayInit make(/*@ non_null @*/ VarInitVec elems, int locOpenBrace, int locCloseBrace) {
107         ArrayInit result = new ArrayInit(elems, locOpenBrace, locCloseBrace);
108         return result;
109      }
110    }