KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > JimpleBodyPack


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2003 Ondrej Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * 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 /*
21  * Modified by the Sable Research Group and others 1997-1999.
22  * See the 'credits' file distributed with Soot for the complete list of
23  * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24  */

25
26
27 package soot;
28 import soot.options.*;
29
30 import soot.jimple.*;
31 import java.util.*;
32 import soot.toolkits.scalar.*;
33 import soot.jimple.toolkits.scalar.*;
34 import soot.jimple.toolkits.typing.*;
35 import soot.jimple.toolkits.base.*;
36 import soot.options.JBOptions;
37
38
39 /** A wrapper object for a pack of optimizations.
40  * Provides chain-like operations, except that the key is the phase name.
41  * This is a specific one for the very messy jb phase. */

42 public class JimpleBodyPack extends BodyPack
43 {
44     public JimpleBodyPack() {
45         super("jb");
46     }
47
48
49     /** Applies the transformations corresponding to the given options. */
50     private void applyPhaseOptions(JimpleBody b, Map opts)
51     {
52         JBOptions options = new JBOptions( opts );
53         
54         if(options.use_original_names())
55             PhaseOptions.v().setPhaseOptionIfUnset( "jb.lns", "only-stack-locals");
56         
57         if(Options.v().time()) Timers.v().splitTimer.start();
58
59         PackManager.v().getTransform( "jb.tt" ).apply( b );
60
61         PackManager.v().getTransform( "jb.ls" ).apply( b );
62
63         if(Options.v().time()) Timers.v().splitTimer.end();
64
65         PackManager.v().getTransform( "jb.a" ).apply( b );
66         PackManager.v().getTransform( "jb.ule" ).apply( b );
67
68         if(Options.v().time()) Timers.v().assignTimer.start();
69
70         PackManager.v().getTransform( "jb.tr" ).apply( b );
71         
72         if(Options.v().time()) Timers.v().assignTimer.end();
73
74         if(options.use_original_names())
75         {
76             PackManager.v().getTransform( "jb.ulp" ).apply( b );
77         }
78         PackManager.v().getTransform( "jb.lns" ).apply( b );
79         PackManager.v().getTransform( "jb.cp" ).apply( b );
80         PackManager.v().getTransform( "jb.dae" ).apply( b );
81         PackManager.v().getTransform( "jb.cp-ule" ).apply( b );
82         PackManager.v().getTransform( "jb.lp" ).apply( b );
83         PackManager.v().getTransform( "jb.ne" ).apply( b );
84         PackManager.v().getTransform( "jb.uce" ).apply( b );
85                     
86         if(Options.v().time())
87             Timers.v().stmtCount += b.getUnits().size();
88     }
89
90
91     protected void internalApply(Body b)
92     {
93         applyPhaseOptions( (JimpleBody) b,
94                 PhaseOptions.v().getPhaseOptions( getPhaseName() ) );
95     }
96 }
97
Popular Tags