T
- type of context on each exit pathpublic class ExitMap<T extends Ordered<T>>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ExitMap.ExceptionKey
Key for an exception exit path
|
static class |
ExitMap.Key
Exit map key
|
static class |
ExitMap.LabeledBranchKey
Labeled
break or continue |
Modifier and Type | Field and Description |
---|---|
protected java.util.Set<polyglot.types.ClassType> |
exceptionTypes
Type of exceptions that can be thrown on exception exit
|
static ExitMap.Key |
KEY_BREAK
Key for a loop break
|
static ExitMap.Key |
KEY_CONTINUE
Key for a loop continue
|
static ExitMap.Key |
KEY_DIVERGE
Key for divergence
|
static ExitMap.Key |
KEY_FALSE_RESULT
Key for a false branch
|
static ExitMap.Key |
KEY_NORM_TERM
Key for normal termination
|
static ExitMap.Key |
KEY_RETURN
Key for exiting with a return statement
|
static ExitMap.Key |
KEY_TRUE_RESULT
Key for a true branch
|
protected java.util.Map<ExitMap.Key,T> |
map
Map of exit key to context
|
Modifier | Constructor and Description |
---|---|
protected |
ExitMap(java.util.Map<ExitMap.Key,T> m,
java.util.Set<polyglot.types.ClassType> exTypes)
Create a new map from the constituent parts
|
Modifier and Type | Method and Description |
---|---|
ExitMap<T> |
addKey(ExitMap.Key k,
T c)
Functional update of an
ExitMap . |
ExitMap<T> |
addToAll(T c)
Upper bound
c with the context for each key |
java.util.List<T> |
allItems() |
java.util.Set<ExitMap.Key> |
allKeys() |
T |
branch(polyglot.ast.Branch.Kind kind)
Get the context for a
break or a continue |
T |
branch(polyglot.ast.Branch.Kind kind,
java.lang.String loopLabel)
Get the context for a
break or a continue |
ExitMap<T> |
branch(polyglot.ast.Branch.Kind kind,
T c)
Set the context for a
break or continue |
static ExitMap.Key |
branchKey(polyglot.ast.Branch.Kind kind)
Get the key for continue or break
|
static ExitMap.Key |
branchKey(polyglot.ast.Branch.Kind kind,
java.lang.String loopLabel)
Get the branch key (
break or continue ) for the
given kind and label |
protected ExitMap<T> |
copy()
Returns a copy so that it is ok to modify the map.
|
protected ExitMap<T> |
create(java.util.Map<ExitMap.Key,T> m,
java.util.Set<polyglot.types.ClassType> exTypes)
Create a new map from the constituent parts
|
ExitMap<T> |
diverge(T c)
Add the context,
c , to the map with a diverge key |
boolean |
equals(java.lang.Object o) |
T |
exception(polyglot.types.ClassType exType)
Get the context for the given exception type
|
ExitMap<T> |
exception(polyglot.types.ClassType exType,
T c)
Add the exception type with the context,
c |
static ExitMap.ExceptionKey |
exceptionKey(polyglot.types.ClassType exType)
Get the key for the given exception type
|
java.util.Set<polyglot.types.ClassType> |
exceptionTypes() |
T |
falseResult()
Get the context for the false branch if any, otherwise return the
context for normal termination
|
ExitMap<T> |
falseResult(T falseC)
Set the context for the false branch
|
T |
get(ExitMap.Key key)
Get the context for the given key
|
boolean |
hasExceptionType(polyglot.types.ClassType exType) |
boolean |
hasFalseResult() |
int |
hashCode() |
boolean |
hasTrueFalseResult()
True if the exit map branches on exit
|
boolean |
hasTrueResult() |
T |
normalTermination() |
ExitMap<T> |
normalTermination(T c)
Set the context for normal termination
|
ExitMap<T> |
removeBranch(polyglot.ast.Branch.Kind kind)
Functionally remove the
break or continue from
the map |
ExitMap<T> |
removeBranch(polyglot.ast.Branch.Kind kind,
java.lang.String loopLabel)
Functionally remove the
break or continue with
the given label from the map |
ExitMap<T> |
removeException(polyglot.types.ClassType exType)
Functionally remove the edge correspinding to the exception type
|
ExitMap<T> |
removeNormalTermination()
Functionally remove the normal termination, true, and false results from
the map
|
ExitMap<T> |
removeReturnItem()
Functionally remove the return result from the map
|
ExitMap<T> |
removeTrueFalseResults()
Functionally remove the true, and false results from the map
|
T |
returnItem() |
ExitMap<T> |
returnItem(T c) |
java.lang.String |
toString() |
ExitMap<T> |
trueFalseResult(T trueC,
T falseC)
Set the contexts for the true and the false branches
|
T |
trueResult()
Get the context for the true branch if any, otherwise return the
context for normal termination
|
ExitMap<T> |
trueResult(T trueC)
Set the context for the true branch
|
ExitMap<T> |
upperBound(ExitMap<T> f)
Compute pairwise upper bound of
this with f . |
protected final java.util.Map<ExitMap.Key,T extends Ordered<T>> map
protected final java.util.Set<polyglot.types.ClassType> exceptionTypes
public static final ExitMap.Key KEY_NORM_TERM
public static final ExitMap.Key KEY_RETURN
public static final ExitMap.Key KEY_BREAK
public static final ExitMap.Key KEY_CONTINUE
public static final ExitMap.Key KEY_DIVERGE
public static final ExitMap.Key KEY_TRUE_RESULT
public static final ExitMap.Key KEY_FALSE_RESULT
protected ExitMap(java.util.Map<ExitMap.Key,T> m, java.util.Set<polyglot.types.ClassType> exTypes)
m
- map of exit type to contextexTypes
- Type of exceptions that can be thrown on exception exitprotected ExitMap<T> create(java.util.Map<ExitMap.Key,T> m, java.util.Set<polyglot.types.ClassType> exTypes)
m
- map of exit type to contextexTypes
- Type of exceptions that can be thrown on exception exitExitMap
classpublic boolean hasExceptionType(polyglot.types.ClassType exType)
public java.util.Set<polyglot.types.ClassType> exceptionTypes()
public T normalTermination()
public ExitMap<T> normalTermination(T c)
c
- the normal termination contextpublic T trueResult()
public T falseResult()
public ExitMap<T> trueFalseResult(T trueC, T falseC)
trueC
- new context for the true branchfalseC
- new context for the false branchpublic ExitMap<T> trueResult(T trueC)
trueC
- new context for the true branchpublic ExitMap<T> falseResult(T falseC)
falseC
- new context for the false branchpublic boolean hasTrueFalseResult()
public boolean hasTrueResult()
public boolean hasFalseResult()
public T returnItem()
public ExitMap<T> returnItem(T c)
c
- the context for a return statementpublic T branch(polyglot.ast.Branch.Kind kind)
break
or a continue
kind
- break
or continue
public T branch(polyglot.ast.Branch.Kind kind, java.lang.String loopLabel)
break
or a continue
kind
- break
or continue
loopLabel
- label of the looppublic ExitMap<T> branch(polyglot.ast.Branch.Kind kind, T c)
break
or continue
kind
- break
or continue
c
- context for the kindpublic ExitMap<T> diverge(T c)
c
, to the map with a diverge keyc
- context upon divergingpublic ExitMap<T> exception(polyglot.types.ClassType exType, T c)
c
exType
- type of exceptionc
- context when exiting with an exception of exType
public T exception(polyglot.types.ClassType exType)
exType
- type of exceptionexType
public static ExitMap.ExceptionKey exceptionKey(polyglot.types.ClassType exType)
exType
- type of exceptionpublic ExitMap<T> addKey(ExitMap.Key k, T c)
ExitMap
. Returns a new ExitMap
with the new value replacing the existing value in the map at the given
key similar to Map.put(Object, Object)
. If c
is
null then the value at the given key will be removed from the returned
map.k
- key for the mapc
- context to addpublic ExitMap<T> removeNormalTermination()
public ExitMap<T> removeTrueFalseResults()
public ExitMap<T> removeReturnItem()
public ExitMap<T> removeBranch(polyglot.ast.Branch.Kind kind)
break
or continue
from
the mappublic ExitMap<T> removeBranch(polyglot.ast.Branch.Kind kind, java.lang.String loopLabel)
break
or continue
with
the given label from the mappublic ExitMap<T> removeException(polyglot.types.ClassType exType)
public ExitMap<T> upperBound(ExitMap<T> f)
this
with f
. If
a key only exists in one then it is added as-isf
- map to upper bound withthis
with
f
public java.util.List<T> allItems()
public java.util.Set<ExitMap.Key> allKeys()
public ExitMap<T> addToAll(T c)
c
with the context for each keyc
with the context for
each keypublic java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public T get(ExitMap.Key key)
public static ExitMap.Key branchKey(polyglot.ast.Branch.Kind kind)
public static ExitMap.Key branchKey(polyglot.ast.Branch.Kind kind, java.lang.String loopLabel)
break
or continue
) for the
given kind and labelkind
- break
or continue
loopLabel
- label for the loop we are breaking or continuing