![JAR search and dependency download from the Maven repository](/logo.png)
soot.jimple.toolkits.scalar.EqualLocalsAnalysis Maven / Gradle / Ivy
package soot.jimple.toolkits.scalar;
import soot.*;
import java.util.*;
import soot.toolkits.graph.*;
import soot.toolkits.scalar.*;
import soot.jimple.*;
// EqualLocalsAnalysis written by Richard L. Halpert, 2006-12-04
// Finds equal/equavalent/aliasing locals to a given local at a given statement, on demand
// The answer provided is occasionally suboptimal (but correct) in the event where
// a _re_definition of the given local causes it to become equal to existing locals.
public class EqualLocalsAnalysis extends ForwardFlowAnalysis
{
Local l;
Stmt s;
public EqualLocalsAnalysis(UnitGraph g)
{
super(g);
l = null;
s = null;
// analysis is done on-demand, not now
}
/** Returns a list of EquivalentValue wrapped Locals and Refs that must always be equal to l at s */
public List getCopiesOfAt(Local l, Stmt s)
{
this.l = l;
this.s = s;
doAnalysis();
List aliasList = new ArrayList();
aliasList.addAll(((FlowSet) getFlowBefore(s)).toList());
if(aliasList.contains(new EquivalentValue(l)))
return aliasList;
return new ArrayList();
}
protected void merge(Object in1, Object in2, Object out)
{
FlowSet inSet1 = (FlowSet) in1;
FlowSet inSet2 = (FlowSet) in2;
FlowSet outSet = (FlowSet) out;
inSet1.intersection(inSet2, outSet);
}
protected void flowThrough(Object inValue, Object unit,
Object outValue)
{
FlowSet in = (FlowSet) inValue;
FlowSet out = (FlowSet) outValue;
Stmt stmt = (Stmt) unit;
in.copy(out);
// get list of definitions at this unit
List newDefs = new ArrayList();
Iterator newDefBoxesIt = stmt.getDefBoxes().iterator();
while( newDefBoxesIt.hasNext() )
{
newDefs.add( new EquivalentValue( ((ValueBox) newDefBoxesIt.next()).getValue()) );
}
// If the local of interest was defined in this statement, then we must
// generate a new list of aliases to it starting here
if( newDefs.contains(new EquivalentValue(l)) )
{
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy