blob: c2f978b9b3fa455374b17c355b81c36e554f4eda (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package st;
import java.util.ArrayList;
public class MethodInstance extends AbstractInstance {
private ArrayList<TypeInstance> args; // the list of arguments
private ArrayList<TypeInstance> lvars; // the list of local variables
protected ClassInstance par_cls; // the surrounding class
private TypeEnum rtrn; // the returned type
public MethodInstance(String name, TypeEnum 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() &&
o.getParentClass() == this.getParentClass()));
}
public ArrayList<TypeInstance> getArguments() {
return this.args;
}
public ArrayList<TypeInstance> getLocals() {
return this.lvars;
}
public TypeEnum 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;
}
}
|