package accrue.analysis.antidep;

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

import polyglot.frontend.ExtensionInfo;
import accrue.AccrueExtensionInfo;
import accrue.analysis.goals.RegisterProceduresGoal;
import accrue.analysis.interprocanalysis.Registrar;
import accrue.analysis.interprocvarcontext.InterProcVarContextPass;

public class AntiDepPass extends InterProcVarContextPass<AntiDepAbsVal> {

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

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

    private AntiDepPass(ExtensionInfo extInfo, Registrar registrar,
            AntiDepAnalysisFactory analysisFactory) {
        super(extInfo,
              AntiDepGoal.singleton(extInfo),
              registrar,
              analysisFactory);
    }
}
