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 javafe.ast; 013 014 import javafe.util.Assert; 015 import javafe.util.Location; 016 import javafe.util.ErrorSet; 017 018 // Convention: unless otherwise noted, integer fields named "loc" refer 019 // to the location of the first character of the syntactic unit 020 021 022 public class InterfaceDecl extends TypeDecl 023 { 024 025 /** Set the parent pointer of the <code>TypeDeclElems</code>s 026 inside the <code>this</code>. */ 027 private void postMake() { 028 for(int i = 0; i < elems.size(); i++) 029 elems.elementAt(i).setParent(this); 030 } 031 032 033 // Generated boilerplate constructors: 034 035 /** 036 * Construct a raw InterfaceDecl whose class invariant(s) have not 037 * yet been established. It is the caller's job to 038 * initialize the returned node's fields so that any 039 * class invariants hold. 040 */ 041 //@ requires I_will_establish_invariants_afterwards; 042 protected InterfaceDecl() {} //@ nowarn Invariant,NonNullInit; 043 044 045 // Generated boilerplate methods: 046 047 public final int childCount() { 048 int sz = 0; 049 if (this.pmodifiers != null) sz += this.pmodifiers.size(); 050 if (this.superInterfaces != null) sz += this.superInterfaces.size(); 051 if (this.tmodifiers != null) sz += this.tmodifiers.size(); 052 if (this.elems != null) sz += this.elems.size(); 053 return sz + 1; 054 } 055 056 public final Object childAt(int index) { 057 /*throws IndexOutOfBoundsException*/ 058 if (index < 0) 059 throw new IndexOutOfBoundsException("AST child index " + index); 060 int indexPre = index; 061 062 int sz; 063 064 sz = (this.pmodifiers == null ? 0 : this.pmodifiers.size()); 065 if (0 <= index && index < sz) 066 return this.pmodifiers.elementAt(index); 067 else index -= sz; 068 069 if (index == 0) return this.id; 070 else index--; 071 072 sz = (this.superInterfaces == null ? 0 : this.superInterfaces.size()); 073 if (0 <= index && index < sz) 074 return this.superInterfaces.elementAt(index); 075 else index -= sz; 076 077 sz = (this.tmodifiers == null ? 0 : this.tmodifiers.size()); 078 if (0 <= index && index < sz) 079 return this.tmodifiers.elementAt(index); 080 else index -= sz; 081 082 sz = (this.elems == null ? 0 : this.elems.size()); 083 if (0 <= index && index < sz) 084 return this.elems.elementAt(index); 085 else index -= sz; 086 087 throw new IndexOutOfBoundsException("AST child index " + indexPre); 088 } //@ nowarn Exception; 089 090 public final String toString() { 091 return "[InterfaceDecl" 092 + " modifiers = " + this.modifiers 093 + " pmodifiers = " + this.pmodifiers 094 + " id = " + this.id 095 + " superInterfaces = " + this.superInterfaces 096 + " tmodifiers = " + this.tmodifiers 097 + " elems = " + this.elems 098 + " loc = " + this.loc 099 + " locId = " + this.locId 100 + " locOpenBrace = " + this.locOpenBrace 101 + " locCloseBrace = " + this.locCloseBrace 102 + "]"; 103 } 104 105 public final int getTag() { 106 return TagConstants.INTERFACEDECL; 107 } 108 109 public final void accept(Visitor v) { v.visitInterfaceDecl(this); } 110 111 public final Object accept(VisitorArgResult v, Object o) {return v.visitInterfaceDecl(this, o); } 112 113 public void check() { 114 super.check(); 115 if (this.pmodifiers != null) 116 for(int i = 0; i < this.pmodifiers.size(); i++) 117 this.pmodifiers.elementAt(i).check(); 118 if (this.id == null) throw new RuntimeException(); 119 for(int i = 0; i < this.superInterfaces.size(); i++) 120 this.superInterfaces.elementAt(i).check(); 121 if (this.tmodifiers != null) 122 for(int i = 0; i < this.tmodifiers.size(); i++) 123 this.tmodifiers.elementAt(i).check(); 124 if (this.elems == null) throw new RuntimeException(); 125 } 126 127 //@ requires loc != javafe.util.Location.NULL; 128 //@ requires locId != javafe.util.Location.NULL; 129 //@ requires locOpenBrace != javafe.util.Location.NULL; 130 //@ requires locCloseBrace != javafe.util.Location.NULL; 131 //@ ensures \result != null; 132 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) { 133 //@ set I_will_establish_invariants_afterwards = true; 134 InterfaceDecl result = new InterfaceDecl(); 135 result.modifiers = modifiers; 136 result.pmodifiers = pmodifiers; 137 result.id = id; 138 result.superInterfaces = superInterfaces; 139 result.tmodifiers = tmodifiers; 140 result.elems = elems; 141 result.loc = loc; 142 result.locId = locId; 143 result.locOpenBrace = locOpenBrace; 144 result.locCloseBrace = locCloseBrace; 145 result.postMake(); 146 return result; 147 } 148 }