jif.types
Class LabelConstraint

java.lang.Object
  extended by jif.types.LabelConstraint

public class LabelConstraint
extends java.lang.Object

A LabelConstraint represents a constraint on labels, which may either be an inequality or equality constraint. LabelConstraints are generated during type checking. LabelConstraints in turn produce Equations which are what the Solver will use to find a satisfying assignment for VarLabels. A LabelConstraint is not the same as a LabelConstraint, which by contrast is assumed to be satisfied.


Nested Class Summary
static class LabelConstraint.Kind
          Kinds of constraint, either equality or inequality.
 
Field Summary
protected  LabelEnv env
          The environment under which this constraint needs to be satisfied.
static LabelConstraint.Kind EQUAL
          An equality kind of constraint.
protected  LabelConstraint.Kind kind
           
static LabelConstraint.Kind LEQ
          An inequality kind of constraint.
protected  Label lhs
           
protected  LabelConstraintMessage messages
          Error messages
protected  NamedLabel namedLHS
          Names for the LHS
protected  NamedLabel namedRHS
          Names for the RHS
protected  polyglot.util.Position pos
           
protected  boolean report
          Do we want to report a violation of this constraint, or report the error for a different constraint?
protected  Label rhs
           
 
Constructor Summary
LabelConstraint(NamedLabel lhs, LabelConstraint.Kind kind, NamedLabel rhs, LabelEnv env, polyglot.util.Position pos, LabelConstraintMessage msg, boolean report)
           
 
Method Summary
protected  void addLEQEqns(java.util.Collection eqns, Label left, Label right)
          Produce equations that require left to be less than or equal to right, and add them to eqns.
 java.util.Map definitions(VarMap bounds)
          Returns a Map of Strings to List[String]s which is the definitions/bounds of the NamedLabels, and the description of any components that appear in the NamedLabels.
 java.lang.String detailMsg()
          A detailed message to display if this constraint is violated.
 LabelEnv env()
           
 java.util.Collection getEquations()
          Produce a Collection of Equations for this constraint.
 LabelConstraint.Kind kind()
           
 Label lhs()
           
 LabelConstraintMessage messages()
           
 java.lang.String msg()
          A message to display if this constraint is violated.
protected  java.util.Map namedDescrips()
          Return a map from Strings to Strings, which are the descriptions of names in the left and right hand sides.
protected  java.util.Map namedLabels()
          Return a map from Strings to Labels, which are the named elements of the left and right hand sides.
 NamedLabel namedLhs()
           
 NamedLabel namedRhs()
           
 polyglot.util.Position position()
           
 boolean report()
           
 Label rhs()
           
 java.lang.String technicalMsg()
          A technical message to display if this constraint is violated.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EQUAL

public static final LabelConstraint.Kind EQUAL
An equality kind of constraint. That is, the constraint requires that lhs <= rhs and rhs <= lhs.


LEQ

public static final LabelConstraint.Kind LEQ
An inequality kind of constraint. That is, the constraint requires that lhs <= rhs.


lhs

protected Label lhs

kind

protected LabelConstraint.Kind kind

rhs

protected Label rhs

env

protected LabelEnv env
The environment under which this constraint needs to be satisfied.


namedLHS

protected NamedLabel namedLHS
Names for the LHS


namedRHS

protected NamedLabel namedRHS
Names for the RHS


pos

protected polyglot.util.Position pos

report

protected boolean report
Do we want to report a violation of this constraint, or report the error for a different constraint?


messages

protected LabelConstraintMessage messages
Error messages

Constructor Detail

LabelConstraint

public LabelConstraint(NamedLabel lhs,
                       LabelConstraint.Kind kind,
                       NamedLabel rhs,
                       LabelEnv env,
                       polyglot.util.Position pos,
                       LabelConstraintMessage msg,
                       boolean report)
Method Detail

lhs

public Label lhs()

kind

public LabelConstraint.Kind kind()

rhs

public Label rhs()

namedLhs

public NamedLabel namedLhs()

namedRhs

public NamedLabel namedRhs()

env

public LabelEnv env()

position

public polyglot.util.Position position()

report

public boolean report()

messages

public LabelConstraintMessage messages()

msg

public java.lang.String msg()
A message to display if this constraint is violated. This message should be short, and explain without using typing rules what this constraint represents. It should not refer to the names of labels (i.e., names for NamedLabels.


detailMsg

public java.lang.String detailMsg()
A detailed message to display if this constraint is violated. This message may consist of several sentences, and may refer to the names of the labels, if NamedLabels are used.


technicalMsg

public java.lang.String technicalMsg()
A technical message to display if this constraint is violated. This message can refer to typing rules to explain what the constraint represents, and to names of labels, if NamedLabels are used.


toString

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

namedLabels

protected java.util.Map namedLabels()
Return a map from Strings to Labels, which are the named elements of the left and right hand sides.


namedDescrips

protected java.util.Map namedDescrips()
Return a map from Strings to Strings, which are the descriptions of names in the left and right hand sides.


definitions

public java.util.Map definitions(VarMap bounds)
Returns a Map of Strings to List[String]s which is the definitions/bounds of the NamedLabels, and the description of any components that appear in the NamedLabels. This map is used for verbose output to the user, to help explain the meaning of this constraint.


getEquations

public java.util.Collection getEquations()
Produce a Collection of Equations for this constraint.


addLEQEqns

protected void addLEQEqns(java.util.Collection eqns,
                          Label left,
                          Label right)
Produce equations that require left to be less than or equal to right, and add them to eqns.