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