01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 2003 Ondrej Lhotak
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.jimple.toolkits.callgraph;
21:
22: import soot.*;
23:
24: import java.util.*;
25: import soot.options.CGOptions;
26:
27: /** A radio pack implementation for the call graph pack that calls the
28: * intra-procedural clinit eliminator after the call graph has been built. */
29: public class CallGraphPack extends RadioScenePack {
30: public CallGraphPack(String name) {
31: super (name);
32: }
33:
34: protected void internalApply() {
35: CGOptions options = new CGOptions(PhaseOptions.v()
36: .getPhaseOptions(this ));
37: if (!options.implicit_entry()) {
38: Scene.v().setEntryPoints(EntryPoints.v().application());
39: }
40: if (options.all_reachable()) {
41: List<SootMethod> entryPoints = new ArrayList<SootMethod>();
42: entryPoints.addAll(EntryPoints.v().all());
43: entryPoints.addAll(EntryPoints.v()
44: .methodsOfApplicationClasses());
45: Scene.v().setEntryPoints(entryPoints);
46: }
47: super .internalApply();
48: ClinitElimTransformer trimmer = new ClinitElimTransformer();
49:
50: if (options.trim_clinit()) {
51: for (SootClass cl : Scene.v().getClasses(SootClass.BODIES)) {
52: for (Iterator mIt = cl.getMethods().iterator(); mIt
53: .hasNext();) {
54: final SootMethod m = (SootMethod) mIt.next();
55: if (m.isConcrete() && m.hasActiveBody()) {
56: trimmer.transform(m.getActiveBody());
57: }
58: }
59: }
60: }
61: }
62: }
|