Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

InfoAnalysis.java

00001 package edu.ksu.cis.bandera.pdgslicer;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998, 1999   Hongjun Zheng (zheng@cis.ksu.edu)      *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * This work was done as a project in the SAnToS Laboratory,         *
00009  * Department of Computing and Information Sciences, Kansas State    *
00010  * University, USA (http://www.cis.ksu.edu/santos).                  *
00011  * It is understood that any modification not identified as such is  *
00012  * not covered by the preceding statement.                           *
00013  *                                                                   *
00014  * This work is free software; you can redistribute it and/or        *
00015  * modify it under the terms of the GNU Library General Public       *
00016  * License as published by the Free Software Foundation; either      *
00017  * version 2 of the License, or (at your option) any later version.  *
00018  *                                                                   *
00019  * This work is distributed in the hope that it will be useful,      *
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00022  * Library General Public License for more details.                  *
00023  *                                                                   *
00024  * You should have received a copy of the GNU Library General Public *
00025  * License along with this toolkit; if not, write to the             *
00026  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00027  * Boston, MA  02111-1307, USA.                                      *
00028  *                                                                   *
00029  * Java is a trademark of Sun Microsystems, Inc.                     *
00030  *                                                                   *
00031  * To submit a bug report, send a comment, or get the latest news on *
00032  * this project and other SAnToS projects, please visit the web-site *
00033  *                http://www.cis.ksu.edu/santos                      *
00034  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00035 
00036 
00037 import ca.mcgill.sable.util.*;
00038 import ca.mcgill.sable.soot.*;
00039 import ca.mcgill.sable.soot.jimple.*;
00040 
00041 /**
00042 * This class is for
00043 * <ul>
00044 * <li> building up {@link MethodInfo MethodInfo} for
00045 * each method in one class;
00046 * <li> recognizing all native methods;
00047 * <li> filling {@link SootMethodInfoMap SootMethodInfoMap}.
00048 * </ul>
00049 */
00050 
00051 public class InfoAnalysis {
00052     /**
00053     * a list of {@link MethodInfo MethodInfo} for all methods in the class.
00054     */
00055     private List methodsInClass = new ArrayList();
00056     /**
00057     * a set of {@link SootMethod SootMethods} that are native methods.
00058     */ 
00059     protected static Set nativeMdSig;
00060 /**
00061 * Analyse one class, and build up {@link MethodInfo MethodInfo} for each method in
00062 * the class.
00063 * @param sootClass class need to be analysed.
00064 */
00065 public InfoAnalysis(SootClass sootClass) {
00066     List methodsList = sootClass.getMethods();
00067     SootMethod sootMethod;
00068 
00069     //get native method signatures in the class sootClass
00070     {
00071         //InfoAnalysis.nativeMdSig = new ArraySet();
00072         for (Iterator nt = methodsList.iterator(); nt.hasNext();) {
00073             sootMethod = (SootMethod) nt.next();
00074             int modifiers = sootMethod.getModifiers();
00075             if (Modifier.isNative(modifiers)) {
00076                 InfoAnalysis.nativeMdSig.add(sootMethod);
00077             }
00078         }
00079     }
00080     for (Iterator mit = methodsList.iterator(); mit.hasNext();) {
00081         sootMethod = (SootMethod) mit.next();
00082         if (InfoAnalysis.nativeMdSig.contains(sootMethod)) {
00083             System.out.println("Method " + sootMethod.getName() + " is a native method");
00084             continue;
00085         }
00086         if (!Slicer.reachableMethods.contains(sootMethod))
00087             continue;
00088         IndexMaps indexMaps = new IndexMaps(sootMethod);
00089         MethodInfo methodInfo = new MethodInfo();
00090         methodInfo.stmtList = indexMaps.getStmtList();
00091         methodInfo.originalStmtList = indexMaps.getOriginalStmtList();
00092         methodInfo.sootClass = sootClass;
00093         methodInfo.sootMethod = sootMethod;
00094         methodInfo.indexMaps = indexMaps;
00095         methodInfo.methodPDG = null;
00096         methodInfo.REF = indexMaps.getREF();
00097         methodInfo.MOD = indexMaps.getMOD();
00098         methodInfo.sCriterion = null;
00099         methodInfo.sliceSet = null;
00100         methodInfo.increCriterion = null;
00101         methodInfo.possibleReadyDependCallSite = new ArraySet();
00102         methodInfo.removedStmt = new ArraySet();
00103         methodsInClass.add(methodInfo);
00104         Slicer.sootMethodInfoMap.put(sootMethod, methodInfo);
00105     }
00106 }
00107 /**
00108 * Get a list of {@link MethodInfo MethodInfo} for each method in the class.
00109 */
00110 public List getMethodsInfoList()
00111     {
00112       return methodsInClass;
00113     }
00114 }

Generated at Thu Feb 7 06:46:41 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001