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    /**
024     * Represents a Name occuring before an argument list.
025     * Is created by the parser, and then resolved to either an
026     * InstanceMethodAccess or ClassMethodAccess by the name resolution code.
027     *
028     * <p> Thus for the method call "x.y()", the "x.y" part is initially 
029     * represented as a MethodName, 
030     * and then resolved to a InstanceMethodAccess if "x" is a variable, 
031     * or resolved to a ClassMethodAccess if "x" is a type name.
032     */
033    
034    public class AmbiguousMethodInvocation extends Expr
035    {
036      public /*@ non_null @*/ Name name;
037    
038      public TypeModifierPragmaVec tmodifiers;
039    
040      //@ invariant locOpenParen != javafe.util.Location.NULL;
041      public int locOpenParen;
042    
043      public /*@ non_null @*/ ExprVec args;
044    
045    
046      //@ public represents startLoc <- name.getStartLoc();
047      public /*@ pure @*/ int getStartLoc() { return name.getStartLoc(); }
048    
049      /*@ also public normal_behavior
050        @ ensures \result == (args.size() < 1 ?
051        @           name.getEndLoc() : args.elementAt(args.size()-1).getEndLoc());
052        @*/
053      public /*@ pure @*/ int getEndLoc() { 
054        if (args.size()<1)
055          return name.getEndLoc();
056    
057        return args.elementAt(args.size()-1).getEndLoc();
058      }
059    
060    
061    // Generated boilerplate constructors:
062    
063      //@ ensures this.name == name;
064      //@ ensures this.tmodifiers == tmodifiers;
065      //@ ensures this.locOpenParen == locOpenParen;
066      //@ ensures this.args == args;
067      protected AmbiguousMethodInvocation(/*@ non_null @*/ Name name, TypeModifierPragmaVec tmodifiers, int locOpenParen, /*@ non_null @*/ ExprVec args) {
068         super();
069         this.name = name;
070         this.tmodifiers = tmodifiers;
071         this.locOpenParen = locOpenParen;
072         this.args = args;
073      }
074    
075    // Generated boilerplate methods:
076    
077      public final int childCount() {
078         int sz = 0;
079         if (this.tmodifiers != null) sz += this.tmodifiers.size();
080         if (this.args != null) sz += this.args.size();
081         return sz + 1;
082      }
083    
084      public final Object childAt(int index) {
085              /*throws IndexOutOfBoundsException*/
086         if (index < 0)
087            throw new IndexOutOfBoundsException("AST child index " + index);
088         int indexPre = index;
089    
090         int sz;
091    
092         if (index == 0) return this.name;
093         else index--;
094    
095         sz = (this.tmodifiers == null ? 0 : this.tmodifiers.size());
096         if (0 <= index && index < sz)
097            return this.tmodifiers.elementAt(index);
098         else index -= sz;
099    
100         sz = (this.args == null ? 0 : this.args.size());
101         if (0 <= index && index < sz)
102            return this.args.elementAt(index);
103         else index -= sz;
104    
105         throw new IndexOutOfBoundsException("AST child index " + indexPre);
106      }   //@ nowarn Exception;
107    
108      public final /*@non_null*/String toString() {
109         return "[AmbiguousMethodInvocation"
110            + " name = " + this.name
111            + " tmodifiers = " + this.tmodifiers
112            + " locOpenParen = " + this.locOpenParen
113            + " args = " + this.args
114            + "]";
115      }
116    
117      public final int getTag() {
118         return TagConstants.AMBIGUOUSMETHODINVOCATION;
119      }
120    
121      public final void accept(Visitor v) { v.visitAmbiguousMethodInvocation(this); }
122    
123      public final Object accept(VisitorArgResult v, Object o) {return v.visitAmbiguousMethodInvocation(this, o); }
124    
125      public void check() {
126         super.check();
127         this.name.check();
128         if (this.tmodifiers != null)
129            for(int i = 0; i < this.tmodifiers.size(); i++)
130               this.tmodifiers.elementAt(i).check();
131         for(int i = 0; i < this.args.size(); i++)
132            this.args.elementAt(i).check();
133      }
134    
135      //@ requires locOpenParen != javafe.util.Location.NULL;
136      //@ ensures \result != null;
137      public static AmbiguousMethodInvocation make(/*@ non_null @*/ Name name, TypeModifierPragmaVec tmodifiers, int locOpenParen, /*@ non_null @*/ ExprVec args) {
138         AmbiguousMethodInvocation result = new AmbiguousMethodInvocation(name, tmodifiers, locOpenParen, args);
139         return result;
140      }
141    }