class documentation

class RegisterSlice:

View In Hierarchy

This class represents a bitwise register slice as defined by a register, its start bit and bit count.

Method __and__ Computes the intersection of this slice with another of the same register.
Method __contains__ Returns whether or not the passed register or slice is contained in self.
Method __eq__ Compares the instance for equality with an object.
Method __hash__ Returns the hash for this value.
Method __init__ Initializes a RegisterSlice
Method __len__ Returns the size of this slice in bits, which is at least 1 (empty slices are not allowed).
Method __ne__ Compares the instance for equality with an object.
Method __or__ Computes the union of this slice with another of the same register.
Method __repr__ Returns the "official" string representation of this instance.
Method __str__ Returns the nicely printable string representation of this instance.
Method __sub__ Computes the difference of this slice with another of the same register.
Method canonicalize Returns the equal register slice of the root register of this register.
Method difference Computes the difference of this slice with another of the same register.
Method flags An iterator over the individual flag registers contained in this slice.
Method intersection Computes the intersection of this slice with another of the same register.
Method is_canonical Whether this register is in its canonical form.
Method is_minimal Whether this register is in its minimal form.
Method is_same_form Whether this slice is under the same form (same register alias and same begin/end) as the other.
Method isdisjoint Returns whether or not there exists no bit contained both in self and in other.
Method issubset Returns whether or not all bits of self are contained in other.
Method issuperset Returns whether or not all bits of other are contained in self.
Method minimize Returns the equal register slice of the smallest register that can fit this slice.
Method union Computes the union of this slice with another of the same register.
Property begin The index of the first bit in the slice.
Property end The index of the first bit not in the slice.
Property is_aligned Property: Whether this slice is aligned at the byte boundaries.
Property is_full Property: Whether this slice contains its entire register.
Property register Property: The sliced register.
Property size Property: The size of the slice, in bits.
Property size_bytes Property: The minimal number of bytes required to hold this slice.
Instance Variable _begin Undocumented
Instance Variable _register Undocumented
Instance Variable _size Undocumented
def __and__(self, other):

Computes the intersection of this slice with another of the same register.

The intersection is defined as the biggest subslice that is both contained in self and in other.

If such slice would be empty, None is returned.

The intersection is always returned in the canonical form.

Parameters
other:_Optional[RegisterSlice]Undocumented
Returns
_Optional[RegisterSlice]Undocumented
def __contains__(self, x):

Returns whether or not the passed register or slice is contained in self.

A register is considered as contained in a slice if it fully fits the slice.

A slice is considered as contained in another if it is a subset of that other slice.

Parameters
x:_Union[_Register, RegisterSlice]Undocumented
Returns
boolUndocumented
def __eq__(self, other):

Compares the instance for equality with an object.

Returns
boolUndocumented
def __hash__(self):

Returns the hash for this value.

Returns
intUndocumented
def __init__(self, register, begin=0, size=None):

Initializes a RegisterSlice

Information

Parameters
register:_RegisterThe sliced register.
begin:intThe beginning bit of the slice. Defaults to 0.
size:_Optional[int]The size of the slice, in bits. Defaults register.size_bits - begin.
Raises
IndexErrorif size <= 0 or size + begin > register.size_bits.
def __len__(self):

Returns the size of this slice in bits, which is at least 1 (empty slices are not allowed).

Returns
intUndocumented
def __ne__(self, other):

Compares the instance for equality with an object.

Returns
boolUndocumented
def __or__(self, other):

Computes the union of this slice with another of the same register.

The union is defined as the smallest slice that contains both self and other, but no other bit of the register.

If self and other are disjoint and not contiguous, then None is returned.

The union is always returned in the canonical form.

Parameters
other:_Optional[RegisterSlice]Undocumented
Returns
_Optional[RegisterSlice]Undocumented
def __repr__(self):

Returns the "official" string representation of this instance.

