Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractSolver.EquationQueue
A queue for equations.
|
protected class |
AbstractSolver.Frame |
Modifier and Type | Field and Description |
---|---|
protected VarMap |
bounds |
protected polyglot.frontend.Compiler |
compiler |
protected static int |
constraint_counter
Counter of the number of constraints added to the system.
|
protected java.util.Set<Equation> |
currentSCC |
protected java.util.Collection<Equation> |
equations |
protected java.util.List<FailedConstraintSnapshot> |
failedEquations |
protected java.util.Set<Variable> |
fixedValueVars
Set of Variables that had their initial value fixed when the constraint
was added.
|
java.util.List<InformationFlowTrace> |
fullTrace |
protected AbstractSolver.EquationQueue |
Q |
protected java.util.LinkedList<java.util.Set<Equation>> |
scc |
protected static int |
solverCounter
Number of solvers instantiated, for debugging purposes
|
protected java.util.Set<Equation> |
staticFailedConstraints
Constraints that were added to the solver, and failed statically.
|
protected int |
status |
protected static int |
STATUS_NO_SOLUTION |
protected static int |
STATUS_NOT_SOLVED |
protected static int |
STATUS_SOLVED |
protected static int |
STATUS_SOLVING |
protected static boolean |
THROW_STATIC_FAILED_CONSTRAINTS |
protected static java.util.Collection<java.lang.String> |
topics |
protected java.util.Map<VarLabel,java.util.List<polyglot.util.Pair<Equation,Label>>> |
traces |
protected JifTypeSystem |
ts |
protected boolean |
useSCC
This boolean is used to turn on or off whether the strongly connected
components optimization is used.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractSolver(AbstractSolver js)
Constructor
|
protected |
AbstractSolver(JifTypeSystem ts,
polyglot.frontend.Compiler compiler,
java.lang.String solverName)
Constructor
|
protected |
AbstractSolver(JifTypeSystem ts,
polyglot.frontend.Compiler compiler,
java.lang.String solverName,
boolean useSCC)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addConstraint(Constraint c)
Add the constraint c to the system
|
protected void |
addConstraintEquations(Constraint c)
Go through each equation in the constraint, add the equation
if needed, and register dependencies for the equation.
|
protected abstract void |
addDependencies(Equation eqn)
This abstract method must add the correct dependencies from Equation eqn
to variables occurring in eqn, and dependencies in the other direction
(that is, from variables occurring in eqn to eqn).
|
protected void |
addDependency(Equation eqn,
Variable var)
This method records a dependency from Equation eqn to variable var.
|
protected void |
addDependency(Variable 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,
Label sourcelabel,
Equation eqn,
Label lb,
InformationFlowTrace.Direction dir)
Record the fact that label variable v, in the constraint eqn had its
bound set to the label lb.
|
Label |
applyBoundsTo(Label L)
Substitute variables in L with the solution for the variables.
|
VarMap |
bounds()
Get the bounds for this Solver.
|
protected void |
checkCandidateSolution()
Check the candidate solution
|
protected void |
checkEquationSatisfied(LabelEquation eqn) |
protected void |
considerEquation(Equation eqn) |
protected void |
considerEquation(LabelEquation eqn) |
protected void |
considerEquation(PrincipalEquation eqn) |
protected java.util.Set<Equation> |
eqnEqnDependencies(Equation eqn)
Returns the equations that are dependent on the equation eqn by finding
the variables that eqn may alter if it is solved (useing the map
eqnVarDependencies), and then finds the equations that depend on those
variables (using the map varEqnDependencies)
|
protected java.util.Set<Equation> |
eqnEqnReverseDependencies(Equation eqn)
Returns the equations that are reverse dependent on the equation eqn by finding
the variables that may invalidate eqn (using the map
eqnVarReverseDependencies), and then finding the equations
that may alter those variables (using the map varEqnReverseDependencies)
|
protected Equation |
findContradictiveEqn(Constraint c) |
protected abstract Equation |
findContradictiveEqn(LabelConstraint c) |
protected polyglot.util.Pair<Equation[],int[]> |
findSCCs()
Returns the pair [by_scc, scc_head] where
by_scc is an array in which SCCs occur in topologically
order.
|
protected Equation |
findTrace(VarLabel var,
Label threshold,
boolean lowerThreshold) |
void |
genFlowMessage(UnsatisfiableConstraintException ex) |
protected abstract Label |
getDefaultLabelBound()
This method must return a constant label, which is the default bound of
label variables.
|
protected abstract Principal |
getDefaultPrincipalBound()
This method must return a constant principal, which is the default bound of
principal variables.
|
protected java.util.List<Equation> |
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).
|
protected boolean |
isFixedValueVar(Variable v) |
protected void |
processConstraint(Constraint c)
Perform any special processing for the label constraint
|
static void |
report(int level,
java.lang.String s)
Convenience method to report messages for the appropriate topics
|
protected UnsatisfiableConstraintException |
reportError(Equation eqn)
Report an unsatisfiable constraint
|
protected void |
reportTrace(Variable v)
Report a trace for a given variable.
|
void |
setBound(VarLabel v,
Label newBound,
LabelConstraint responsible) |
void |
setBound(VarPrincipal v,
Principal newBound,
PrincipalConstraint responsible) |
void |
setBounds(VarMap bnds)
Set the bounds for this Solver.
|
protected void |
setStatus(int status) |
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(LabelEquation eqn)
This method changes the bounds of variables in the Equation eqn, to make
the equation satisfied.
|
protected abstract void |
solve_eqn(PrincipalEquation eqn)
This method changes the bounds of variables in the Equation eqn, to make
the equation satisfied.
|
VarMap |
solve()
Solve the system of constraints.
|
java.lang.String |
solverName() |
protected Label |
triggerTransforms(Label label,
LabelEnv env) |
protected void |
wakeUp(Variable v)
Awakens all equations in the system that depend on the variable v,
ensuring that they are in the queue of active equations.
|
protected AbstractSolver.EquationQueue Q
protected java.util.LinkedList<java.util.Set<Equation>> scc
protected java.util.Set<Equation> currentSCC
protected java.util.Collection<Equation> equations
protected java.util.List<FailedConstraintSnapshot> failedEquations
protected java.util.Set<Variable> fixedValueVars
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 int status
protected VarMap bounds
protected JifTypeSystem ts
protected java.util.Set<Equation> staticFailedConstraints
protected static final boolean THROW_STATIC_FAILED_CONSTRAINTS
protected final polyglot.frontend.Compiler compiler
public java.util.List<InformationFlowTrace> fullTrace
protected static java.util.Collection<java.lang.String> topics
protected final boolean useSCC
protected static int solverCounter
protected static int constraint_counter
protected AbstractSolver(JifTypeSystem ts, polyglot.frontend.Compiler compiler, java.lang.String solverName)
protected AbstractSolver(JifTypeSystem ts, polyglot.frontend.Compiler compiler, java.lang.String solverName, boolean useSCC)
protected AbstractSolver(AbstractSolver js)
public static final void report(int level, java.lang.String s)
public static final boolean shouldReport(int obscurity)
public Label applyBoundsTo(Label L)
Solver
applyBoundsTo
in interface Solver
protected java.util.List<Equation> getQueue()
protected void addEquationToQueue(Equation eqn)
protected void addEquationToQueueHead(Equation eqn)
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 void setBound(VarPrincipal v, Principal newBound, PrincipalConstraint responsible)
public VarMap solve() throws polyglot.types.SemanticException
public void genFlowMessage(UnsatisfiableConstraintException ex)
protected void setStatus(int status)
protected abstract Label getDefaultLabelBound()
protected abstract Principal getDefaultPrincipalBound()
protected VarMap solve_bounds() throws polyglot.types.SemanticException
polyglot.types.SemanticException
- if the Solver cannot find a solution to the
system of constraints.protected void considerEquation(Equation eqn) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected void considerEquation(LabelEquation eqn) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected abstract void solve_eqn(LabelEquation eqn) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected void considerEquation(PrincipalEquation eqn) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected abstract void solve_eqn(PrincipalEquation eqn) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected final void checkCandidateSolution() throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected void checkEquationSatisfied(LabelEquation eqn) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected final void wakeUp(Variable v)
public java.lang.String solverName()
protected final void inc_counter()
protected boolean isFixedValueVar(Variable v)
public void addConstraint(Constraint c) throws polyglot.types.SemanticException
addConstraint
in interface Solver
polyglot.types.SemanticException
protected void processConstraint(Constraint c) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected void addConstraintEquations(Constraint c) throws polyglot.types.SemanticException
c
- polyglot.types.SemanticException
protected abstract void addDependencies(Equation eqn)
protected void addDependency(Variable var, Equation eqn)
protected void addDependency(Equation eqn, Variable var)
protected java.util.Set<Equation> eqnEqnDependencies(Equation eqn)
protected java.util.Set<Equation> eqnEqnReverseDependencies(Equation eqn)
protected final void addTrace(VarLabel v, Label sourcelabel, Equation eqn, Label lb, InformationFlowTrace.Direction dir)
protected final Equation findTrace(VarLabel var, Label threshold, boolean lowerThreshold)
protected Equation findContradictiveEqn(Constraint c)
protected abstract Equation findContradictiveEqn(LabelConstraint c)
protected polyglot.util.Pair<Equation[],int[]> findSCCs()
protected UnsatisfiableConstraintException reportError(Equation eqn)
eqn
- The equation that is unsatisfiableprotected void reportTrace(Variable v)