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