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