jif.types.label
Class Label_c

java.lang.Object
  extended by polyglot.ext.jl.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, NotTaken_c, ParamLabel_c, PolicyLabel_c, RuntimeLabel_c, ThisLabel_c, TopLabel_c, UnknownLabel_c, VarLabel_c

public abstract class Label_c
extends polyglot.ext.jl.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
           
 
Fields inherited from class polyglot.ext.jl.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.util.Collection components()
          By default, the components of a label is simply the label itself.
 java.lang.String componentString()
           
abstract  java.lang.String componentString(java.util.Set printedLabels)
           
 java.lang.String description()
           
abstract  boolean equalsImpl(polyglot.types.TypeObject t)
           
 boolean hasVariables()
          Does the label contain any variables, that is, labels of type VarLabel?
 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 isSingleton()
          A label is a singleton if it only has a single component.
 boolean isTop()
          Is this label equivalent to top?
 Label join(Label L)
          Join this label to L.
 PathMap labelCheck(JifContext A)
          Label check the label, which will determine how much information may be gained if the label is evaluated at runtime.
 void setDescription(java.lang.String d)
           
 Label simplify()
           
 Label singletonComponent()
          Return the single component.
 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 variables()
          The set of variables that this contains, i.e., labels of type VarLabel?
 
Methods inherited from class polyglot.ext.jl.types.TypeObject_c
copy, 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
 
Methods inherited from interface polyglot.util.Copy
copy
 

Field Detail

description

protected java.lang.String description

toJava

protected LabelToJavaExpr toJava
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

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

hasVariables

public final boolean hasVariables()
Description copied from interface: Label
Does the label contain any variables, that is, labels of type VarLabel?

Specified by:
hasVariables in interface Label

variables

public final java.util.Set variables()
Description copied from interface: Label
The set of variables that this contains, i.e., labels of type VarLabel?

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

components

public java.util.Collection components()
By default, the components of a label is simply the label itself.

Specified by:
components in interface Label

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

isSingleton

public boolean isSingleton()
A label is a singleton if it only has a single component.

Specified by:
isSingleton in interface Label

singletonComponent

public Label singletonComponent()
Return the single component.

Specified by:
singletonComponent in interface Label
Throws:
polyglot.util.InternalCompilerError - if this label is not a singleton.

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

join

public final Label join(Label L)
Join this label to L. The result is generally a JoinLabel

Specified by:
join 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.ext.jl.types.TypeObject_c

simplify

public Label simplify()
Specified by:
simplify 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)
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)