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 escjava.ast;
014
015 import java.util.Hashtable;
016 import java.util.Set;
017 import java.util.ArrayList;
018
019 import javafe.ast.*;
020 import javafe.util.Assert;
021 import javafe.util.Location;
022 import escjava.ParsedRoutineSpecs;
023
024 // Convention: unless otherwise noted, integer fields named "loc" refer
025 // to the location of the first character of the syntactic unit
026
027 //# TagBase javafe.tc.TagConstants.LAST_TAG + 1
028 //# VisitorRoot javafe.ast.Visitor
029
030
031 public class GuardExpr extends Expr
032 {
033 public /*@ non_null @*/ Expr expr;
034
035 public int locPragmaDecl;
036
037
038 //@ public represents startLoc <- expr.getStartLoc();
039 public /*@ pure @*/ int getStartLoc() { return expr.getStartLoc(); }
040 /*@ also
041 @ public normal_behavior
042 @ ensures \result == expr.getEndLoc();
043 @*/
044 public /*@ pure @*/ int getEndLoc() { return expr.getEndLoc(); }
045
046
047 // Generated boilerplate constructors:
048
049 //@ ensures this.expr == expr;
050 //@ ensures this.locPragmaDecl == locPragmaDecl;
051 protected GuardExpr(/*@ non_null @*/ Expr expr, int locPragmaDecl) {
052 this.expr = expr;
053 this.locPragmaDecl = locPragmaDecl;
054 }
055
056 // Generated boilerplate methods:
057
058 public final int childCount() {
059 return 1;
060 }
061
062 public final Object childAt(int index) {
063 /*throws IndexOutOfBoundsException*/
064 if (index < 0)
065 throw new IndexOutOfBoundsException("AST child index " + index);
066 int indexPre = index;
067
068 int sz;
069
070 if (index == 0) return this.expr;
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 "[GuardExpr"
078 + " expr = " + this.expr
079 + " locPragmaDecl = " + this.locPragmaDecl
080 + "]";
081 }
082
083 public final int getTag() {
084 return TagConstants.GUARDEXPR;
085 }
086
087 public final void accept(javafe.ast.Visitor v) {
088 if (v instanceof Visitor) ((Visitor)v).visitGuardExpr(this);
089 }
090
091 public final Object accept(javafe.ast.VisitorArgResult v, Object o) {
092 if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitGuardExpr(this, o); else return null;
093 }
094
095 public void check() {
096 this.expr.check();
097 }
098
099 //@ ensures \result != null;
100 public static GuardExpr make(/*@ non_null @*/ Expr expr, int locPragmaDecl) {
101 GuardExpr result = new GuardExpr(expr, locPragmaDecl);
102 return result;
103 }
104 }