001    /* Copyright 2000, 2001, Compaq Computer Corporation */
002    
003    /* IF THIS IS A JAVA FILE, DO NOT EDIT IT!  
004    
005       Most Java files in this directory which are part of the Javafe AST
006       are automatically generated using the astgen comment (see
007       ESCTools/Javafe/astgen) from the input file 'hierarchy.h'.  If you
008       wish to modify AST classes or introduce new ones, modify
009       'hierarchy.j.'
010     */
011    
012    package escjava.ast;
013    
014    import java.util.Hashtable;
015    import java.util.Set;
016    import java.util.ArrayList;
017    
018    import javafe.ast.*;
019    import javafe.util.Assert;
020    import javafe.util.Location;
021    import escjava.ParsedRoutineSpecs;
022    
023    // Convention: unless otherwise noted, integer fields named "loc" refer
024    // to the location of the first character of the syntactic unit
025    
026    //# TagBase javafe.tc.TagConstants.LAST_TAG + 1
027    //# VisitorRoot javafe.ast.Visitor
028    
029    
030    public class Call extends GuardedCmd
031    {
032      public /*@ non_null @*/ ExprVec args;
033    
034      public int scall;
035    
036      public int ecall;
037    
038    
039      public boolean inlined;
040    
041    
042      // This is a backedge, so it can't be a child:
043      //@ invariant rd != null;
044      public RoutineDecl rd;
045    
046      public Spec spec;
047      public GuardedCmd desugared;
048    
049      public int getStartLoc() { return scall; }
050      public int getEndLoc() { return ecall; }
051    
052    
053    // Generated boilerplate constructors:
054    
055      /**
056       * Construct a raw Call whose class invariant(s) have not
057       * yet been established.  It is the caller's job to
058       * initialize the returned node's fields so that any
059       * class invariants hold.
060       */
061      //@ requires I_will_establish_invariants_afterwards;
062      protected Call() {}    //@ nowarn Invariant,NonNullInit;
063    
064    
065    // Generated boilerplate methods:
066    
067      public final int childCount() {
068         int sz = 0;
069         if (this.args != null) sz += this.args.size();
070         return sz + 0;
071      }
072    
073      public final Object childAt(int index) {
074              /*throws IndexOutOfBoundsException*/
075         if (index < 0)
076            throw new IndexOutOfBoundsException("AST child index " + index);
077         int indexPre = index;
078    
079         int sz;
080    
081         sz = (this.args == null ? 0 : this.args.size());
082         if (0 <= index && index < sz)
083            return this.args.elementAt(index);
084         else index -= sz;
085    
086         throw new IndexOutOfBoundsException("AST child index " + indexPre);
087      }   //@ nowarn Exception;
088    
089      public final String toString() {
090         return "[Call"
091            + " args = " + this.args
092            + " scall = " + this.scall
093            + " ecall = " + this.ecall
094            + " inlined = " + this.inlined
095            + "]";
096      }
097    
098      public final int getTag() {
099         return TagConstants.CALL;
100      }
101    
102      public final void accept(javafe.ast.Visitor v) { 
103        if (v instanceof Visitor) ((Visitor)v).visitCall(this);
104      }
105    
106      public final Object accept(javafe.ast.VisitorArgResult v, Object o) { 
107        if (v instanceof VisitorArgResult) return ((VisitorArgResult)v).visitCall(this, o); else return null;
108      }
109    
110      public void check() {
111         super.check();
112         for(int i = 0; i < this.args.size(); i++)
113            this.args.elementAt(i).check();
114      }
115    
116      //@ ensures \result != null;
117      public static Call make(/*@ non_null @*/ ExprVec args, int scall, int ecall, boolean inlined) {
118         //@ set I_will_establish_invariants_afterwards = true;
119         Call result = new Call();
120         result.args = args;
121         result.scall = scall;
122         result.ecall = ecall;
123         result.inlined = inlined;
124         return result;
125      }
126    }