decompiler  1.0.0
Public Types | Public Member Functions | Private Attributes | List of all members
ghidra::partmap< _linetype, _valuetype > Class Template Reference

A map from a linear space to value objects. More...

#include <partmap.hh>

Public Types

typedef std::map< _linetype, _valuetype > maptype
 Defining the map from split points to value objects.
 
typedef maptype::iterator iterator
 A partmap iterator is an iterator into the map.
 
typedef maptype::const_iterator const_iterator
 A constant iterator.
 

Public Member Functions

_valuetype & getValue (const _linetype &pnt)
 Get the value object at a point. More...
 
const _valuetype & getValue (const _linetype &pnt) const
 Get the value object at a point. More...
 
const _valuetype & bounds (const _linetype &pnt, _linetype &before, _linetype &after, int &valid) const
 Get the value object for a given point and return the range over which the value object applies. More...
 
_valuetype & split (const _linetype &pnt)
 Introduce a new split point. More...
 
const _valuetype & defaultValue (void) const
 Get the default value object.
 
_valuetype & defaultValue (void)
 Get the default value object.
 
_valuetype & clearRange (const _linetype &pnt1, const _linetype &pnt2)
 Clear a range of split points. More...
 
const_iterator begin (void) const
 Beginning of split points.
 
const_iterator end (void) const
 End of split points.
 
iterator begin (void)
 Beginning of split points.
 
iterator end (void)
 End of split points.
 
const_iterator begin (const _linetype &pnt) const
 Get first split point after given point.
 
iterator begin (const _linetype &pnt)
 Get first split point after given point.
 
void clear (void)
 Clear all split points.
 
bool empty (void) const
 Return true if there are no split points.
 

Private Attributes

maptype database
 Map from linear split points to the value objects.
 
_valuetype defaultvalue
 The value object before the first split point.
 

Detailed Description

template<typename _linetype, typename _valuetype>
class ghidra::partmap< _linetype, _valuetype >

A map from a linear space to value objects.

The partmap is a template class taking:

Let R be the linear space with an ordering, and let { a_i } be a finite set of points in R. The a_i partition R into a finite number of disjoint sets { x : x < a_0 }, { x : x>=a_0 && x < a_1 }, ... { x : x>=a_i && x < a_i+1 }, ... { x : x>=a_n }

A partmap maps elements of this partition to _valuetype objects A _valuetype is then associated with any element x in R by looking up the value associated with the partition element containing x.

The map is defined by starting with a default value object that applies to the whole linear space. Then split points are introduced, one at a time, in the linear space. At each split point, the associated value object is split into two objects. At any point the value object describing some part of the linear space can be changed.

Member Function Documentation

◆ bounds()

template<typename _linetype, typename _valuetype >
const _valuetype & ghidra::partmap< _linetype, _valuetype >::bounds ( const _linetype &  pnt,
_linetype &  before,
_linetype &  after,
int &  valid 
) const

Get the value object for a given point and return the range over which the value object applies.

Pass back a before and after point defining the maximal range over which the value applies. An additional validity code is passed back describing which of the bounding points apply:

  • 0 if both bounds apply
  • 1 if there is no lower bound
  • 2 if there is no upper bound,
  • 3 if there is neither a lower or upper bound
    Parameters
    pntis the given point around which to compute the range
    beforeis a reference to the passed back lower bound
    afteris a reference to the passed back upper bound
    validis a reference to the passed back validity code
    Returns
    the corresponding value object

Referenced by ghidra::partmap< ghidra::Address, ghidra::ContextInternal::FreeArray >::clearRange().

◆ clearRange()

template<typename _linetype, typename _valuetype >
_valuetype & ghidra::partmap< _linetype, _valuetype >::clearRange ( const _linetype &  pnt1,
const _linetype &  pnt2 
)

Clear a range of split points.

Split points are introduced at the two boundary points of the given range, and all split points in between are removed. The value object that was initially present at the left-most boundary point becomes the value (as a copy) for the whole range.

Parameters
pnt1is the left-most boundary point of the range
pnt2is the right-most boundary point
Returns
the value object assigned to the range

Referenced by ghidra::partmap< ghidra::Address, ghidra::ContextInternal::FreeArray >::defaultValue(), and ghidra::partmap< ghidra::Address, ghidra::ContextInternal::FreeArray >::split().

◆ getValue() [1/2]

template<typename _linetype, typename _valuetype >
_valuetype & ghidra::partmap< _linetype, _valuetype >::getValue ( const _linetype &  pnt)

Get the value object at a point.

Look up the first split point coming before the given point and return the value object it maps to. If there is no earlier split point return the default value.

Parameters
pntis the given point in the linear space
Returns
the corresponding value object

Referenced by ghidra::partmap< ghidra::Address, ghidra::ContextInternal::FreeArray >::bounds(), ghidra::partmap< ghidra::Address, ghidra::ContextInternal::FreeArray >::empty(), ghidra::ContextInternal::getContext(), ghidra::Database::getProperty(), and ghidra::ContextInternal::getTrackedSet().

◆ getValue() [2/2]

template<typename _linetype, typename _valuetype >
const _valuetype & ghidra::partmap< _linetype, _valuetype >::getValue ( const _linetype &  pnt) const

Get the value object at a point.

Look up the first split point coming before the given point and return the value object it maps to. If there is no earlier split point return the default value.

Parameters
pntis the given point in the linear space
Returns
the corresponding value object

◆ split()

template<typename _linetype, typename _valuetype >
_valuetype & ghidra::partmap< _linetype, _valuetype >::split ( const _linetype &  pnt)

Introduce a new split point.

Add (if not already present) a point to the linear partition.

Parameters
pntis the (new) point
Returns
the (possibly) new value object for the range starting at the point

Referenced by ghidra::partmap< ghidra::Address, ghidra::ContextInternal::FreeArray >::bounds(), and ghidra::partmap< ghidra::Address, ghidra::ContextInternal::FreeArray >::clearRange().


The documentation for this class was generated from the following file: