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 DynInstCmd extends GuardedCmd
032 {
033 // denotes DynamicInstanceCommand s IN g END.
034 public /*@ non_null @*/ String s;
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.s == s;
051 //@ ensures this.g == g;
052 protected DynInstCmd(/*@ non_null @*/ String s, /*@ non_null @*/ GuardedCmd g) {
053 super();
054 this.s = s;
055 this.g = g;
056 }
057
058 // Generated boilerplate methods:
059
060 public final int childCount() {
061 return 2;
062 }
063
064 public final Object childAt(int index) {
065 /*throws IndexOutOfBoundsException*/
066 if (index < 0)
067 throw new IndexOutOfBoundsException("AST child index " + index);
068 int indexPre = index;
069
070 int sz;
071
072 if (index == 0) return this.s;
073 else index--;
074
075 if (index == 0) return this.g;
076 else index--;
077
078 throw new IndexOutOfBoundsException("AST child index " + indexPre);
079 } //@ nowarn Exception;
080
081 public final /*@non_null*/String toString() {
082 return "[DynInstCmd"
083 + " s = " + this.s
084 + " g = " + this.g
085 + "]";
086 }
087
088 public final int getTag() {
089 return TagConstants.DYNINSTCMD;
090 }
091
092 public final void accept(javafe.ast.Visitor v) {
093 if (v instanceof Visitor) ((Visitor)v).visitDynInstCmd(this);
094 }
095
096 public final Object accept(javafe.ast.VisitorArgResult v, Object o) {
097 if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitDynInstCmd(this, o); else return null;
098 }
099
100 public void check() {
101 super.check();
102 if (this.s == null) throw new RuntimeException();
103 this.g.check();
104 }
105
106 //@ ensures \result != null;
107 public static DynInstCmd make(/*@ non_null @*/ String s, /*@ non_null @*/ GuardedCmd g) {
108 DynInstCmd result = new DynInstCmd(s, g);
109 return result;
110 }
111 }