Source Code Cross Referenced for BodyBuilder.java in  » Code-Analyzer » soot » soot » jbco » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » soot » soot.jbco.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Soot - a J*va Optimization Framework
002:         * Copyright (C) 1997-1999 Raja Vallee-Rai
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the
016:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017:         * Boston, MA 02111-1307, USA.
018:         */
019:
020:        package soot.jbco.util;
021:
022:        import java.util.ArrayList;
023:        import java.util.Iterator;
024:        import java.util.List;
025:
026:        import soot.Local;
027:        import soot.PatchingChain;
028:        import soot.RefType;
029:        import soot.SootClass;
030:        import soot.SootMethod;
031:        import soot.SootField;
032:        import soot.Trap;
033:        import soot.Type;
034:        import soot.Unit;
035:        import soot.baf.IfCmpEqInst;
036:        import soot.baf.IfCmpGeInst;
037:        import soot.baf.IfCmpGtInst;
038:        import soot.baf.IfCmpLeInst;
039:        import soot.baf.IfCmpLtInst;
040:        import soot.baf.IfCmpNeInst;
041:        import soot.baf.IfEqInst;
042:        import soot.baf.IfGeInst;
043:        import soot.baf.IfGtInst;
044:        import soot.baf.IfLeInst;
045:        import soot.baf.IfLtInst;
046:        import soot.baf.IfNeInst;
047:        import soot.baf.IfNonNullInst;
048:        import soot.baf.IfNullInst;
049:        import soot.jimple.Jimple;
050:        import soot.jimple.ThisRef;
051:        import soot.util.Chain;
052:
053:        /**
054:         * @author Michael Batchelder 
055:         * 
056:         * Created on 7-Feb-2006 
057:         */
058:        public class BodyBuilder {
059:
060:            public static boolean bodiesHaveBeenBuilt = false;
061:            public static boolean namesHaveBeenRetrieved = false;
062:            public static ArrayList<String> nameList = new ArrayList<String>();
063:
064:            public static void retrieveAllBodies() {
065:                if (bodiesHaveBeenBuilt)
066:                    return;
067:
068:                //  iterate through application classes, rename fields with junk
069:                Iterator it = soot.Scene.v().getApplicationClasses().iterator();
070:                while (it.hasNext()) {
071:                    SootClass c = (SootClass) it.next();
072:
073:                    Iterator mIt = c.getMethods().iterator();
074:                    while (mIt.hasNext()) {
075:                        SootMethod m = (SootMethod) mIt.next();
076:                        if (!m.isConcrete())
077:                            continue;
078:
079:                        if (!m.hasActiveBody())
080:                            m.retrieveActiveBody();
081:                    }
082:                }
083:
084:                bodiesHaveBeenBuilt = true;
085:            }
086:
087:            public static void retrieveAllNames() {
088:                if (namesHaveBeenRetrieved)
089:                    return;
090:
091:                //  iterate through application classes, rename fields with junk
092:                Iterator it = soot.Scene.v().getApplicationClasses().iterator();
093:                while (it.hasNext()) {
094:                    SootClass c = (SootClass) it.next();
095:                    nameList.add(c.getName());
096:
097:                    Iterator _it = c.getMethods().iterator();
098:                    while (_it.hasNext()) {
099:                        SootMethod m = (SootMethod) _it.next();
100:                        nameList.add(m.getName());
101:                    }
102:                    _it = c.getFields().iterator();
103:                    while (_it.hasNext()) {
104:                        SootField f = (SootField) _it.next();
105:                        nameList.add(f.getName());
106:                    }
107:                }
108:
109:                namesHaveBeenRetrieved = true;
110:            }
111:
112:            public static Local buildThisLocal(PatchingChain units, ThisRef tr,
113:                    Chain locals) {
114:                Local ths = Jimple.v().newLocal("ths", tr.getType());
115:                locals.add(ths);
116:                units.add(Jimple.v().newIdentityStmt(ths,
117:                        Jimple.v().newThisRef((RefType) tr.getType())));
118:                return ths;
119:            }
120:
121:            public static ArrayList buildParameterLocals(PatchingChain units,
122:                    Chain locals, List paramTypes) {
123:                ArrayList args = new ArrayList();
124:                for (int k = 0; k < paramTypes.size(); k++) {
125:                    Type type = (Type) paramTypes.get(k);
126:                    Local loc = Jimple.v().newLocal("l" + k, type);
127:                    locals.add(loc);
128:
129:                    units.add(Jimple.v().newIdentityStmt(loc,
130:                            Jimple.v().newParameterRef(type, k)));
131:
132:                    args.add(loc);
133:                }
134:                return args;
135:            }
136:
137:            public static void updateTraps(Unit oldu, Unit newu, Chain traps) {
138:                int size = traps.size();
139:                if (size == 0)
140:                    return;
141:
142:                Trap t = (Trap) traps.getFirst();
143:                do {
144:                    if (t.getBeginUnit() == oldu)
145:                        t.setBeginUnit(newu);
146:                    if (t.getEndUnit() == oldu)
147:                        t.setEndUnit(newu);
148:                    if (t.getHandlerUnit() == oldu)
149:                        t.setHandlerUnit(newu);
150:                } while ((--size > 0)
151:                        && (t = (Trap) traps.getSuccOf(t)) != null);
152:            }
153:
154:            public static boolean isExceptionCaughtAt(Chain units, Unit u,
155:                    Iterator trapsIt) {
156:                while (trapsIt.hasNext()) {
157:                    Trap t = (Trap) trapsIt.next();
158:                    Iterator it = units.iterator(t.getBeginUnit(), units
159:                            .getPredOf(t.getEndUnit()));
160:                    while (it.hasNext())
161:                        if (u.equals(it.next()))
162:                            return true;
163:                }
164:
165:                return false;
166:            }
167:
168:            public static int getIntegerNine() {
169:                int r1 = Rand.getInt(8388606) * 256;
170:
171:                int r2 = Rand.getInt(28) * 9;
172:
173:                if (r2 > 126)
174:                    r2 += 4;
175:
176:                return r1 + r2;
177:            }
178:
179:            public static boolean isBafIf(Unit u) {
180:                if (u instanceof  IfCmpEqInst || u instanceof  IfCmpGeInst
181:                        || u instanceof  IfCmpGtInst || u instanceof  IfCmpLeInst
182:                        || u instanceof  IfCmpLtInst || u instanceof  IfCmpNeInst
183:                        || u instanceof  IfEqInst || u instanceof  IfGeInst
184:                        || u instanceof  IfGtInst || u instanceof  IfLeInst
185:                        || u instanceof  IfLtInst || u instanceof  IfNeInst
186:                        || u instanceof  IfNonNullInst
187:                        || u instanceof  IfNullInst)
188:                    return true;
189:                return false;
190:            }
191:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.