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