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 public class InterfaceDecl extends TypeDecl
024 {
025
026 /** Set the parent pointer of the <code>TypeDeclElems</code>s
027 inside the <code>this</code>. */
028 private void postMake() {
029 for(int i = 0; i < elems.size(); i++)
030 elems.elementAt(i).setParent(this);
031 }
032
033
034 // Generated boilerplate constructors:
035
036 //@ ensures this.modifiers == modifiers;
037 //@ ensures this.pmodifiers == pmodifiers;
038 //@ ensures this.id == id;
039 //@ ensures this.superInterfaces == superInterfaces;
040 //@ ensures this.tmodifiers == tmodifiers;
041 //@ ensures this.elems == elems;
042 //@ ensures this.loc == loc;
043 //@ ensures this.locId == locId;
044 //@ ensures this.locOpenBrace == locOpenBrace;
045 //@ ensures this.locCloseBrace == locCloseBrace;
046 protected InterfaceDecl(int modifiers, ModifierPragmaVec pmodifiers, /*@ non_null @*/ Identifier id, /*@ non_null @*/ TypeNameVec superInterfaces, TypeModifierPragmaVec tmodifiers, /*@ non_null @*/ TypeDeclElemVec elems, int loc, int locId, int locOpenBrace, int locCloseBrace) {
047 super(modifiers, pmodifiers, id, superInterfaces, tmodifiers, elems, loc, locId, locOpenBrace, locCloseBrace);
048 }
049
050 // Generated boilerplate methods:
051
052 public final int childCount() {
053 int sz = 0;
054 if (this.pmodifiers != null) sz += this.pmodifiers.size();
055 if (this.superInterfaces != null) sz += this.superInterfaces.size();
056 if (this.tmodifiers != null) sz += this.tmodifiers.size();
057 if (this.elems != null) sz += this.elems.size();
058 return sz + 1;
059 }
060
061 public final Object childAt(int index) {
062 /*throws IndexOutOfBoundsException*/
063 if (index < 0)
064 throw new IndexOutOfBoundsException("AST child index " + index);
065 int indexPre = index;
066
067 int sz;
068
069 sz = (this.pmodifiers == null ? 0 : this.pmodifiers.size());
070 if (0 <= index && index < sz)
071 return this.pmodifiers.elementAt(index);
072 else index -= sz;
073
074 if (index == 0) return this.id;
075 else index--;
076
077 sz = (this.superInterfaces == null ? 0 : this.superInterfaces.size());
078 if (0 <= index && index < sz)
079 return this.superInterfaces.elementAt(index);
080 else index -= sz;
081
082 sz = (this.tmodifiers == null ? 0 : this.tmodifiers.size());
083 if (0 <= index && index < sz)
084 return this.tmodifiers.elementAt(index);
085 else index -= sz;
086
087 sz = (this.elems == null ? 0 : this.elems.size());
088 if (0 <= index && index < sz)
089 return this.elems.elementAt(index);
090 else index -= sz;
091
092 throw new IndexOutOfBoundsException("AST child index " + indexPre);
093 } //@ nowarn Exception;
094
095 public final /*@non_null*/String toString() {
096 return "[InterfaceDecl"
097 + " modifiers = " + this.modifiers
098 + " pmodifiers = " + this.pmodifiers
099 + " id = " + this.id
100 + " superInterfaces = " + this.superInterfaces
101 + " tmodifiers = " + this.tmodifiers
102 + " elems = " + this.elems
103 + " loc = " + this.loc
104 + " locId = " + this.locId
105 + " locOpenBrace = " + this.locOpenBrace
106 + " locCloseBrace = " + this.locCloseBrace
107 + "]";
108 }
109
110 public final int getTag() {
111 return TagConstants.INTERFACEDECL;
112 }
113
114 public final void accept(Visitor v) { v.visitInterfaceDecl(this); }
115
116 public final Object accept(VisitorArgResult v, Object o) {return v.visitInterfaceDecl(this, o); }
117
118 public void check() {
119 super.check();
120 if (this.pmodifiers != null)
121 for(int i = 0; i < this.pmodifiers.size(); i++)
122 this.pmodifiers.elementAt(i).check();
123 if (this.id == null) throw new RuntimeException();
124 for(int i = 0; i < this.superInterfaces.size(); i++)
125 this.superInterfaces.elementAt(i).check();
126 if (this.tmodifiers != null)
127 for(int i = 0; i < this.tmodifiers.size(); i++)
128 this.tmodifiers.elementAt(i).check();
129 if (this.elems == null) throw new RuntimeException();
130 }
131
132 //@ requires loc != javafe.util.Location.NULL;
133 //@ requires locId != javafe.util.Location.NULL;
134 //@ requires locOpenBrace != javafe.util.Location.NULL;
135 //@ requires locCloseBrace != javafe.util.Location.NULL;
136 //@ ensures \result != null;
137 public static InterfaceDecl make(int modifiers, ModifierPragmaVec pmodifiers, /*@ non_null @*/ Identifier id, /*@ non_null @*/ TypeNameVec superInterfaces, TypeModifierPragmaVec tmodifiers, /*@ non_null @*/ TypeDeclElemVec elems, int loc, int locId, int locOpenBrace, int locCloseBrace) {
138 InterfaceDecl result = new InterfaceDecl(modifiers, pmodifiers, id, superInterfaces, tmodifiers, elems, loc, locId, locOpenBrace, locCloseBrace);
139 result.postMake();
140 return result;
141 }
142 }