package accrue.analysis.goals;

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

import polyglot.frontend.EmptyPass;
import polyglot.frontend.ExtensionInfo;
import polyglot.frontend.Job;
import polyglot.frontend.Pass;
import polyglot.frontend.Scheduler;
import polyglot.frontend.goals.EndGoal;
import polyglot.frontend.goals.Goal;
import polyglot.frontend.goals.SourceFileGoal;
import accrue.AccrueScheduler;

public class AnalysesDone extends SourceFileGoal implements EndGoal {
    public static Goal create(Scheduler scheduler, Job job) {
        return scheduler.internGoal(new AnalysesDone(job));
    }

    /**
     * @param job The job to compile.
     */
    protected AnalysesDone(Job job) {
        super(job);
    }

    @Override
    public Collection<Goal> prerequisiteGoals(Scheduler scheduler) {
        List<Goal> l = new ArrayList<Goal>();

        l.add(((AccrueScheduler) scheduler).helper().PointerAnalysis());
        l.add(((AccrueScheduler) scheduler).helper()
                                           .PreciseExceptionAnalysis(1));

        l.addAll(super.prerequisiteGoals(scheduler));
        return l;
    }

    @Override
    public Pass createPass(ExtensionInfo extInfo) {
        return new EmptyPass(this);
    }

}
