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