soot.jimple.toolkits.infoflow.SimpleMethodLocalObjectsAnalysis Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of robovm-soot Show documentation
Show all versions of robovm-soot Show documentation
RoboVM fork of Soot - A Java optimization framework
package soot.jimple.toolkits.infoflow;
import soot.*;
import java.util.*;
import soot.toolkits.graph.*;
// SimpleMethodLocalObjectsAnalysis written by Richard L. Halpert, 2007-02-23
// Finds objects that are local to the scope of the LocalObjectsScopeAnalysis
// that is provided.
// This is a specialized version of SimpleMethodInfoFlowAnalysis, in which the data
// source is the abstract "shared" data source.
public class SimpleMethodLocalObjectsAnalysis extends SimpleMethodInfoFlowAnalysis
{
public static int mlocounter = 0;
public SimpleMethodLocalObjectsAnalysis(UnitGraph g, ClassLocalObjectsAnalysis cloa, InfoFlowAnalysis dfa)
{
super(g, dfa, true, true); // special version doesn't run analysis yet
mlocounter++;
printMessages = false;
SootMethod method = g.getBody().getMethod();
AbstractDataSource sharedDataSource = new AbstractDataSource(new String("SHARED"));
// Add a source for every parameter that is shared
for(int i = 0; i < method.getParameterCount(); i++) // no need to worry about return value...
{
EquivalentValue paramEqVal = InfoFlowAnalysis.getNodeForParameterRef(method, i);
if(!cloa.parameterIsLocal(method, paramEqVal))
{
addToEntryInitialFlow(sharedDataSource, paramEqVal.getValue());
addToNewInitialFlow(sharedDataSource, paramEqVal.getValue());
}
}
for (SootField sf : cloa.getSharedFields()) {
EquivalentValue fieldRefEqVal = InfoFlowAnalysis.getNodeForFieldRef(method, sf);
addToEntryInitialFlow(sharedDataSource, fieldRefEqVal.getValue());
addToNewInitialFlow(sharedDataSource, fieldRefEqVal.getValue());
}
if(printMessages)
G.v().out.println("----- STARTING SHARED/LOCAL ANALYSIS FOR " + g.getBody().getMethod() + " -----");
doFlowInsensitiveAnalysis();
if(printMessages)
G.v().out.println("----- ENDING SHARED/LOCAL ANALYSIS FOR " + g.getBody().getMethod() + " -----");
}
public SimpleMethodLocalObjectsAnalysis(UnitGraph g, CallLocalityContext context, InfoFlowAnalysis dfa)
{
super(g, dfa, true, true); // special version doesn't run analysis yet
mlocounter++;
printMessages = false;
SootMethod method = g.getBody().getMethod();
AbstractDataSource sharedDataSource = new AbstractDataSource(new String("SHARED"));
List