public class LabelChecker
extends java.lang.Object
implements polyglot.util.Copy
LabelChecker
class is used in the label checking of
Jif. Primarily it provides the method labelCheck(Node)
which invokes the labelCheck
method on nodes, utility functions to help in the implementation of the
labelCheck
methods, as well as references to the appropriate
Solver
and JifContext
.
LabelChecker
is mostly imperative; however, the
JifContext
is treated functionally, and whenever a
LabelChecker
is given a new JifContext
, a new
LabelChecker
is created.
Modifier and Type | Field and Description |
---|---|
protected polyglot.frontend.Job |
job |
protected polyglot.ast.NodeFactory |
nf |
protected boolean |
solvePerClassBody
If true, then a new system of constraints will be used for each
class body, and upon leaving the class body, the system of constraints
will be solved.
|
protected boolean |
solvePerMethod
If true, then a new system of constraints will be used for each
method body, and upon leaving the method body, the system of constraints
will be solved.
|
protected Solver |
solver
The
Solver to add constraints to. |
protected JifTypeSystem |
ts |
protected boolean |
warningsEnabled
If true, then warnings will be produced; otherwise, warnings will be
silenced.
|
Constructor and Description |
---|
LabelChecker(polyglot.frontend.Job job,
polyglot.types.TypeSystem ts,
polyglot.ast.NodeFactory nf,
boolean warningsEnabled,
boolean solvePerClassBody,
boolean solvePerMethod,
boolean doLabelSubst) |
Modifier and Type | Method and Description |
---|---|
protected void |
constrain(Constraint c) |
void |
constrain(NamedLabel lhs,
Constraint.Kind kind,
NamedLabel rhs,
LabelEnv env,
polyglot.util.Position pos) |
void |
constrain(NamedLabel lhs,
Constraint.Kind kind,
NamedLabel rhs,
LabelEnv env,
polyglot.util.Position pos,
boolean report,
ConstraintMessage msg) |
void |
constrain(NamedLabel lhs,
Constraint.Kind kind,
NamedLabel rhs,
LabelEnv env,
polyglot.util.Position pos,
ConstraintMessage msg) |
void |
constrain(NamedLabel label,
Principal p,
LabelEnv env,
polyglot.util.Position pos,
ConstraintMessage msg)
Adds a constraint to the solver, specifying that the given label must
actfor the given principal.
|
void |
constrain(NamedLabel label,
Principal p,
LabelEnv env,
polyglot.util.Position pos,
ConstraintMessage msg,
boolean report)
Adds a constraint to the solver, specifying that the given label must
actfor the given principal.
|
void |
constrain(Principal p,
Constraint.Kind kind,
Principal q,
LabelEnv env,
polyglot.util.Position pos,
ConstraintMessage msg) |
void |
constrain(Principal p,
Constraint.Kind kind,
Principal q,
LabelEnv env,
polyglot.util.Position pos,
ConstraintMessage msg,
boolean report) |
JifContext |
context() |
LabelChecker |
context(JifContext c) |
java.lang.Object |
copy() |
CallHelper |
createCallHelper(Label receiverLabel,
polyglot.ast.Receiver receiver,
polyglot.types.ReferenceType calleeContainer,
JifProcedureInstance pi,
java.util.List<polyglot.ast.Expr> actualArgs,
polyglot.util.Position position) |
CallHelper |
createCallHelper(Label receiverLabel,
polyglot.types.ReferenceType calleeContainer,
JifProcedureInstance pi,
java.util.List<polyglot.ast.Expr> actualArgs,
polyglot.util.Position position) |
CallHelper |
createOverrideHelper(JifMethodInstance overridden,
JifMethodInstance overriding) |
void |
enteringClassDecl(polyglot.types.ClassType ct)
Called by JifClassDeclExt just before this label checker is used to
check a class body.
|
void |
enteringMethod(polyglot.types.MethodInstance mi)
Called by JifMethodDeclExt just before this label checker is used to
check a method body.
|
polyglot.util.ErrorQueue |
errorQueue() |
polyglot.ast.Node |
finishedLabelCheckPass(polyglot.ast.Node n)
This method should be called on the top level label checker once
the label checking has finished.
|
boolean |
ignoredForSinglePathRule(Path p)
Helper function that can be overriden to indicate if a path is to be
ignored for the single path rule (such as the NV path).
|
JifContext |
jifContext() |
JifTypeSystem |
jifTypeSystem() |
polyglot.frontend.Job |
job() |
polyglot.ast.Node |
labelCheck(polyglot.ast.Node n) |
protected JifLabelSubst |
labelSubst()
Create a new JifLabelSubst.
|
JifClassDecl |
leavingClassDecl(JifClassDecl n)
Called by JifClassDeclExt just after this label checker has been used to
check a class body.
|
JifMethodDecl |
leavingMethod(JifMethodDecl n)
Called by JifClassDeclExt just after this label checker has been used to
check a method body.
|
Label |
lowerBound(Label L1,
Label L2)
Returns a lower bound for L1 and L2
|
polyglot.ast.NodeFactory |
nodeFactory() |
protected polyglot.ast.Node |
postLabelCheck(polyglot.ast.Node old,
polyglot.ast.Node n) |
protected polyglot.ast.Node |
preLabelCheck(polyglot.ast.Node n) |
void |
reportSemanticException(polyglot.types.SemanticException e) |
protected polyglot.ast.Node |
solveConstraints(polyglot.ast.Node n) |
Solver |
solver() |
JifTypeSystem |
typeSystem() |
Label |
upperBound(Label L1,
Label L2)
Returns an upper bound for L1 and L2
|
Label |
upperBound(Label L1,
Label L2,
Label L3) |
boolean |
warningsEnabled() |
protected final JifTypeSystem ts
protected final polyglot.frontend.Job job
protected final polyglot.ast.NodeFactory nf
protected final boolean warningsEnabled
protected final boolean solvePerClassBody
protected final boolean solvePerMethod
protected Solver solver
Solver
to add constraints to. Depending on
solveClassBodies
, a new Solver
is used
for every class, or a single Solver
used for the entire
compilation.public LabelChecker(polyglot.frontend.Job job, polyglot.types.TypeSystem ts, polyglot.ast.NodeFactory nf, boolean warningsEnabled, boolean solvePerClassBody, boolean solvePerMethod, boolean doLabelSubst)
public java.lang.Object copy()
copy
in interface polyglot.util.Copy
public JifContext context()
public JifContext jifContext()
public LabelChecker context(JifContext c)
public JifTypeSystem typeSystem()
public JifTypeSystem jifTypeSystem()
public polyglot.ast.NodeFactory nodeFactory()
public Solver solver()
public polyglot.frontend.Job job()
public boolean warningsEnabled()
public polyglot.util.ErrorQueue errorQueue()
protected polyglot.ast.Node preLabelCheck(polyglot.ast.Node n)
protected polyglot.ast.Node postLabelCheck(polyglot.ast.Node old, polyglot.ast.Node n)
public polyglot.ast.Node labelCheck(polyglot.ast.Node n) throws polyglot.types.SemanticException
polyglot.types.SemanticException
public void constrain(NamedLabel lhs, Constraint.Kind kind, NamedLabel rhs, LabelEnv env, polyglot.util.Position pos, ConstraintMessage msg) throws polyglot.types.SemanticException
polyglot.types.SemanticException
public void constrain(NamedLabel lhs, Constraint.Kind kind, NamedLabel rhs, LabelEnv env, polyglot.util.Position pos, boolean report, ConstraintMessage msg) throws polyglot.types.SemanticException
polyglot.types.SemanticException
public void constrain(NamedLabel lhs, Constraint.Kind kind, NamedLabel rhs, LabelEnv env, polyglot.util.Position pos) throws polyglot.types.SemanticException
polyglot.types.SemanticException
protected void constrain(Constraint c) throws polyglot.types.SemanticException
polyglot.types.SemanticException
public void constrain(Principal p, Constraint.Kind kind, Principal q, LabelEnv env, polyglot.util.Position pos, ConstraintMessage msg) throws polyglot.types.SemanticException
polyglot.types.SemanticException
public void constrain(Principal p, Constraint.Kind kind, Principal q, LabelEnv env, polyglot.util.Position pos, ConstraintMessage msg, boolean report) throws polyglot.types.SemanticException
polyglot.types.SemanticException
public void constrain(NamedLabel label, Principal p, LabelEnv env, polyglot.util.Position pos, ConstraintMessage msg) throws polyglot.types.SemanticException
polyglot.types.SemanticException
public void constrain(NamedLabel label, Principal p, LabelEnv env, polyglot.util.Position pos, ConstraintMessage msg, boolean report) throws polyglot.types.SemanticException
polyglot.types.SemanticException
public void enteringClassDecl(polyglot.types.ClassType ct)
public void enteringMethod(polyglot.types.MethodInstance mi)
public JifClassDecl leavingClassDecl(JifClassDecl n)
public JifMethodDecl leavingMethod(JifMethodDecl n)
public polyglot.ast.Node finishedLabelCheckPass(polyglot.ast.Node n)
protected JifLabelSubst labelSubst()
protected polyglot.ast.Node solveConstraints(polyglot.ast.Node n)
public void reportSemanticException(polyglot.types.SemanticException e)
public CallHelper createCallHelper(Label receiverLabel, polyglot.ast.Receiver receiver, polyglot.types.ReferenceType calleeContainer, JifProcedureInstance pi, java.util.List<polyglot.ast.Expr> actualArgs, polyglot.util.Position position)
public CallHelper createCallHelper(Label receiverLabel, polyglot.types.ReferenceType calleeContainer, JifProcedureInstance pi, java.util.List<polyglot.ast.Expr> actualArgs, polyglot.util.Position position)
public CallHelper createOverrideHelper(JifMethodInstance overridden, JifMethodInstance overriding)
public boolean ignoredForSinglePathRule(Path p)