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