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