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.HashMap;
23: import java.util.Map;
24: import soot.jbco.*;
25: import soot.Body;
26: import soot.BodyTransformer;
27:
28: /**
29: * @author Michael Batchelder
30: *
31: * Created on 15-Jun-2006
32: */
33: public class BAFPrintout extends BodyTransformer implements
34: IJbcoTransform {
35:
36: private String name = "bb.printout";
37:
38: public void outputSummary() {
39: }
40:
41: public String[] getDependancies() {
42: return new String[0];
43: }
44:
45: public String getName() {
46: return name;
47: }
48:
49: static boolean stack = false;
50:
51: public BAFPrintout() {
52: }
53:
54: public BAFPrintout(String newname, boolean print_stack) {
55: name = newname;
56: stack = print_stack;
57: }
58:
59: protected void internalTransform(Body b, String phaseName,
60: Map options) {
61: //if (b.getMethod().getSignature().indexOf("run")<0) return;
62: System.out.println("\n" + b.getMethod().getSignature());
63:
64: if (stack) {
65: HashMap Stacks = null, b2j = soot.jbco.Main.methods2Baf2JLocals
66: .get(b.getMethod());
67:
68: try {
69: if (b2j == null)
70: Stacks = StackTypeHeightCalculator
71: .calculateStackHeights(b);
72: else
73: Stacks = StackTypeHeightCalculator
74: .calculateStackHeights(b, b2j);
75:
76: StackTypeHeightCalculator.printStack(b.getUnits(),
77: Stacks, true);
78: } catch (Exception exc) {
79: System.out
80: .println("\n**************Exception calculating height "
81: + exc
82: + ", printing plain bytecode now\n\n");
83: soot.jbco.util.Debugger.printUnits(b, " FINAL");
84: }
85: } else {
86: soot.jbco.util.Debugger.printUnits(b, " FINAL");
87: }
88: System.out.println();
89: }
90: }
|