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