01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 1997-1999 Raja Vallee-Rai
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the
16: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17: * Boston, MA 02111-1307, USA.
18: */
19:
20: package soot.jbco.bafTransformations;
21:
22: import java.util.*;
23:
24: import soot.Body;
25: import soot.BodyTransformer;
26: import soot.baf.GotoInst;
27: import soot.baf.JSRInst;
28: import soot.baf.TargetArgInst;
29: import soot.jbco.IJbcoTransform;
30:
31: public class BAFCounter extends BodyTransformer implements
32: IJbcoTransform {
33:
34: static int count = 0;
35: public static String dependancies[] = new String[] { "bb.jbco_counter" };
36:
37: public String[] getDependancies() {
38: return dependancies;
39: }
40:
41: public static String name = "bb.jbco_counter";
42:
43: public String getName() {
44: return name;
45: }
46:
47: public void outputSummary() {
48: out.println("Count: " + count);
49: }
50:
51: protected void internalTransform(Body b, String phaseName,
52: Map options) {
53: Iterator it = b.getUnits().snapshotIterator();
54: while (it.hasNext()) {
55: Object u = it.next();
56: if (u instanceof TargetArgInst && !(u instanceof GotoInst)
57: && !(u instanceof JSRInst))
58: count++;
59: }
60: }
61: }
|