ROSE
0.9.6a
|
A contiguous range of values. More...
#include <rangemap.h>
Public Types | |
typedef T | Value |
typedef std::pair< Range, Range > | Pair |
A pair of ranges. More... | |
Public Member Functions | |
Range () | |
Create an empty range. More... | |
Range (const Value &first) | |
Create a new range of unit size. More... | |
Range (const Value &first, const Value &size) | |
Create a new range of specified size. More... | |
template<class Other > | |
Range (const Other &other) | |
Create a new range from a different range. More... | |
Value | size () const |
Returns the number of values represented by the range. More... | |
Pair | split_range_at (const Value &at) const |
Split a range into two parts. More... | |
Range | join (const Range &right) const |
Joins two adjacent ranges. More... | |
std::vector< Range > | erase (const Range &to_erase) const |
Erase part of a range to return zero, one, or two new ranges. More... | |
Range | intersect (const Range &other) const |
Intersection of two ranges. More... | |
bool | empty () const |
Returns true if this range is empty. More... | |
void | clear () |
Make a range empty. More... | |
bool | begins_with (const Range &x) const |
Do both ranges begin at the same place? More... | |
bool | ends_with (const Range &x) const |
Do both ranges end at the same place? More... | |
bool | begins_after (const Range &x, bool strict=true) const |
Does this range begin (strictly) after the beginning of another range? More... | |
bool | begins_before (const Range &x, bool strict=true) const |
Does this range begin (strictly) before the beginning of another range? More... | |
bool | ends_after (const Range &x, bool strict=true) const |
Does this range end (strictly) after the end of another range? More... | |
bool | ends_before (const Range &x, bool strict=true) const |
Does this range end (strictly) before the end of another range? More... | |
bool | contains (const Range &x, bool strict=false) const |
Does this range contain the argument range? More... | |
bool | contained_in (const Range &x, bool strict=false) const |
Is this range contained in the argument range? More... | |
bool | congruent (const Range &x) const |
Are two ranges equal? More... | |
bool | left_of (const Range &x) const |
Is this range left of the argument range? More... | |
bool | right_of (const Range &x) const |
Is this range right of the argument range? More... | |
bool | overlaps (const Range &x) const |
Does this range overlap with the argument range? More... | |
bool | distinct (const Range &x) const |
Is this range non-overlapping with the argument range? More... | |
bool | abuts_lt (const Range &x) const |
Is this range immediately left of the argument range? More... | |
bool | abuts_gt (const Range &x) const |
Is this range immediately right of the argument range? More... | |
bool | operator== (const Range &x) const |
bool | operator!= (const Range &x) const |
void | print (std::ostream &o) const |
template<> | |
Range () | |
template<> | |
bool | empty () const |
template<> | |
void | clear () |
template<> | |
const double | relaxed_first () const |
template<> | |
double | size () const |
template<> | |
void | resize (const double &new_size) |
template<> | |
void | relaxed_resize (const double &new_size) |
template<> | |
Range< double >::Pair | split_range_at (const double &at) const |
template<> | |
double | minimum () |
template<> | |
double | maximum () |
template<> | |
Range () | |
template<> | |
bool | empty () const |
template<> | |
void | clear () |
template<> | |
const float | relaxed_first () const |
template<> | |
float | size () const |
template<> | |
void | resize (const float &new_size) |
template<> | |
void | relaxed_resize (const float &new_size) |
template<> | |
Range< float >::Pair | split_range_at (const float &at) const |
template<> | |
float | minimum () |
template<> | |
float | maximum () |
void | first (const Value &first) |
Accessor for the first value of a range. More... | |
const Value | first () const |
Accessor for the first value of a range. More... | |
const Value | relaxed_first () const |
Accessor for the first value of a range. More... | |
void | last (const Value &last) |
Accessor for the last value of a range. More... | |
const Value | last () const |
Accessor for the last value of a range. More... | |
const Value | relaxed_last () const |
Accessor for the last value of a range. More... | |
void | resize (const Value &new_size) |
Sets the range size by adjusting the maximum value. More... | |
void | relaxed_resize (const Value &new_size) |
Sets the range size by adjusting the maximum value. More... | |
Static Public Member Functions | |
static Range | inin (const Value &v1, const Value &v2) |
Create a new range by giving the first (inclusive) and last value (inclusive). More... | |
static Value | minimum () |
Return the minimum possible value represented by this range. More... | |
static Value | maximum () |
Return the maximum possible value represented by this range. More... | |
static Range | all () |
Return a range that covers all possible values. More... | |
Protected Attributes | |
Value | r_first |
First value in range. More... | |
Value | r_last |
Last value in range. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &o, const Range &x) |
A contiguous range of values.
Represents a contiguous range of size
values beginning at begin
, and defines relationships between two ranges. The ranges are designed such that they can represent unsigned values up to and including the maximum possible values for the data type. However, this means that a range that represents all possible values will have a size() of zero due to overflow.
Floating point ranges are also possible (types "float" or "double") but the behavior of some methods differs slightly from integers. For instance, an integer range containing a single value has size 1, but a floating point range with one value has size zero. The differences are noted in the documentation for the particular methods affected.
Definition at line 46 of file rangemap.h.
Definition at line 48 of file rangemap.h.
A pair of ranges.
Definition at line 49 of file rangemap.h.
Create an empty range.
Ranges may have an empty size, but empty ranges will never appear inside a RangeMap object. The begin
value of an empty range is meaningless.
Definition at line 58 of file rangemap.h.
Referenced by Range< rose_addr_t >::intersect().
Create a new range of unit size.
The new range contains only the specified value.
Definition at line 62 of file rangemap.h.
Create a new range of specified size.
If size
is zero then an empty range is created. Note that a zero size is also returned for a range that contains all values, but this is due to overflow. Whether this is an integer range or a floating point range, if size is zero then the range is considered to be empty (but the first
value is remembered). To create a floating point range with a single value, use the single-argument constructor.
Definition at line 69 of file rangemap.h.
Create a new range from a different range.
Definition at line 81 of file rangemap.h.
Create a new range by giving the first (inclusive) and last value (inclusive).
This is the only way to create a range that contains all values since the size of such a range overflows the range's Value type. If the two values are equal then the created range contains only that value; if the first value is larger than the second then the range is considered to be empty.
Definition at line 88 of file rangemap.h.
Referenced by Range< rose_addr_t >::all(), Range< rose_addr_t >::erase(), RangeMap< Extent >::erase_ranges(), Range< rose_addr_t >::intersect(), RangeMap< Extent >::invert_within(), Range< rose_addr_t >::join(), and RangeMap< Extent >::minmax().
Accessor for the first value of a range.
It does not make sense to ask for the first value of an empty range, and an assertion will fail if such a request is made. However, relaxed_first() will return a value anyway.
Definition at line 99 of file rangemap.h.
Referenced by Range< rose_addr_t >::abuts_lt(), Range< rose_addr_t >::begins_after(), Range< rose_addr_t >::begins_before(), Range< rose_addr_t >::begins_with(), MemoryMap::Segment::check(), RangeMap< Extent >::check(), Range< rose_addr_t >::congruent(), Range< rose_addr_t >::contained_in(), Range< rose_addr_t >::contains(), RangeMap< Extent >::contains(), MemoryMap::dump(), Range< rose_addr_t >::erase(), RangeMap< Extent >::erase(), MemoryMap::erase_zeros(), MemoryMap::exists(), SgAsmGenericFile::fill_holes(), RegisterDictionary::filter_nonoverlapping(), MemoryMap::find_free(), MemoryMap::Segment::get_buffer_offset(), SgAsmGenericSection::get_referenced_extents(), Range< rose_addr_t >::inin(), MemoryMap::insert(), RangeMap< Extent >::insert(), Range< rose_addr_t >::intersect(), RangeMap< Extent >::invert_within(), Range< rose_addr_t >::left_of(), MemoryMap::Segment::merge(), MemoryMap::mprotect(), Partitioner::FindDataPadding::operator()(), Partitioner::FindData::operator()(), Partitioner::FindFunctionFragments::operator()(), Partitioner::FindThunkTables::operator()(), Partitioner::FindInterPadFunctions::operator()(), RangeMap< Extent >::overlaps(), MemoryMap::read1(), SgAsmGenericStrtab::reallocate(), Disassembler::search_next_address(), Disassembler::search_words(), MemoryMap::Segment::split(), MemoryMap::Segment::truncate(), RangeMapValue< Extent, Function * >::truncate(), SgAsmGenericSection::unparse(), and MemoryMap::write1().
Accessor for the first value of a range.
It does not make sense to ask for the first value of an empty range, and an assertion will fail if such a request is made. However, relaxed_first() will return a value anyway.
Definition at line 102 of file rangemap.h.
Referenced by Range< rose_addr_t >::abuts_gt(), Range< rose_addr_t >::begins_after(), Range< rose_addr_t >::begins_before(), Range< rose_addr_t >::begins_with(), Range< rose_addr_t >::congruent(), Range< rose_addr_t >::contained_in(), Range< rose_addr_t >::contains(), Range< rose_addr_t >::erase(), Range< rose_addr_t >::first(), Range< rose_addr_t >::intersect(), Range< rose_addr_t >::join(), Range< rose_addr_t >::print(), Range< rose_addr_t >::Range(), Range< rose_addr_t >::relaxed_first(), Range< rose_addr_t >::right_of(), and Range< rose_addr_t >::split_range_at().
Accessor for the first value of a range.
It does not make sense to ask for the first value of an empty range, and an assertion will fail if such a request is made. However, relaxed_first() will return a value anyway.
Definition at line 106 of file rangemap.h.
Referenced by ExtentMap::category(), Range< rose_addr_t >::relaxed_last(), Range< rose_addr_t >::relaxed_resize(), and SgAsmGenericFile::shift_extend().
Accessor for the last value of a range.
It does not make sense to ask for the last value of an empty range, and an assertion will fail if such a request is made. However, relaxed_last() will return a value anyway.
Definition at line 118 of file rangemap.h.
Referenced by Range< rose_addr_t >::abuts_gt(), Range< rose_addr_t >::congruent(), Range< rose_addr_t >::contained_in(), Range< rose_addr_t >::contains(), MemoryMap::dump(), Range< rose_addr_t >::ends_after(), Range< rose_addr_t >::ends_before(), Range< rose_addr_t >::ends_with(), Range< rose_addr_t >::erase(), RangeMap< Extent >::erase(), MemoryMap::exists(), MemoryMap::find_free(), Range< rose_addr_t >::inin(), RangeMap< Extent >::insert(), Range< rose_addr_t >::intersect(), RangeMap< Extent >::invert_within(), Range< rose_addr_t >::join(), MemoryMap::Segment::merge(), MemoryMap::mprotect(), Partitioner::FindDataPadding::operator()(), Partitioner::FindFunctionFragments::operator()(), Partitioner::FindThunkTables::operator()(), Partitioner::FindInterPadFunctions::operator()(), MemoryMap::read1(), Range< rose_addr_t >::right_of(), Disassembler::search_next_address(), Disassembler::search_words(), MemoryMap::Segment::truncate(), and RangeMapValue< Extent, Function * >::truncate().
Accessor for the last value of a range.
It does not make sense to ask for the last value of an empty range, and an assertion will fail if such a request is made. However, relaxed_last() will return a value anyway.
Definition at line 121 of file rangemap.h.
Referenced by Range< rose_addr_t >::abuts_lt(), Range< rose_addr_t >::congruent(), Range< rose_addr_t >::contained_in(), Range< rose_addr_t >::contains(), Range< rose_addr_t >::ends_after(), Range< rose_addr_t >::ends_before(), Range< rose_addr_t >::ends_with(), Range< rose_addr_t >::erase(), Range< rose_addr_t >::intersect(), Range< rose_addr_t >::last(), Range< rose_addr_t >::left_of(), Range< rose_addr_t >::print(), Range< rose_addr_t >::relaxed_last(), and Range< rose_addr_t >::split_range_at().
Accessor for the last value of a range.
It does not make sense to ask for the last value of an empty range, and an assertion will fail if such a request is made. However, relaxed_last() will return a value anyway.
Definition at line 125 of file rangemap.h.
Returns the number of values represented by the range.
Note that if the range contains all possible values then the returned size may be zero due to overflow, in which case the empty() method should also be called to make the determination.
Floating point range sizes are simply the last value minus the first value. Therefore, a singleton floating point range will return a size of zero, while a singleton integer range will return a size of one. This is actualy consistent behavior if you think of an integer value N as the floating point range [N,N+1), where N is included in the range but N+1 is not.
Definition at line 138 of file rangemap.h.
Referenced by ExtentMap::category(), MemoryMap::Segment::check(), MemoryMap::dump(), MemoryMap::erase_zeros(), SgAsmGenericFile::fill_holes(), RegisterDictionary::filter_nonoverlapping(), SgAsmGenericSection::get_referenced_extents(), Partitioner::FindDataPadding::operator()(), Partitioner::FindData::operator()(), SgAsmGenericStrtab::reallocate(), SgAsmGenericFile::shift_extend(), and SgAsmGenericSection::unparse().
Sets the range size by adjusting the maximum value.
It is an error to change the size of a range from zero to non-zero, but the relaxed_resize() is available for that purpose.
Setting the size to zero causes different behavior for integer ranges than it does for floating point ranges. For integer ranges, setting the size to zero clears the range (makes it empty); for floating point ranges, setting the size to zero causes the range to contain only the starting value. Floating point ranges can be cleared by setting the new size to a negative value. The clear() method should be favored over resize() for making a range empty.
Definition at line 153 of file rangemap.h.
Referenced by Partitioner::FindDataPadding::operator()().
Sets the range size by adjusting the maximum value.
It is an error to change the size of a range from zero to non-zero, but the relaxed_resize() is available for that purpose.
Setting the size to zero causes different behavior for integer ranges than it does for floating point ranges. For integer ranges, setting the size to zero clears the range (makes it empty); for floating point ranges, setting the size to zero causes the range to contain only the starting value. Floating point ranges can be cleared by setting the new size to a negative value. The clear() method should be favored over resize() for making a range empty.
Definition at line 162 of file rangemap.h.
Split a range into two parts.
Returns a pair of adjacent ranges such that at
is the first value of the second returned range. The split point must be such that neither range is empty.
Definition at line 175 of file rangemap.h.
Referenced by RangeMap< Extent >::contains(), and RangeMap< Extent >::erase().
Joins two adjacent ranges.
This range must be the left range, and the argument is the right range. They must be adjacent without overlapping. If one of the ranges is empty, then the return value is the other range (which might also be empty).
Definition at line 186 of file rangemap.h.
Referenced by RangeMap< Extent >::insert().
Erase part of a range to return zero, one, or two new ranges.
The possible situations are:
Definition at line 209 of file rangemap.h.
Intersection of two ranges.
Definition at line 225 of file rangemap.h.
|
inline |
Returns true if this range is empty.
Note that many of the range comparison methods have special cases for empty ranges. Note that due to overflow, the size() method may return zero for integer ranges if this range contains all possible values. It follows, then that the expressions "empty()" and "0==size()" are not always equal.
Definition at line 240 of file rangemap.h.
Referenced by Range< rose_addr_t >::abuts_gt(), Range< rose_addr_t >::abuts_lt(), Range< rose_addr_t >::begins_after(), Range< rose_addr_t >::begins_before(), Range< rose_addr_t >::begins_with(), MemoryMap::Segment::check(), RangeMap< Extent >::check(), Range< rose_addr_t >::clear(), Range< rose_addr_t >::congruent(), Range< rose_addr_t >::contained_in(), Range< rose_addr_t >::contains(), RangeMap< Extent >::contains(), Range< rose_addr_t >::distinct(), Range< rose_addr_t >::ends_after(), Range< rose_addr_t >::ends_before(), Range< rose_addr_t >::ends_with(), Range< rose_addr_t >::erase(), RangeMap< Extent >::erase(), MemoryMap::exists(), Range< rose_addr_t >::first(), RangeMap< Extent >::insert(), Range< rose_addr_t >::intersect(), RangeMap< Extent >::invert_within(), Range< rose_addr_t >::join(), Range< rose_addr_t >::last(), Range< rose_addr_t >::left_of(), MemoryMap::Segment::merge(), RangeMapValue< Extent, Function * >::merge(), MemoryMap::mprotect(), Partitioner::FindDataPadding::operator()(), Partitioner::FindThunkTables::operator()(), Range< rose_addr_t >::overlaps(), RangeMap< Extent >::overlaps(), Range< rose_addr_t >::print(), Range< rose_addr_t >::Range(), Range< rose_addr_t >::relaxed_first(), Range< rose_addr_t >::relaxed_last(), Range< rose_addr_t >::relaxed_resize(), MemoryMap::Segment::removing(), RangeMapValue< Extent, Function * >::removing(), Range< rose_addr_t >::resize(), Range< rose_addr_t >::right_of(), RangeMap< Extent >::select_overlapping_ranges(), Range< rose_addr_t >::size(), and Range< rose_addr_t >::split_range_at().
|
inline |
Make a range empty.
An empty range is one in which r_first is greater than r_last. We make special provisions here so that relaxed_first() will continue to return the same value as it did before the range was set to empty.
Definition at line 246 of file rangemap.h.
Referenced by Range< rose_addr_t >::Range(), Range< rose_addr_t >::relaxed_resize(), Range< rose_addr_t >::resize(), and SgAsmGenericFile::shift_extend().
Do both ranges begin at the same place?
An empty range never begins with any other range, including other empty ranges.
Definition at line 261 of file rangemap.h.
Referenced by RangeMap< Extent >::check().
Do both ranges end at the same place?
An empty range never ends with any other range, including other empty ranges.
Definition at line 270 of file rangemap.h.
Referenced by RangeMap< Extent >::check().
|
inline |
Does this range begin (strictly) after the beginning of another range?
An empty range never begins after any other range, including other empty ranges.
Definition at line 279 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), and RangeMap< Extent >::erase().
|
inline |
Does this range begin (strictly) before the beginning of another range?
An empty range never begins before any other range, including other empty ranges.
Definition at line 288 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), RangeMap< Extent >::contains(), Range< rose_addr_t >::erase(), MemoryMap::exists(), SgAsmGenericSection::get_referenced_extents(), and MemoryMap::mprotect().
|
inline |
Does this range end (strictly) after the end of another range?
An empty range never ends after any other range, including other empty ranges.
Definition at line 297 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), Range< rose_addr_t >::erase(), and SgAsmGenericSection::get_referenced_extents().
|
inline |
Does this range end (strictly) before the end of another range?
An empty range never ends before any other range, including other empty ranges.
Definition at line 306 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), RangeMap< Extent >::contains(), and RangeMap< Extent >::erase().
|
inline |
Does this range contain the argument range?
The argument is contained in this range if the argument starts at or after the start of this range and ends at or before the end of this range. If strict
is true, then the comparisons do not include equality. An empty range does not contain any other range, including other empty ranges.
Definition at line 317 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), RangeMap< Extent >::erase(), MemoryMap::Segment::get_buffer_offset(), SgAsmGenericSection::get_referenced_extents(), Range< rose_addr_t >::intersect(), MemoryMap::mprotect(), MemoryMap::read1(), Partitioner::FunctionRangeMapValue::split(), Partitioner::DataRangeMapValue::split(), and MemoryMap::write1().
|
inline |
Is this range contained in the argument range?
This range is contained in the argument range if this range starts at or after the start of the argument and ends at or before the end of the argument. If strict
is true, then the comparisons do not include equality. An empty range does not contain any other range, including other empty ranges.
Definition at line 328 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), Range< rose_addr_t >::erase(), RangeMap< Extent >::erase(), and SgAsmGenericSection::get_referenced_extents().
Are two ranges equal?
They are equal if the start and end at the same place or if they are both empty.
Definition at line 337 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), Range< rose_addr_t >::operator!=(), and Range< rose_addr_t >::operator==().
Is this range left of the argument range?
This range is left of the argument range if this range ends before the start of the argument. They may adjoin, but must not overlap. An empty range is never left of any other range, including other empty ranges.
Definition at line 347 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), RangeMap< Extent >::erase(), SgAsmGenericSection::get_referenced_extents(), RangeMap< Extent >::invert_within(), Range< rose_addr_t >::overlaps(), and RangeMap< Extent >::select_overlapping_ranges().
Is this range right of the argument range?
This range is right of the argument range if this range starts after the end of the argument range. They may adjoin, but must not overlap. An empty range is never right of any other range, including other empty ranges.
Definition at line 357 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), SgAsmGenericSection::get_referenced_extents(), and Range< rose_addr_t >::overlaps().
Does this range overlap with the argument range?
An empty range does not overlap with any other rance, including other empty ranges.
Definition at line 366 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), RangeMap< Extent >::contains(), Range< rose_addr_t >::distinct(), MemoryMap::insert(), RangeMap< Extent >::insert(), Range< rose_addr_t >::intersect(), RangeMap< Extent >::overlaps(), and RangeMap< Extent >::select_overlapping_ranges().
Is this range non-overlapping with the argument range?
In other words, do the two ranges represent distinct sets of values? An empty range is always distinct from all other ranges (including other empty ranges).
Definition at line 376 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), and Range< rose_addr_t >::erase().
Is this range immediately left of the argument range?
Returns true if this range ends at the beginning of the argument, with no overlap and no space between them. An empty range does not abut any other range, including other empty ranges.
Definition at line 386 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), RangeMap< Extent >::insert(), Range< rose_addr_t >::join(), and MemoryMap::Segment::merge().
Is this range immediately right of the argument range?
Returns true if this range begins at the end of the argument, with no overlap and no space between them. An empty range does not abut any other range, including other empty ranges.
Definition at line 396 of file rangemap.h.
Referenced by RangeMap< Extent >::check(), RangeMap< Extent >::insert(), and MemoryMap::Segment::merge().
Return the minimum possible value represented by this range.
Definition at line 403 of file rangemap.h.
Referenced by Range< rose_addr_t >::all(), and RangeMap< Extent >::insert().
Return the maximum possible value represented by this range.
Definition at line 408 of file rangemap.h.
Referenced by Range< rose_addr_t >::all(), Range< rose_addr_t >::clear(), and RangeMap< Extent >::insert().
Return a range that covers all possible values.
Definition at line 413 of file rangemap.h.
Referenced by RangeMap< Extent >::invert().
Definition at line 417 of file rangemap.h.
Definition at line 420 of file rangemap.h.
|
inline |
Definition at line 424 of file rangemap.h.
bool Range< double >::empty | ( | ) | const |
void Range< double >::clear | ( | ) |
const double Range< double >::relaxed_first | ( | ) | const |
double Range< double >::size | ( | ) | const |
void Range< double >::resize | ( | const double & | new_size) |
void Range< double >::relaxed_resize | ( | const double & | new_size) |
double Range< double >::minimum | ( | ) |
double Range< double >::maximum | ( | ) |
bool Range< float >::empty | ( | ) | const |
void Range< float >::clear | ( | ) |
const float Range< float >::relaxed_first | ( | ) | const |
float Range< float >::size | ( | ) | const |
void Range< float >::resize | ( | const float & | new_size) |
void Range< float >::relaxed_resize | ( | const float & | new_size) |
float Range< float >::minimum | ( | ) |
float Range< float >::maximum | ( | ) |
|
friend |
Definition at line 434 of file rangemap.h.
First value in range.
Definition at line 52 of file rangemap.h.
Referenced by Range< rose_addr_t >::clear(), Range< rose_addr_t >::empty(), Range< rose_addr_t >::first(), Range< rose_addr_t >::relaxed_first(), Range< rose_addr_t >::relaxed_resize(), Range< rose_addr_t >::resize(), and Range< rose_addr_t >::size().
Last value in range.
Definition at line 53 of file rangemap.h.
Referenced by Range< rose_addr_t >::clear(), Range< rose_addr_t >::empty(), Range< rose_addr_t >::last(), Range< rose_addr_t >::Range(), Range< rose_addr_t >::relaxed_first(), Range< rose_addr_t >::relaxed_resize(), Range< rose_addr_t >::resize(), and Range< rose_addr_t >::size().