boomerang.staticfields.SingletonStaticFieldStrategy Maven / Gradle / Ivy
package boomerang.staticfields;
import boomerang.scene.ControlFlowGraph.Edge;
import boomerang.scene.Field;
import boomerang.scene.Statement;
import boomerang.scene.StaticFieldVal;
import boomerang.scene.Val;
import boomerang.solver.AbstractBoomerangSolver;
import com.google.common.collect.Multimap;
import java.util.Set;
import sync.pds.solver.nodes.Node;
import wpds.impl.Weight;
import wpds.interfaces.State;
public class SingletonStaticFieldStrategy implements StaticFieldStrategy {
private Multimap fieldStoreStatements;
private Multimap fieldLoadStatements;
private AbstractBoomerangSolver solver;
public SingletonStaticFieldStrategy(
AbstractBoomerangSolver solver,
Multimap fieldLoadStatements,
Multimap fieldStoreStatements) {
this.solver = solver;
this.fieldStoreStatements = fieldStoreStatements;
this.fieldLoadStatements = fieldLoadStatements;
}
@Override
public void handleForward(
Edge storeStmt, Val storedVal, StaticFieldVal staticVal, Set out) {
for (Statement matchingStore : fieldLoadStatements.get(staticVal.field())) {
if (matchingStore.isAssign()) {
for (Statement succ :
matchingStore.getMethod().getControlFlowGraph().getSuccsOf(matchingStore)) {
solver.processNormal(
new Node<>(storeStmt, storedVal),
new Node<>(new Edge(matchingStore, succ), matchingStore.getLeftOp()));
}
}
}
}
@Override
public void handleBackward(
Edge loadStatement, Val loadedVal, StaticFieldVal staticVal, Set out) {
for (Statement matchingStore : fieldStoreStatements.get(staticVal.field())) {
for (Statement pred :
matchingStore.getMethod().getControlFlowGraph().getPredsOf(matchingStore)) {
solver.processNormal(
new Node<>(loadStatement, loadedVal),
new Node<>(new Edge(pred, matchingStore), matchingStore.getRightOp()));
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy