001 package escjava.vcGeneration;
002
003 import java.util.Vector;
004
005
006 /**
007 * The class used to represent method calls for the new Vc gen tree.
008 * @version 14/11/2005
009 */
010 public class TMethodCall extends TFunction {
011 private VariableInfo name;
012 private Vector argTypes = new Vector();
013
014
015 /**
016 * The vector containing all the method names (in forms of String).
017 */
018 public static Vector methNames = new Vector();
019 /**
020 * The vector containing the definition of the methods. The
021 * definition is fetched following this pattern, for a method
022 * called strMethName (a String).
023 * <code>
024 * methDefs.get({@link Vector#indexOf(java.lang.Object) methName.indexOf(strMethName)})
025 * </code>
026 */
027 public static Vector methDefs = new Vector();
028
029
030 /**
031 * @see TNode#accept(TVisitor)
032 * @param args
033 */
034 public void accept(/*@ non_null @*/ TVisitor v) throws java.io.IOException{
035 v.visitTMethodCall(this);
036 }
037
038
039 /**
040 * Construct a method call.
041 * @param name The name of the method called.
042 */
043 public TMethodCall(/*@ non_null @*/ String name) {
044 this.name = new VariableInfo(name, new TypeInfo("pure method"));
045 if(!methNames.contains(this.name)) {
046 methNames.add(this.name);
047 methDefs.add(this);
048 }
049 }
050
051
052 /**
053 * return the VariableInfo associated with the method name,
054 * of interest for the return type of the method.
055 * @return The variable info object associated with the method.
056 */
057 public VariableInfo getName() {
058 return name;
059 }
060
061 /**
062 * @see TFunction#typeTree()
063 */
064 protected void typeTree(){
065 // in case of double typing...
066 if(argTypes.size() > 0)
067 argTypes.clear();
068 /*
069 * Semantic control : for now we determine the type of the pure method
070 */
071 for(int i = 0; i < sons.size(); i++){
072 TNode nodeTemp = getChildAt(i);
073 nodeTemp.typeTree();
074 // does not work at all: we only get the same empty type -- julien
075 argTypes.add(nodeTemp.type);
076 }
077
078 }
079 /**
080 * Returns a vector containing the types from the different arguments of
081 * the MethodCall. The pure method has the following signature: <code>elem(1) -> elem(1) -> ... -> {@link TNode#type this.type}</code>
082 * @return A vector containing elements from the TypeInfo class.
083 */
084 public Vector getArgType() {
085 return argTypes;
086 }
087 protected void setType(TypeInfo type, boolean sure){
088 this.type = type;
089 }
090 }