|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjif.types.Solver
public abstract class Solver
A solver of Jif constraints. Finds solution to constraints essentially by propogating upper bounds backwards.
Field Summary | |
---|---|
protected VarMap |
dynBounds
|
protected static int |
STATUS_NO_SOLUTION
|
protected static int |
STATUS_NOT_SOLVED
|
protected static int |
STATUS_SOLVED
|
protected static int |
STATUS_SOLVING
|
static int |
stop_constraint
Constraint number at which to stop the compiler, for debugging purposes. |
protected JifTypeSystem |
ts
|
Constructor Summary | |
---|---|
|
Solver(JifTypeSystem ts,
java.lang.String solverName)
Constructor |
protected |
Solver(Solver js)
Constructor |
Method Summary | |
---|---|
void |
addConstraint(LabelConstraint c)
Add the constraint c to the system |
protected abstract void |
addDependencies(Equation eqn)
This abstract method must add the correct dependencies from Equation eqn to varaiables occuring in eqn, and dependencies in the other direction (that is, from variables occuring in eqn to eqn). |
protected void |
addDependency(Equation eqn,
VarLabel var)
This method records a dependency from Equation eqn to variable var. |
protected void |
addDependency(VarLabel var,
Equation eqn)
This method records a dependency from variable var to Equation eqn. |
protected void |
addEquationToQueue(Equation eqn)
|
protected void |
addEquationToQueueHead(Equation eqn)
|
protected void |
addTrace(VarLabel v,
Equation eqn,
Label lb)
Record the fact that label variable v, in the constraint eqn had its bound set to the label lb. |
Label |
applyBoundsTo(Label L)
|
VarMap |
bounds()
Get the bounds for this Solver. |
protected void |
checkCandidateSolution()
Check the candidate solution |
protected Graph |
createGraph()
Creating the equation graph with edges based on information gathered during the addConstraint method. |
protected java.lang.String |
errorMsg(LabelConstraint c)
Produce an error message for the constraint c, which cannot be satisfied. |
protected boolean |
errorShowConstraint()
|
protected boolean |
errorShowDefns()
|
protected boolean |
errorShowDetailMsg()
|
protected boolean |
errorShowTechnicalMsg()
|
protected java.lang.String |
errorStringConstraint(LabelConstraint c)
Produce a string appropriate for an error message that displays the unsatisfiable constraint c . |
protected java.lang.String |
errorStringDefns(LabelConstraint c)
Produce a string appropriate for an error message that displays the definitions needed by the unsatisfiable constraint c . |
protected abstract Equation |
findContradictiveEqn(LabelConstraint c)
|
protected Equation |
findTrace(VarLabel var,
Label threshold,
boolean lowerThreshold)
|
protected abstract Label |
getDefaultBound()
This method must return a constant label, which is the default bound of variables. |
protected java.util.List |
getQueue()
|
protected void |
inc_counter()
Increase the count of the number of constraints added (not just to this system, but to all instances of the Solver). |
static void |
report(int level,
java.lang.String s)
Convenience method to report messages for the appropriate topics |
protected void |
reportError(LabelConstraint c,
java.util.Collection variables)
Throws a SemanticException with the appropriate error message. |
protected void |
reportTraces(java.util.Collection variables)
Report the traces for each variables in the collection Variables |
void |
setBound(VarLabel v,
Label newBound,
LabelConstraint responsible)
|
void |
setBounds(VarMap bnds)
Set the bounds for this Solver. |
static boolean |
shouldReport(int obscurity)
Convenience method to determine if messages of the given obscurity should be reported. |
protected VarMap |
solve_bounds()
Solve the system of constraints, by finding upper bounds for the label variables. |
protected abstract void |
solve_eqn(Equation eqn)
This method changes the bounds of variables in the Equation eqn, to make the equation satisfied. |
VarMap |
solve()
Solve the system of constraints. |
protected Label |
triggerTransforms(Label label,
LabelEnv env)
|
protected void |
wakeUp(VarLabel v)
Awakens all equations in the system that depend on the variable v, ensuring that they are in the queue of active equations. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int STATUS_NOT_SOLVED
protected static final int STATUS_SOLVING
protected static final int STATUS_SOLVED
protected static final int STATUS_NO_SOLUTION
protected VarMap dynBounds
protected JifTypeSystem ts
public static int stop_constraint
ExtensionInfo
for
details
Constructor Detail |
---|
public Solver(JifTypeSystem ts, java.lang.String solverName)
protected Solver(Solver js)
Method Detail |
---|
public static final void report(int level, java.lang.String s)
public static final boolean shouldReport(int obscurity)
public Label applyBoundsTo(Label L)
protected Label triggerTransforms(Label label, LabelEnv env)
protected java.util.List getQueue()
protected void addEquationToQueue(Equation eqn)
protected void addEquationToQueueHead(Equation eqn)
protected final Graph createGraph()
public VarMap bounds()
public void setBounds(VarMap bnds)
public void setBound(VarLabel v, Label newBound, LabelConstraint responsible) throws polyglot.types.SemanticException
v
- the VarLabel to set the bound fornewBound
- the new bound for vresponsible
- the constraint that was responsible for modifying the
bound.
polyglot.types.SemanticException
- if the new bound violates an equality
constraint.public final VarMap solve() throws polyglot.types.SemanticException
polyglot.types.SemanticException
- if the Solver cannot find a solution to the
system of contraints.protected abstract Label getDefaultBound()
protected VarMap solve_bounds() throws polyglot.types.SemanticException
polyglot.types.SemanticException
- if the Solver cannot find a solution to the
system of contraints.protected abstract void solve_eqn(Equation eqn) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected final void checkCandidateSolution() throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected final void wakeUp(VarLabel v)
protected final void inc_counter()
public final void addConstraint(LabelConstraint c) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected abstract void addDependencies(Equation eqn)
protected void addDependency(VarLabel var, Equation eqn)
protected void addDependency(Equation eqn, VarLabel var)
protected final void addTrace(VarLabel v, Equation eqn, Label lb)
protected final Equation findTrace(VarLabel var, Label threshold, boolean lowerThreshold)
protected void reportTraces(java.util.Collection variables)
Variables
protected boolean errorShowConstraint()
protected boolean errorShowTechnicalMsg()
protected boolean errorShowDetailMsg()
protected boolean errorShowDefns()
protected final java.lang.String errorMsg(LabelConstraint c)
protected java.lang.String errorStringConstraint(LabelConstraint c)
c
.
protected java.lang.String errorStringDefns(LabelConstraint c)
c
.
protected void reportError(LabelConstraint c, java.util.Collection variables) throws polyglot.types.SemanticException
c
- The constraint that cannot be satisfied.
polyglot.types.SemanticException
- always.protected abstract Equation findContradictiveEqn(LabelConstraint c)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |