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