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 javafe.ast; 013 014 import javafe.util.Assert; 015 import javafe.util.Location; 016 import javafe.util.ErrorSet; 017 018 // Convention: unless otherwise noted, integer fields named "loc" refer 019 // to the location of the first character of the syntactic unit 020 021 022 /** 023 * Represents a Name occuring before an argument list. 024 * Is created by the parser, and then resolved to either an 025 * InstanceMethodAccess or ClassMethodAccess by the name resolution code. 026 * 027 * <p> Thus for the method call "x.y()", the "x.y" part is initially 028 * represented as a MethodName, 029 * and then resolved to a InstanceMethodAccess if "x" is a variable, 030 * or resolved to a ClassMethodAccess if "x" is a type name. 031 */ 032 033 public class AmbiguousMethodInvocation extends Expr 034 { 035 public /*@ non_null @*/ Name name; 036 037 public TypeModifierPragmaVec tmodifiers; 038 039 //@ invariant locOpenParen != javafe.util.Location.NULL; 040 public int locOpenParen; 041 042 public /*@ non_null @*/ ExprVec args; 043 044 public int getStartLoc() { return name.getStartLoc(); } 045 public int getEndLoc() { 046 if (args.size()<1) 047 return name.getEndLoc(); 048 049 return args.elementAt(args.size()-1).getEndLoc(); 050 } 051 052 053 // Generated boilerplate constructors: 054 055 /** 056 * Construct a raw AmbiguousMethodInvocation 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 AmbiguousMethodInvocation() {} //@ nowarn Invariant,NonNullInit; 063 064 065 // Generated boilerplate methods: 066 067 public final int childCount() { 068 int sz = 0; 069 if (this.tmodifiers != null) sz += this.tmodifiers.size(); 070 if (this.args != null) sz += this.args.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.name; 083 else index--; 084 085 sz = (this.tmodifiers == null ? 0 : this.tmodifiers.size()); 086 if (0 <= index && index < sz) 087 return this.tmodifiers.elementAt(index); 088 else index -= sz; 089 090 sz = (this.args == null ? 0 : this.args.size()); 091 if (0 <= index && index < sz) 092 return this.args.elementAt(index); 093 else index -= sz; 094 095 throw new IndexOutOfBoundsException("AST child index " + indexPre); 096 } //@ nowarn Exception; 097 098 public final String toString() { 099 return "[AmbiguousMethodInvocation" 100 + " name = " + this.name 101 + " tmodifiers = " + this.tmodifiers 102 + " locOpenParen = " + this.locOpenParen 103 + " args = " + this.args 104 + "]"; 105 } 106 107 public final int getTag() { 108 return TagConstants.AMBIGUOUSMETHODINVOCATION; 109 } 110 111 public final void accept(Visitor v) { v.visitAmbiguousMethodInvocation(this); } 112 113 public final Object accept(VisitorArgResult v, Object o) {return v.visitAmbiguousMethodInvocation(this, o); } 114 115 public void check() { 116 super.check(); 117 this.name.check(); 118 if (this.tmodifiers != null) 119 for(int i = 0; i < this.tmodifiers.size(); i++) 120 this.tmodifiers.elementAt(i).check(); 121 for(int i = 0; i < this.args.size(); i++) 122 this.args.elementAt(i).check(); 123 } 124 125 //@ requires locOpenParen != javafe.util.Location.NULL; 126 //@ ensures \result != null; 127 public static AmbiguousMethodInvocation make(/*@ non_null @*/ Name name, TypeModifierPragmaVec tmodifiers, int locOpenParen, /*@ non_null @*/ ExprVec args) { 128 //@ set I_will_establish_invariants_afterwards = true; 129 AmbiguousMethodInvocation result = new AmbiguousMethodInvocation(); 130 result.name = name; 131 result.tmodifiers = tmodifiers; 132 result.locOpenParen = locOpenParen; 133 result.args = args; 134 return result; 135 } 136 }