jif.types.label
Class Label_c

java.lang.Object
  extended by polyglot.types.TypeObject_c
      extended by jif.types.label.Label_c
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Label, Param, polyglot.types.TypeObject, polyglot.util.Copy
Direct Known Subclasses:
ArgLabel_c, CovariantParamLabel_c, DynamicLabel_c, JoinLabel_c, MeetLabel_c, NotTaken_c, PairLabel_c, ParamLabel_c, ThisLabel_c, UnknownLabel_c, VarLabel_c, WritersToReadersLabel_c

public abstract class Label_c
extends polyglot.types.TypeObject_c
implements Label

An abstract implementation of the Label interface.

See Also:
Serialized Form

Field Summary
protected  java.lang.String description
           
protected  LabelToJavaExpr toJava
           
protected  java.util.Set variables
           
 
Fields inherited from class polyglot.types.TypeObject_c
position, ts
 
Constructor Summary
protected Label_c()
           
  Label_c(JifTypeSystem ts, polyglot.util.Position pos)
           
  Label_c(JifTypeSystem ts, polyglot.util.Position pos, LabelToJavaExpr toJava)
           
 
Method Summary
 java.lang.String componentString()
           
abstract  java.lang.String componentString(java.util.Set printedLabels)
           
 ConfPolicy confProjection()
           
 java.lang.Object copy()
           
 java.lang.String description()
           
abstract  boolean equalsImpl(polyglot.types.TypeObject t)
           
 boolean hasVariableComponents()
          Does the label contain any variables as components? This does not include variables that are in bounds of arg labels.
 boolean hasVariables()
          Does the label contain any variables at all? This includes variables that are in bounds of arg labels.
 boolean hasWritersToReaders()
          Does the label contain any writersToReaders constructs?
 IntegPolicy integProjection()
           
 boolean isBottom()
          By default, a label is not Bottom
 boolean isDisambiguated()
          Are the components of this label all disambiguated?
protected abstract  boolean isDisambiguatedImpl()
          Check if the label is disambiguated, without recursing into child labels.
 boolean isInvariant()
          Is this label invariant?
 boolean isTop()
          Is this label equivalent to top?
 PathMap labelCheck(JifContext A, LabelChecker lc)
          Label check the label, which will determine how much information may be gained if the label is evaluated at runtime.
 Label normalize()
          Normalize the label.
 void setDescription(java.lang.String d)
           
 Label simplify()
          Simplify the label, using leq if needed
protected  Label simplifyImpl()
           
 Label subst(LabelSubstitution substitution)
           
 java.util.List throwTypes(polyglot.types.TypeSystem ts)
          If the label is runtime representable, when it is evaluated at runtime it may throw exceptions.
 polyglot.ast.Expr toJava(JifToJavaRewriter rw)
           
 java.lang.String toString()
           
 java.lang.String toString(java.util.Set printedLabels)
           
 java.util.Set variableComponents()
          The set of variables that this label contains as components.
 java.util.Set variables()
          The set of variables that this label contains including variables contained in upper bounds of arg labels.
 
Methods inherited from class polyglot.types.TypeObject_c
equals, hashCode, position, typeSystem
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface jif.types.label.Label
isComparable, isCovariant, isEnumerable, isRuntimeRepresentable, leq_
 
Methods inherited from interface jif.types.Param
isCanonical
 
Methods inherited from interface polyglot.types.TypeObject
position, typeSystem
 

Field Detail

description

protected java.lang.String description

toJava

protected LabelToJavaExpr toJava

variables

protected java.util.Set variables
Constructor Detail

Label_c

protected Label_c()

Label_c

public Label_c(JifTypeSystem ts,
               polyglot.util.Position pos,
               LabelToJavaExpr toJava)

Label_c

public Label_c(JifTypeSystem ts,
               polyglot.util.Position pos)
Method Detail

copy

public java.lang.Object copy()
Specified by:
copy in interface polyglot.util.Copy
Overrides:
copy in class polyglot.types.TypeObject_c

description

public java.lang.String description()
Specified by:
description in interface Label

setDescription

public void setDescription(java.lang.String d)
Specified by:
setDescription in interface Label

hasVariableComponents

public boolean hasVariableComponents()
Description copied from interface: Label
Does the label contain any variables as components? This does not include variables that are in bounds of arg labels.

Specified by:
hasVariableComponents in interface Label

