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

TestDom.java

00001 package edu.ksu.cis.bandera.prog;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 1998-2001 SAnToS Laboratories (santos@cis.ksu.edu)  *
00006 
00007  * All rights reserved.                                              *
00008  *                                                                   *
00009  * This work was done as a project in the SAnToS Laboratory,         *
00010  * Department of Computing and Information Sciences, Kansas State    *
00011  * University, USA (http://www.cis.ksu.edu/santos).                  *
00012  * It is understood that any modification not identified as such is  *
00013  * not covered by the preceding statement.                           *
00014  *                                                                   *
00015  * This work is free software; you can redistribute it and/or        *
00016  * modify it under the terms of the GNU Library General Public       *
00017  * License as published by the Free Software Foundation; either      *
00018  * version 2 of the License, or (at your option) any later version.  *
00019  *                                                                   *
00020  * This work is distributed in the hope that it will be useful,      *
00021  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00022  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00023  * Library General Public License for more details.                  *
00024  *                                                                   *
00025  * You should have received a copy of the GNU Library General Public *
00026  * License along with this toolkit; if not, write to the             *
00027  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00028  * Boston, MA  02111-1307, USA.                                      *
00029  *                                                                   *
00030  * Java is a trademark of Sun Microsystems, Inc.                     *
00031  *                                                                   *
00032  * To submit a bug report, send a comment, or get the latest news on *
00033  * this project and other SAnToS projects, please visit the web-site *
00034  *                http://www.cis.ksu.edu/santos                      *
00035  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00036 import ca.mcgill.sable.util.*;
00037 import ca.mcgill.sable.soot.*;
00038 import ca.mcgill.sable.soot.jimple.*;
00039 
00040 import edu.ksu.cis.bandera.prog.DomAnalysis;
00041 import edu.ksu.cis.bandera.prog.PostdomAnalysis;
00042 import edu.ksu.cis.bandera.prog.BackEdgeAnalysis;
00043 
00044 public class TestDom
00045 {
00046   public static void main(String[] args)
00047     {
00048       SootClassManager cm = new SootClassManager();
00049       SootClass sClass = cm.getClass(args[0]);
00050       sClass.resolveIfNecessary();
00051       
00052       BuildAndStoreBody bd = 
00053     new BuildAndStoreBody(Jimple.v(), 
00054                   new StoredBody(ClassFile.v()), 
00055                   BuildJimpleBodyOption.NO_PACKING);
00056       
00057       Iterator methodIt = sClass.getMethods().iterator();
00058       
00059       while(methodIt.hasNext())
00060     {
00061       SootMethod m = (SootMethod) methodIt.next();
00062       bd.resolveFor(m);
00063       JimpleBody body = (JimpleBody) new StoredBody(Jimple.v()).resolveFor(m);
00064       StmtList stmtList = body.getStmtList();
00065       CompleteStmtGraph stmtGraph = new CompleteStmtGraph(stmtList);
00066 
00067       //dominators
00068       DomAnalysis da = new DomAnalysis(stmtList, stmtGraph);
00069       Map domMap = da.stmtToDominatorsMap();
00070       System.out.println("\n dominators map for method : " + m.getName());
00071       System.out.println(domMap);
00072 
00073       //immediate dominator
00074       Map immdomMap = da.stmtToImmediateDom();
00075       System.out.println("\n immediate dominators map for method : " + m.getName());
00076       System.out.println(immdomMap);
00077       
00078       //postdominators
00079       PostdomAnalysis pda = new PostdomAnalysis(stmtList, stmtGraph);
00080       Map postdomMap = pda.stmtToPostdominatorsMap();
00081       System.out.println("\n post-dominators map for method : " + m.getName());
00082       System.out.println(postdomMap);
00083 
00084       //immediate postdominator
00085       Map immpostdomMap = pda.stmtToImmediatePostdom();
00086       System.out.println("\n immediate post-dominators map for method : " + m.getName());
00087       System.out.println(immpostdomMap);
00088 
00089 
00090       //back edge analysis
00091       BackEdgeAnalysis bea = new BackEdgeAnalysis(stmtList, stmtGraph);
00092       List edgeList = bea.backEdgeList();
00093       System.out.println("\n back edge list for method: " + m.getName());
00094       System.out.println(edgeList);
00095     }
00096     }
00097 }

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