Returns
strUndocumented
def __str__(self):

Returns the nicely printable string representation of this instance.

Returns
strUndocumented
def __sub__(self, other):

Computes the difference of this slice with another of the same register.

The difference is defined as a pair of slices such that:

  • The first slice contains all bits of self that are before the first bit of other.
  • The second slice contains all bits of self that are after the last bit of other.

If any of these ranges would be empty, then None is returned in its stead.

Each returned slice is in the canonical form.

Note: if other slices a different register from self, the pair of slices will contain self.canonicalize() and None.

Parameters
other:_Optional[RegisterSlice]Undocumented
Returns
_Tuple[_Optional[RegisterSlice], _Optional[RegisterSlice]]Undocumented
def canonicalize(self):

Returns the equal register slice of the root register of this register.

Returns
RegisterSliceUndocumented
def difference(self, other):

Computes the difference of this slice with another of the same register.

The difference is defined as a pair of slices such that:

  • The first slice contains all bits of self that are before the first bit of other.
  • The second slice contains all bits of self that are after the last bit of other.

If any of these ranges would be empty, then None is returned in its stead.

Each returned slice is in the canonical form.

Note: if other is disjoint from self, the pair of slices will contain self.canonicalize() and None.

Parameters
other:_Optional[RegisterSlice]Undocumented
Returns
_Tuple[_Optional[RegisterSlice], _Optional[RegisterSlice]]Undocumented
def flags(self):

An iterator over the individual flag registers contained in this slice.

Returns an empty iterator if no flag is contained in this slice (e.g., because it is rax and not a flag register).

Returns
_Iterator[RegisterSlice]Undocumented
def intersection(self, other):

Computes the intersection of this slice with another of the same register.

The intersection is defined as the biggest subslice that is both contained in self and in other.

If such slice would be empty, None is returned.

The intersection is always returned in the canonical form.

Parameters
other:_Optional[RegisterSlice]Undocumented
Returns
_Optional[RegisterSlice]Undocumented
def is_canonical(self):

Whether this register is in its canonical form.

Returns
boolUndocumented
def is_minimal(self):

Whether this register is in its minimal form.

Returns
boolUndocumented
def is_same_form(self, other):

Whether this slice is under the same form (same register alias and same begin/end) as the other.

Parameters
other:RegisterSliceUndocumented
Returns
boolUndocumented
def isdisjoint(self, other):

Returns whether or not there exists no bit contained both in self and in other.

Parameters
other:RegisterSliceUndocumented
Returns
boolUndocumented
def issubset(self, other):

Returns whether or not all bits of self are contained in other.

Parameters
other:RegisterSliceUndocumented
Returns
boolUndocumented
def issuperset(self, other):

Returns whether or not all bits of other are contained in self.

Parameters
other:RegisterSliceUndocumented
Returns
boolUndocumented
def minimize(self, to=None):

Returns the equal register slice of the smallest register that can fit this slice.

Parameters
to:_RegisterUndocumented
Returns
RegisterSliceUndocumented
def union(self, other):

Computes the union of this slice with another of the same register.

The union is defined as the smallest slice that contains both self and other, but no other bit of the register.

If self and other are disjoint and not contiguous, then None is returned.

The union is always returned in the canonical form.

Parameters
other:_Optional[RegisterSlice]Undocumented
Returns
_Optional[RegisterSlice]Undocumented
@property
begin: int =

The index of the first bit in the slice.

@property
end: int =

The index of the first bit not in the slice.

@property
is_aligned: bool =

Property: Whether this slice is aligned at the byte boundaries.

@property
is_full: bool =

Property: Whether this slice contains its entire register.

@property
register: _Register =

Property: The sliced register.

@property
size: int =

Property: The size of the slice, in bits.

@property
size_bytes: int =

Property: The minimal number of bytes required to hold this slice.

_begin =

Undocumented

_register =

Undocumented

_size =

Undocumented