hasVariables

public final boolean hasVariables()
Description copied from interface: Label
Does the label contain any variables at all? This includes variables that are in bounds of arg labels.

Specified by:
hasVariables in interface Label

hasWritersToReaders

public boolean hasWritersToReaders()
Description copied from interface: Label
Does the label contain any writersToReaders constructs?

Specified by:
hasWritersToReaders in interface Label

variables

public java.util.Set variables()
Description copied from interface: Label
The set of variables that this label contains including variables contained in upper bounds of arg labels.

Specified by:
variables in interface Label

toJava

public polyglot.ast.Expr toJava(JifToJavaRewriter rw)
                         throws polyglot.types.SemanticException
Specified by:
toJava in interface Label
Throws:
polyglot.types.SemanticException

isBottom

public boolean isBottom()
By default, a label is not Bottom

Specified by:
isBottom in interface Label

isTop

public boolean isTop()
Description copied from interface: Label
Is this label equivalent to top?

For example, a JoinLabel with two components, one of which is Top, would return true for this method.

Specified by:
isTop in interface Label

isInvariant

public boolean isInvariant()
Description copied from interface: Label
Is this label invariant?

Specified by:
isInvariant in interface Label

isDisambiguatedImpl

protected abstract boolean isDisambiguatedImpl()
Check if the label is disambiguated, without recursing into child labels.


isDisambiguated

public final boolean isDisambiguated()
Description copied from interface: Label
Are the components of this label all disambiguated?

Specified by:
isDisambiguated in interface Label

toString

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

toString

public java.lang.String toString(java.util.Set printedLabels)
Specified by:
toString in interface Label

componentString

public java.lang.String componentString()
Specified by:
componentString in interface Label

componentString

public abstract java.lang.String componentString(java.util.Set printedLabels)
Specified by:
componentString in interface Label

equalsImpl

public abstract boolean equalsImpl(polyglot.types.TypeObject t)
Specified by:
equalsImpl in interface polyglot.types.TypeObject
Overrides:
equalsImpl in class polyglot.types.TypeObject_c

simplify

public final Label simplify()
Description copied from interface: Label
Simplify the label, using leq if needed

Specified by:
simplify in interface Label

simplifyImpl

protected Label simplifyImpl()

normalize

public Label normalize()
Description copied from interface: Label
Normalize the label. Essentially, simplify as much as possible without using the leq ordering

Specified by:
normalize in interface Label

confProjection

public ConfPolicy confProjection()
Specified by:
confProjection in interface Label

integProjection

public IntegPolicy integProjection()
Specified by:
integProjection in interface Label

throwTypes

public java.util.List throwTypes(polyglot.types.TypeSystem ts)
Description copied from interface: Label
If the label is runtime representable, when it is evaluated at runtime it may throw exceptions. This method returns a list of the exceptions that the runtime evaluation of the label may produce. If the label cannot be evaluated at runtime, an empty list should be returned.

Specified by:
throwTypes in interface Label

subst

public Label subst(LabelSubstitution substitution)
            throws polyglot.types.SemanticException
Specified by:
subst in interface Label
Parameters:
substitution - The LabelSubstitution to apply to this label
Returns:
the result of applying labelSubst to this label.
Throws:
polyglot.types.SemanticException

labelCheck

public PathMap labelCheck(JifContext A,
                          LabelChecker lc)
Description copied from interface: Label
Label check the label, which will determine how much information may be gained if the label is evaluated at runtime. For example, given the dynamic label {*lb}, where lb is a local variable, evaluation of this label at runtime will reveal as much information as the label of lb. For example, the following code is illegal, as the runtime evaluation of the label reveals too much information
 
  boolean{Alice:} secret = ...;
  final label{Alice:} lb = secret?new label{}:new label{Bob:};
  boolean{} leak = false;
  if ((*lb} <= new label{}) { // evaluation of lb reveals 
                           // information at level {Alice:} 
     leak = true;
  } 
  
 

Specified by:
labelCheck in interface Label
See Also:
Jif.labelCheck(LabelChecker), Principal.labelCheck(JifContext, LabelChecker)

variableComponents

public java.util.Set variableComponents()
Description copied from interface: Label
The set of variables that this label contains as components. This is a subset of variables(), since it does not count var labels contained in upper bounds of arg labels.

Specified by:
variableComponents in interface Label