
heros.fieldsens.FieldSensitiveIFDSSolver Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2014 Johannes Lerch, Johannes Spaeth.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* Contributors:
* Johannes Lerch, Johannes Spaeth - initial API and implementation
******************************************************************************/
package heros.fieldsens;
import heros.InterproceduralCFG;
import heros.utilities.DefaultValueMap;
import java.util.Map.Entry;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class FieldSensitiveIFDSSolver> {
protected static final Logger logger = LoggerFactory.getLogger(FieldSensitiveIFDSSolver.class);
private DefaultValueMap> methodAnalyzers = new DefaultValueMap>() {
@Override
protected MethodAnalyzer createItem(M key) {
return createMethodAnalyzer(key);
}
};
private IFDSTabulationProblem tabulationProblem;
protected Context context;
protected Debugger debugger;
private Scheduler scheduler;
public FieldSensitiveIFDSSolver(IFDSTabulationProblem tabulationProblem, FactMergeHandler factHandler, Debugger debugger, Scheduler scheduler) {
this.tabulationProblem = tabulationProblem;
this.scheduler = scheduler;
this.debugger = debugger == null ? new Debugger.NullDebugger() : debugger;
this.debugger.setICFG(tabulationProblem.interproceduralCFG());
context = initContext(tabulationProblem, factHandler);
submitInitialSeeds();
}
private Context initContext(IFDSTabulationProblem tabulationProblem, FactMergeHandler factHandler) {
return new Context(tabulationProblem, scheduler, factHandler) {
@Override
public MethodAnalyzer getAnalyzer(M method) {
if(method == null)
throw new IllegalArgumentException("Method must be not null");
return methodAnalyzers.getOrCreate(method);
}
};
}
protected MethodAnalyzer createMethodAnalyzer(M method) {
return new MethodAnalyzerImpl(method, context, debugger);
}
/**
* Schedules the processing of initial seeds, initiating the analysis.
*/
private void submitInitialSeeds() {
for(Entry> seed: tabulationProblem.initialSeeds().entrySet()) {
N startPoint = seed.getKey();
MethodAnalyzer analyzer = methodAnalyzers.getOrCreate(tabulationProblem.interproceduralCFG().getMethodOf(startPoint));
for(D val: seed.getValue()) {
analyzer.addInitialSeed(startPoint, val);
debugger.initialSeed(startPoint);
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy