01: package dk.brics.soot.intermediate.representation;
02:
03: import java.util.HashSet;
04: import java.util.LinkedList;
05: import java.util.List;
06: import java.util.Set;
07:
08: import soot.SootMethod;
09:
10: public class Method {
11:
12: private String name = "";
13: private Variable[] params;
14:
15: private List<Statement> sl;
16: private Set<Return> rs;
17: private List<MethodCall> sites;
18: private MethodHead entry;
19:
20: public Method(String name, Variable[] params) {
21: this .name = name;
22: this .params = params;
23: sl = new LinkedList<Statement>();
24: rs = new HashSet<Return>();
25: sites = new LinkedList<MethodCall>();
26: entry = new MethodHead(params);
27: }
28:
29: public MethodHead getEntry() {
30: return this .entry;
31: }
32:
33: /** Adds the given statement to the list of statements for this method.
34: * @param s the statement to add.
35: */
36: public void addStatement(Statement s) {
37: s.setIndex(sl.size());
38: sl.add(s);
39: s.setMethod(this );
40: if (s instanceof Return) {
41: rs.add((Return) s);
42: }
43: if (s instanceof MethodCall) {
44: MethodCall mc = (MethodCall) s;
45: mc.getTarget().sites.add(mc);
46: }
47: }
48:
49: public String getName() {
50: return name;
51: }
52:
53: public String toString() {
54: String result = "";
55: for (Statement s : sl) {
56: result += s.toString() + "\n";
57: }
58: return result;
59: }
60: }
|