package accrue.analysis.ctldep;

import java.util.HashMap;
import java.util.Map;

import polyglot.frontend.ExtensionInfo;
import accrue.AccrueExtensionInfo;
import accrue.analysis.goals.RegisterProceduresGoal;
import accrue.analysis.interprocanalysis.AnalysisFactory;
import accrue.analysis.interprocanalysis.InterProcAnalysisPass;
import accrue.analysis.interprocanalysis.Registrar;

public class CtlDepPass extends InterProcAnalysisPass<CDAbsVal> {

    static private Map<ExtensionInfo, CtlDepPass> singletons =
            new HashMap<ExtensionInfo, CtlDepPass>();

    static public CtlDepPass singleton(AccrueExtensionInfo extInfo) {
        CtlDepPass singleton = singletons.get(extInfo);
        if (singleton == null) {
            singleton =
                    new CtlDepPass(extInfo,
                                   RegisterProceduresGoal.registrar(extInfo),
                                   new CtlDepAnalysisFactory(extInfo));
            singletons.put(extInfo, singleton);
        }
        return singleton;
    }

    private CtlDepPass(ExtensionInfo extInfo, Registrar registrar,
            AnalysisFactory<CDAbsVal> analysisFactory) {
        super(extInfo,
              CtlDepGoal.singleton(extInfo),
              registrar,
              analysisFactory);
    }
}
