Package it.unive.lisa.analysis
Class FixpointInfo
- java.lang.Object
-
- it.unive.lisa.analysis.FixpointInfo
-
- All Implemented Interfaces:
BaseLattice<FixpointInfo>
,Lattice<FixpointInfo>
,StructuredObject
,java.lang.Iterable<java.util.Map.Entry<java.lang.String,Lattice<?>>>
public class FixpointInfo extends java.lang.Object implements BaseLattice<FixpointInfo>, java.lang.Iterable<java.util.Map.Entry<java.lang.String,Lattice<?>>>
A generic mapping from string keys toLattice
instances that can store custom user-defined information inside theAnalysisState
. This class itself is a special case ofFunctionalLattice
where values are not required to have the same type.
-
-
Field Summary
Fields Modifier and Type Field Description static FixpointInfo
BOTTOM
The unique bottom instance of this class.java.util.Map<java.lang.String,Lattice<?>>
function
The function containing the additional information.-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description FixpointInfo()
Builds the function.FixpointInfo(java.util.Map<java.lang.String,Lattice<?>> mapping)
Builds the function by using the given mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FixpointInfo
bottom()
Yields the bottom element of this lattice.boolean
equals(java.lang.Object obj)
Lattice<?>
get(java.lang.String key)
Yields the information associated to the given key.<T> T
get(java.lang.String key, java.lang.Class<T> type)
Yields the information associated to the given key, casted to the given type.java.util.Set<java.lang.String>
getKeys()
Yields the set of keys currently in this mapping.java.util.Map<java.lang.String,Lattice<?>>
getMap()
Yields the map associated with this mapping.java.util.Collection<Lattice<?>>
getValues()
Yields the values currently in this mapping.FixpointInfo
glbAux(FixpointInfo other)
Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled.int
hashCode()
boolean
isBottom()
Yieldstrue
if and only if this object represents the bottom of the lattice.boolean
isTop()
Yieldstrue
if and only if this object represents the top of the lattice.java.util.Iterator<java.util.Map.Entry<java.lang.String,Lattice<?>>>
iterator()
boolean
lessOrEqualAux(FixpointInfo other)
Yieldstrue
if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.FixpointInfo
lubAux(FixpointInfo other)
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.FixpointInfo
narrowingAux(FixpointInfo other)
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled.FixpointInfo
put(java.lang.String key, Lattice<?> info)
Yields a new instance of this class where the given information has been mapped to the given key.FixpointInfo
putWeak(java.lang.String key, Lattice<?> info)
Yields a new instance of this class where the given information has been mapped to the given key.StructuredRepresentation
representation()
Yields aStructuredRepresentation
of the information contained in this object's instance.FixpointInfo
top()
Yields the top element of this lattice.java.lang.String
toString()
FixpointInfo
wideningAux(FixpointInfo other)
Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.BaseLattice
glb, lessOrEqual, lub, narrowing, widening
-
-
-
-
Field Detail
-
BOTTOM
public static final FixpointInfo BOTTOM
The unique bottom instance of this class.
-
function
public java.util.Map<java.lang.String,Lattice<?>> function
The function containing the additional information.
-
-
Constructor Detail
-
FixpointInfo
public FixpointInfo()
Builds the function.
-
FixpointInfo
public FixpointInfo(java.util.Map<java.lang.String,Lattice<?>> mapping)
Builds the function by using the given mapping.- Parameters:
mapping
- the mapping to use
-
-
Method Detail
-
get
public Lattice<?> get(java.lang.String key)
Yields the information associated to the given key.- Parameters:
key
- the key- Returns:
- the mapped information
-
get
public <T> T get(java.lang.String key, java.lang.Class<T> type)
Yields the information associated to the given key, casted to the given type.- Type Parameters:
T
- the type to cast the return value of this method to- Parameters:
key
- the keytype
- the type to cast the retrieved information to- Returns:
- the mapped information
-
put
public FixpointInfo put(java.lang.String key, Lattice<?> info)
Yields a new instance of this class where the given information has been mapped to the given key. This is a strong update, meaning that the information previously mapped to the same key, if any, is lost. For a weak update, useputWeak(String, Lattice)
.- Parameters:
key
- the keyinfo
- the information to store- Returns:
- a new instance with the updated mapping
-
putWeak
public FixpointInfo putWeak(java.lang.String key, Lattice<?> info) throws SemanticException
Yields a new instance of this class where the given information has been mapped to the given key. This is a weak update, meaning that the information previously mapped to the same key, if any, is lubbed together with the given one, and the result is stored inside the mapping instead. For a strong update, useput(String, Lattice)
.- Parameters:
key
- the keyinfo
- the information to store- Returns:
- a new instance with the updated mapping
- Throws:
SemanticException
- if something goes wrong during the lub
-
lubAux
public FixpointInfo lubAux(FixpointInfo other) throws SemanticException
Description copied from interface:BaseLattice
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
lubAux
in interfaceBaseLattice<FixpointInfo>
- Parameters:
other
- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
glbAux
public FixpointInfo glbAux(FixpointInfo other) throws SemanticException
Description copied from interface:BaseLattice
Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
glbAux
in interfaceBaseLattice<FixpointInfo>
- Parameters:
other
- the other lattice element- Returns:
- the greatest lower bound between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
wideningAux
public FixpointInfo wideningAux(FixpointInfo other) throws SemanticException
Description copied from interface:BaseLattice
Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
BaseLattice.lubAux(BaseLattice)
, and is thus safe for finite lattices and ACC ones.- Specified by:
wideningAux
in interfaceBaseLattice<FixpointInfo>
- Parameters:
other
- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
narrowingAux
public FixpointInfo narrowingAux(FixpointInfo other) throws SemanticException
Description copied from interface:BaseLattice
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
BaseLattice.glbAux(BaseLattice)
, and is thus safe for finite lattices and DCC ones.- Specified by:
narrowingAux
in interfaceBaseLattice<FixpointInfo>
- Parameters:
other
- the other lattice element- Returns:
- the narrowing between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
lessOrEqualAux
public boolean lessOrEqualAux(FixpointInfo other) throws SemanticException
Description copied from interface:BaseLattice
Yieldstrue
if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
lessOrEqualAux
in interfaceBaseLattice<FixpointInfo>
- Parameters:
other
- the other lattice element- Returns:
true
if and only if that condition holds- Throws:
SemanticException
- if an error occurs during the computation
-
top
public FixpointInfo top()
Description copied from interface:Lattice
Yields the top element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isTop()
uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isTop()
accordingly to provide a coherent test.- Specified by:
top
in interfaceLattice<FixpointInfo>
- Returns:
- the top element
-
isTop
public boolean isTop()
Description copied from interface:Lattice
Yieldstrue
if and only if this object represents the top of the lattice. The default implementation of this method uses reference equality betweenthis
and the value returned byLattice.top()
, thus assuming that the top element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.- Specified by:
isTop
in interfaceLattice<FixpointInfo>
- Returns:
true
if this is the top of the lattice
-
bottom
public FixpointInfo bottom()
Description copied from interface:Lattice
Yields the bottom element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isBottom()
uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isBottom()
accordingly to provide a coherent test.- Specified by:
bottom
in interfaceLattice<FixpointInfo>
- Returns:
- the bottom element
-
isBottom
public boolean isBottom()
Description copied from interface:Lattice
Yieldstrue
if and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality betweenthis
and the value returned byLattice.bottom()
, thus assuming that the bottom element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.- Specified by:
isBottom
in interfaceLattice<FixpointInfo>
- Returns:
true
if this is the bottom of the lattice
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceBaseLattice<FixpointInfo>
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceBaseLattice<FixpointInfo>
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfaceBaseLattice<FixpointInfo>
- Overrides:
toString
in classjava.lang.Object
-
iterator
public java.util.Iterator<java.util.Map.Entry<java.lang.String,Lattice<?>>> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.util.Map.Entry<java.lang.String,Lattice<?>>>
-
getKeys
public java.util.Set<java.lang.String> getKeys()
Yields the set of keys currently in this mapping.- Returns:
- the set of keys
-
getValues
public java.util.Collection<Lattice<?>> getValues()
Yields the values currently in this mapping.- Returns:
- the set of values
-
getMap
public java.util.Map<java.lang.String,Lattice<?>> getMap()
Yields the map associated with this mapping.- Returns:
- the associated map
-
representation
public StructuredRepresentation representation()
Description copied from interface:StructuredObject
Yields aStructuredRepresentation
of the information contained in this object's instance.- Specified by:
representation
in interfaceStructuredObject
- Returns:
- the representation
-
-