package accrue.analysis.antidep;

import polyglot.ast.ProcedureDecl;
import polyglot.types.SemanticException;
import accrue.AccrueExtensionInfo;
import accrue.analysis.AnalysisTopics;
import accrue.analysis.interprocanalysis.AnalysisUnit;
import accrue.analysis.interprocanalysis.AnalysisUtil;
import accrue.analysis.interprocanalysis.WorkQueue;
import accrue.analysis.interprocvarcontext.AnalysisFactoryVarContext;
import accrue.analysis.interprocvarcontext.VarContext;

public class AntiDepAnalysisFactory extends
        AnalysisFactoryVarContext<AntiDepAbsVal> {

    public static final String ANALYSIS_NAME = "accrue.analysis.antidep";

    /**
     * This analysis result stores a Set<EdgeIdentifier> pointing to definitions of locations used.
     */
    public static final String INTRA_ANTI_DEPENDENCIES = ANALYSIS_NAME
            + ".INTRA_ANTI";

    public AntiDepAnalysisFactory(AccrueExtensionInfo extInfo) {
        super(extInfo);
    }

    @Override
    public String analysisName() {
        return ANALYSIS_NAME;
    }

    @Override
    public String analysisReportName() {
        return AnalysisTopics.ANTIDEP;
    }

    @Override
    public AntiDepAbsVal bottomAbstractValue() {
        return AntiDepAbsVal.EMPTY;
    }

    @Override
    public AnalysisUtil<VarContext<AntiDepAbsVal>> analysisUtil(
            WorkQueue<VarContext<AntiDepAbsVal>> wq, AnalysisUnit aunit) {
        return new AntiDepAnalysisUtil(wq, aunit, extInfo);
    }

    @Override
    public VarContext<AntiDepAbsVal> startItem(
            AnalysisUtil<VarContext<AntiDepAbsVal>> autil,
            ProcedureDecl startProc) throws SemanticException {
        return new VarContext<AntiDepAbsVal>(ANALYSIS_NAME,
                                             bottomAbstractValue());
    }

}
