package st; import java.util.ArrayList; public class MethodInstance extends AbstractInstance { private ArrayList args; // the list of arguments private ArrayList lvars; // the list of local variables protected ClassInstance par_cls; // the surrounding class private ClassInstance rtrn; // the returned type public MethodInstance(String name, ClassInstance rtrn, ClassInstance par_cls) { super(name, TypeEnum.method); this.lvars = new ArrayList<>(); this.args = new ArrayList<>(); this.par_cls = par_cls; this.rtrn = rtrn; } public boolean equals(Object other) { MethodInstance o; return (other instanceof MethodInstance && ((o = (MethodInstance) other).getName() == this.getName())); } public ArrayList getArguments() { return this.args; } public ArrayList getLocals() { return this.lvars; } public ClassInstance getReturn() { return this.rtrn; } protected void addArgument(TypeInstance arg) { this.args.add(arg); this.lvars.add(arg); } protected void addLocal(TypeInstance lvar) { this.lvars.add(lvar); } public void addParentClass(ClassInstance par_cls) { this.par_cls = par_cls; } public ClassInstance getParentClass() { return this.par_cls; } }