package accrue.analysis.goals;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import polyglot.frontend.ExtensionInfo;
import polyglot.frontend.Pass;
import polyglot.frontend.Scheduler;
import polyglot.frontend.goals.AbstractGoal;
import polyglot.frontend.goals.Goal;
import accrue.AccrueScheduler;
import accrue.analysis.pointer.PointerAnalysisPass;

public class PointerAnalysisGoal extends AbstractGoal {
    public static Goal singleton(ExtensionInfo extInfo) {
        Scheduler scheduler = extInfo.scheduler();
        return scheduler.internGoal(new PointerAnalysisGoal());
    }

    protected PointerAnalysisGoal() {
        super(null, "PointerAnalysisGoal");
    }

    @Override
    public Collection<Goal> prerequisiteGoals(Scheduler scheduler) {
        List<Goal> l = new ArrayList<Goal>();
        l.add(((AccrueScheduler) scheduler).helper().RegisterPointerStmtsDone());
        l.addAll(super.prerequisiteGoals(scheduler));
        return l;
    }

    @Override
    public Pass createPass(ExtensionInfo extInfo) {
        return PointerAnalysisPass.singleton(extInfo);
    }
}
