package accrue.analysis.readwritesets;

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

/**
 * {@link AnalysisFactory} for the analysis which gathers all locations read and 
 * written by particular analysis units.
 */
public class ReadWriteSetsAnalysisFactory extends AnalysisFactory<ReadWriteSet> {

    /**
     * Construct a new factory
     * 
     * @param extInfo information about the extension
     */
    public ReadWriteSetsAnalysisFactory(AccrueExtensionInfo extInfo) {
        super(extInfo);
    }

    /**
     * Name of the analysis
     */
    public static final String ANALYSIS_NAME = "accrue.analysis.readwritesets";

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

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

    @Override
    public AnalysisUtil<ReadWriteSet> analysisUtil(WorkQueue<ReadWriteSet> wq,
            AnalysisUnit aunit) {
        return new ReadWriteSetsAnalysisUtil(wq, aunit, this.extInfo);
    }

    @Override
    public ReadWriteSet startItem(AnalysisUtil<ReadWriteSet> autil,
            ProcedureDecl startProc) throws SemanticException {
        return ReadWriteSet.EMPTY;
    }

}
