polyglot.frontend.goals
Class AbstractGoal

java.lang.Object
  extended by polyglot.frontend.goals.AbstractGoal
All Implemented Interfaces:
Goal
Direct Known Subclasses:
Barrier, ClassTypeGoal, FieldConstantsChecked, Scheduler.TheEndGoal, SourceFileGoal, TypeExists

public abstract class AbstractGoal
extends java.lang.Object
implements Goal

An AbstractGoal is the base class of most Goal implementations.

Author:
nystrom

Field Summary
protected  java.util.Set corequisites
           
protected  Job job
           
protected  java.lang.String name
           
protected  java.util.Set prerequisites
           
protected  int state
           
 
Fields inherited from interface polyglot.frontend.goals.Goal
ATTEMPTED, REACHED, RUNNING, UNREACHABLE, UNREACHABLE_THIS_RUN, UNREACHED
 
Constructor Summary
protected AbstractGoal(Job job)
           
protected AbstractGoal(Job job, java.lang.String name)
           
 
Method Summary
 void addCorequisiteGoal(Goal g, Scheduler scheduler)
          Add a new corequisite subgoal g.
 void addPrerequisiteGoal(Goal g, Scheduler scheduler)
          Add a new subgoal g.
protected  void checkCycles(Goal current, Scheduler scheduler)
           
 boolean conflictsWith(Goal goal)
          Return true if this goal conflicts with the other; that is passes running over both goals could access the same data.
 java.util.Collection corequisiteGoals(Scheduler scheduler)
          Goals on which this goal may mutually depend.
abstract  Pass createPass(ExtensionInfo extInfo)
          Creates a pass to attempt to satisfy the goal.
 boolean equals(java.lang.Object o)
           
 boolean hasBeenReached()
          Return true if this goal has been reached.
 int hashCode()
           
 boolean isReachable()
          Return true if this goal is reachable.
 Job job()
          Get the job associated with this goal, or null.
 java.lang.String name()
          Get the name of the goal for debugging.
 java.util.Collection prerequisiteGoals(Scheduler scheduler)
          Goals that must be completed before attempting this goal.
 void setState(int state)
           
 void setUnreachable()
          Set a flag indicating that this rule is unreachable.
 void setUnreachableThisRun()
          Mark the goal as reached or not reached.
 int state()
           
protected  java.lang.String stateString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

job

protected Job job

name

protected java.lang.String name

state

protected int state

corequisites

protected java.util.Set corequisites

prerequisites

protected java.util.Set prerequisites
Constructor Detail

AbstractGoal

protected AbstractGoal(Job job)

AbstractGoal

protected AbstractGoal(Job job,
                       java.lang.String name)
Method Detail

conflictsWith

public boolean conflictsWith(Goal goal)
Return true if this goal conflicts with the other; that is passes running over both goals could access the same data.

Specified by:
conflictsWith in interface Goal

createPass

public abstract Pass createPass(ExtensionInfo extInfo)
Creates a pass to attempt to satisfy the goal.

Specified by:
createPass in interface Goal

name

public java.lang.String name()
Description copied from interface: Goal
Get the name of the goal for debugging.

Specified by:
name in interface Goal

job

public Job job()
Description copied from interface: Goal
Get the job associated with this goal, or null.

Specified by:
job in interface Goal

prerequisiteGoals

public java.util.Collection prerequisiteGoals(Scheduler scheduler)
Description copied from interface: Goal
Goals that must be completed before attempting this goal. The graph of dependencies between prerequisite goals should be acyclic.

Specified by:
prerequisiteGoals in interface Goal

corequisiteGoals

public java.util.Collection corequisiteGoals(Scheduler scheduler)
Description copied from interface: Goal
Goals on which this goal may mutually depend. If the passes for all corequisite goals are run (possibly more than once) they should all eventually be reached.

Specified by:
corequisiteGoals in interface Goal

addPrerequisiteGoal

public void addPrerequisiteGoal(Goal g,
                                Scheduler scheduler)
                         throws CyclicDependencyException
Description copied from interface: Goal
Add a new subgoal g. g must be completed before this goal is attempted. g should be interned.

Specified by:
addPrerequisiteGoal in interface Goal
Throws:
CyclicDependencyException - if a prerequisite of g is this

checkCycles

protected void checkCycles(Goal current,
                           Scheduler scheduler)
                    throws CyclicDependencyException
Throws:
CyclicDependencyException

addCorequisiteGoal

public void addCorequisiteGoal(Goal g,
                               Scheduler scheduler)
Description copied from interface: Goal
Add a new corequisite subgoal g. g is a goal on which this goal mutually depends. The caller must be careful to ensure that all corequisite goals can be eventually reached. g should be interned.

Specified by:
addCorequisiteGoal in interface Goal

setUnreachableThisRun

public void setUnreachableThisRun()
Mark the goal as reached or not reached.

Specified by:
setUnreachableThisRun in interface Goal

state

public int state()
Specified by:
state in interface Goal

setState

public void setState(int state)
Specified by:
setState in interface Goal

hasBeenReached

public boolean hasBeenReached()
Description copied from interface: Goal
Return true if this goal has been reached.

Specified by:
hasBeenReached in interface Goal

setUnreachable

public void setUnreachable()
Description copied from interface: Goal
Set a flag indicating that this rule is unreachable.

Specified by:
setUnreachable in interface Goal

isReachable

public boolean isReachable()
Description copied from interface: Goal
Return true if this goal is reachable.

Specified by:
isReachable in interface Goal

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

stateString

protected java.lang.String stateString()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object