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 DependsPragma extends TypeDeclElemPragma
032    {
033      public int tag;
034    
035      public /*@ non_null @*/ Expr target;
036    
037      public /*@ non_null @*/ ExprVec exprs;
038    
039      public int loc;
040    
041    
042      public final int getTag() { return tag; }
043    
044      //@ public represents startLoc <- loc;
045      public /*@ pure @*/ int getStartLoc() { return loc; }
046      /*@ also
047        @ public normal_behavior
048        @ ensures \result == exprs.elementAt(exprs.size()-1).getEndLoc();
049        @*/
050      public /*@ pure @*/ int getEndLoc() { return exprs.elementAt(exprs.size()-1).getEndLoc(); }
051    
052    
053    // Generated boilerplate constructors:
054    
055      //@ ensures this.tag == tag;
056      //@ ensures this.target == target;
057      //@ ensures this.exprs == exprs;
058      //@ ensures this.loc == loc;
059      protected DependsPragma(int tag, /*@ non_null @*/ Expr target, /*@ non_null @*/ ExprVec exprs, int loc) {
060         this.tag = tag;
061         this.target = target;
062         this.exprs = exprs;
063         this.loc = loc;
064      }
065    
066    // Generated boilerplate methods:
067    
068      public final int childCount() {
069         int sz = 0;
070         if (this.exprs != null) sz += this.exprs.size();
071         return sz + 1;
072      }
073    
074      public final Object childAt(int index) {
075              /*throws IndexOutOfBoundsException*/
076         if (index < 0)
077            throw new IndexOutOfBoundsException("AST child index " + index);
078         int indexPre = index;
079    
080         int sz;
081    
082         if (index == 0) return this.target;
083         else index--;
084    
085         sz = (this.exprs == null ? 0 : this.exprs.size());
086         if (0 <= index && index < sz)
087            return this.exprs.elementAt(index);
088         else index -= sz;
089    
090         throw new IndexOutOfBoundsException("AST child index " + indexPre);
091      }   //@ nowarn Exception;
092    
093      public final /*@non_null*/String toString() {
094         return "[DependsPragma"
095            + " tag = " + this.tag
096            + " target = " + this.target
097            + " exprs = " + this.exprs
098            + " loc = " + this.loc
099            + "]";
100      }
101    
102      public final void accept(javafe.ast.Visitor v) { 
103        if (v instanceof Visitor) ((Visitor)v).visitDependsPragma(this);
104      }
105    
106      public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
107        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitDependsPragma(this, o); else return null;
108      }
109    
110      public void check() {
111         this.target.check();
112         for(int i = 0; i < this.exprs.size(); i++)
113            this.exprs.elementAt(i).check();
114      }
115    
116      //@ ensures \result != null;
117      public static DependsPragma make(int tag, /*@ non_null @*/ Expr target, /*@ non_null @*/ ExprVec exprs, int loc) {
118         DependsPragma result = new DependsPragma(tag, target, exprs, loc);
119         return result;
120      }
121    }