    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    /** Represents a ConstructorDeclaration.
    023     *
    024     *  The first Stmt in the body field should be a ConstructorInvocation. If
    025     *  the source code does not contain a constructor invocation, it is
    026     *  inserted by the parser.
    027     */
    028
    029    public class ConstructorDecl extends RoutineDecl
    030    {
    031
    032      public Identifier id() { return parent != null ? parent.id : Identifier.intern("<constructor>"); }
    033
    034
    035    // Generated boilerplate constructors:
    036
    037      /**
    038       * Construct a raw ConstructorDecl whose class invariant(s) have not
    039       * yet been established.  It is the caller's job to
    040       * initialize the returned node's fields so that any
    041       * class invariants hold.
    042       */
    043      //@ requires I_will_establish_invariants_afterwards;
    044      protected ConstructorDecl() {}    //@ nowarn Invariant,NonNullInit;
    045
    046
    047    // Generated boilerplate methods:
    048
    049      public final int childCount() {
    050         int sz = 0;
    051         if (this.pmodifiers != null) sz += this.pmodifiers.size();
    052         if (this.tmodifiers != null) sz += this.tmodifiers.size();
    053         if (this.args != null) sz += this.args.size();
    054         if (this.raises != null) sz += this.raises.size();
    055         return sz + 1;
    056      }
    057
    058      public final Object childAt(int index) {
    059              /*throws IndexOutOfBoundsException*/
    060         if (index < 0)
    061            throw new IndexOutOfBoundsException("AST child index " + index);
    062         int indexPre = index;
    063
    064         int sz;
    065
    066         sz = (this.pmodifiers == null ? 0 : this.pmodifiers.size());
    067         if (0 <= index && index < sz)
    068            return this.pmodifiers.elementAt(index);
    069         else index -= sz;
    070
    071         sz = (this.tmodifiers == null ? 0 : this.tmodifiers.size());
    072         if (0 <= index && index < sz)
    073            return this.tmodifiers.elementAt(index);
    074         else index -= sz;
    075
    076         sz = (this.args == null ? 0 : this.args.size());
    077         if (0 <= index && index < sz)
    078            return this.args.elementAt(index);
    079         else index -= sz;
    080
    081         sz = (this.raises == null ? 0 : this.raises.size());
    082         if (0 <= index && index < sz)
    083            return this.raises.elementAt(index);
    084         else index -= sz;
    085
    086         if (index == 0) return this.body;
    087         else index--;
    088
    089         throw new IndexOutOfBoundsException("AST child index " + indexPre);
    090      }   //@ nowarn Exception;
    091
    092      public final String toString() {
    093         return "[ConstructorDecl"
    094            + " modifiers = " + this.modifiers
    095            + " pmodifiers = " + this.pmodifiers
    096            + " tmodifiers = " + this.tmodifiers
    097            + " args = " + this.args
    098            + " raises = " + this.raises
    099            + " body = " + this.body
    100            + " locOpenBrace = " + this.locOpenBrace
    101            + " loc = " + this.loc
    102            + " locId = " + this.locId
    103            + " locThrowsKeyword = " + this.locThrowsKeyword
    104            + "]";
    105      }
    106
    107      public final int getTag() {
    108         return TagConstants.CONSTRUCTORDECL;
    109      }
    110
    111      public final void accept(Visitor v) { v.visitConstructorDecl(this); }
    112
    113      public final Object accept(VisitorArgResult v, Object o) {return v.visitConstructorDecl(this, o); }
    114
    115      public void check() {
    116         super.check();
    117         if (this.pmodifiers != null)
    118            for(int i = 0; i < this.pmodifiers.size(); i++)
    119               this.pmodifiers.elementAt(i).check();
    120         if (this.tmodifiers != null)
    121            for(int i = 0; i < this.tmodifiers.size(); i++)
    122               this.tmodifiers.elementAt(i).check();
    123         for(int i = 0; i < this.args.size(); i++)
    124            this.args.elementAt(i).check();
    125         for(int i = 0; i < this.raises.size(); i++)
    126            this.raises.elementAt(i).check();
    127         if (this.body != null)
    128            this.body.check();
    129      }
    130
    131      //@ requires loc != javafe.util.Location.NULL;
    132      //@ requires locId != javafe.util.Location.NULL;
    133      //@ requires body != null ==> locOpenBrace != Location.NULL;
    134      //@ ensures \result != null;
    135      public static ConstructorDecl make(int modifiers, ModifierPragmaVec pmodifiers, TypeModifierPragmaVec tmodifiers, /*@ non_null @*/ FormalParaDeclVec args, /*@ non_null @*/ TypeNameVec raises, BlockStmt body, int locOpenBrace, int loc, int locId, int locThrowsKeyword) {
    136         //@ set I_will_establish_invariants_afterwards = true;
    137         ConstructorDecl result = new ConstructorDecl();
    138         result.modifiers = modifiers;
    139         result.pmodifiers = pmodifiers;
    140         result.tmodifiers = tmodifiers;
    141         result.args = args;
    142         result.raises = raises;
    143         result.body = body;
    144         result.locOpenBrace = locOpenBrace;
    145         result.loc = loc;
    146         result.locId = locId;
    147         result.locThrowsKeyword = locThrowsKeyword;
    148         return result;
    149      }
    150    }