2 import IR.Tree.Modifiers;
3 import IR.Tree.ExpressionNode;
4 import java.util.Vector;
9 * represents a symbol in the language (var name, function name, etc).
12 public class MethodDescriptor extends Descriptor {
14 protected Modifiers modifier;
15 protected TypeDescriptor returntype;
16 protected String identifier;
17 protected Vector param_name;
18 protected Vector param_type;
19 protected SymbolTable paramtable;
21 public MethodDescriptor(Modifiers m, TypeDescriptor rt, String identifier) {
25 this.identifier=identifier;
26 this.safename = "__" + name + "__";
27 this.uniqueid=count++;
28 param_name=new Vector();
29 param_type=new Vector();
30 paramtable=new SymbolTable();
32 public TypeDescriptor getReturnType() {
36 public SymbolTable getParameterTable() {
40 public void addParameter(TypeDescriptor type, String paramname) {
41 param_name.add(paramname);
43 if (paramtable.getFromSameScope(paramname)!=null) {
44 throw new Error("Parameter "+paramname+" already defined");
46 paramtable.add(paramname,type);
49 public int numParameters() {
50 return param_name.size();
53 public String getParamName(int i) {
54 return (String) param_name.get(i);
57 public TypeDescriptor getParamType(int i) {
58 return (TypeDescriptor) param_type.get(i);
61 public String toString() {
62 String st=modifier.toString()+returntype.toString()+" "+identifier+"(";
63 for(int i=0;i<param_type.size();i++) {
64 st+=param_type.get(i).toString()+" "+param_name.get(i).toString();
65 if ((i+1)!=param_type.size())