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