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