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