Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /* Soot - a J*va Optimization Framework
  * Copyright (C) 2002 Ondrej Lhotak
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */
package soot.jimple;
import java.util.*;
import soot.*;
import java.io.*;

Dumps the reaching types of each local variable to a file in a format that can be easily compared with results of other analyses, such as VTA.

Author(s):
Ondrej Lhotak
public class ReachingTypeDumper {
    public ReachingTypeDumperPointsToAnalysis paString output_dir ) {
        this. = pa;
        this. = output_dir;
    }
    public void dump() {
        try {
            PrintWriter file = new PrintWriter(
                new FileOutputStreamnew File("types") ) );
            forIterator it = Scene.v().getApplicationClasses().iterator();
                    it.hasNext(); ) {
                handleClassfile, (SootClassit.next() );
            }
            forIterator it = Scene.v().getLibraryClasses().iterator();
                    it.hasNext(); ) {
                handleClassfile, (SootClassit.next() );
            }
            file.close();
        } catchIOException e ) {
            throw new RuntimeException"Couldn't dump reaching types."+e );
        }
    }
    /* End of public methods. */
    /* End of package methods. */
    protected PointsToAnalysis pa;
    protected String output_dir;
    protected void handleClassPrintWriter outSootClass c ) {
        forIterator mIt = c.methodIterator(); mIt.hasNext(); ) {
            final SootMethod m = (SootMethodmIt.next();
            if( !m.isConcrete() ) continue;
            Body b = m.retrieveActiveBody();
            TreeSet sortedLocals = new TreeSetnew StringComparator() );
            sortedLocals.addAllb.getLocals() );
            forIterator lIt = sortedLocals.iterator(); lIt.hasNext(); ) {
                final Local l = (LocallIt.next();
                out.println"V "+m+l );
                ifl.getType() instanceof RefLikeType ) {
                    Set types = .reachingObjectsl ).possibleTypes();
                    TreeSet sortedTypes = new TreeSetnew StringComparator() );
                    sortedTypes.addAlltypes );
                    forIterator tIt = sortedTypes.iterator(); tIt.hasNext(); ) {
                        out.println"T "+tIt.next() );
                    }
                }
            }
        }
    }
    class StringComparator implements Comparator {
        public int compareObject o1Object o2 ) {
            return o1.toString().compareToo2.toString() );
        }
    }
New to GrepCode? Check out our FAQ X