class documentation

class ArrayInstance(_Generic[_ValueType]):

View In Hierarchy

An array instance, the result of reading an array.

Access the elements of the array as a list with the ArrayInstance.list method, or with a list conversion.

Method __eq__ Compares the instance for equality with an object.
Method __getitem__ Returns an item of the array from its index, or a subslice of this instance.
Method __hash__ Returns the hash for this value.
Method __init__ Initializes a new array instance from its array type, its list of elements and the context it was read at.
Method __iter__ Iterates over the elements of the array.
Method __len__ Get the number of elements of the array.
Method __ne__ Compares the instance for equality with an object.
Method assert_array Asserts to the type system that this array produces array values.
Method assert_bool Asserts to the type system that this array produces boolean values.
Method assert_enum Asserts to the type system that this array produces enum values.
Method assert_float Asserts to the type system that this array produces float values.
Method assert_int Asserts to the type system that this array produces integer values.
Method assert_ptr Asserts to the type system that this array produces pointer values.
Method assert_struct Asserts to the type system that this array produces struct values.
Method list Produces the values of this instance as a list, whose type of element is determined by the type of this instance.
Method list_bytes Produces the values of this instance as a list of byte buffers.
Method slice Returns a new instance that is a slice of the current instance.
Method slice_str Returns the value of this instance, interpreted as a null-terminated string.
Method to_bytes Returns the value of this instance, interpreted as the bytes it is composed of.
Class Variable SubArrayValueType Undocumented
Class Variable SubPointerValueType Undocumented
Property context The context where this instance was spawned at.
Property count The number of elements of the array.
Property type The type of the instance.
Instance Variable _array Undocumented
Instance Variable _ctx Undocumented
Instance Variable _elements Undocumented
def __eq__(self, o):

Compares the instance for equality with an object.

  • if the object is of type ArrayInstance, it will be considered equal to this instance if it has the same array type (including the number of elements) and the same elements.
  • if the object can be converted to a list, it will be considered equal to this instance if it has the same elements.
  • if the object is none of the types above, then it will never be considered equal.

Note

  • The context where this enum was spawned at is never taken into consideration for the purpose of equality. This means that two ArrayInstances at different contexts with the same type and values will be considered equal.
  • Similarly, the source from which the instance was read is never taken into consideration for the purpose of equality. This means that two ArrayInstances coming from different addresses in memory or different registers can compare equal if they have the same type and values.
Returns
boolUndocumented
def __getitem__(self, item):

Returns an item of the array from its index, or a subslice of this instance.

Information

Parameters
item:_Union[int, slice]the index of the item in the list, or a slice object indicating the bounds of the subslice.
Returns
_Union[_ValueType, ArrayInstance[_ValueType]]a value of the type produced by the inner type of the array, or a subslice of the same instance.
Raises
IndexErrorif the index is out of bounds.
def __hash__(self):

Returns the hash for this value.

Returns
intUndocumented
def __init__(self, array, elements, ctx):

Initializes a new array instance from its array type, its list of elements and the context it was read at.

Warnings

At the moment, this object is not meant to be constructed directly. Use FieldInstance.read instead.

Parameters
array:_ArrayUndocumented
elements:_List[_ValueType]Undocumented
ctx:_trace.ContextUndocumented
def __iter__(self):

Iterates over the elements of the array.

Returns
_Iterator[_ValueType]Undocumented
def __len__(self):

Get the number of elements of the array.

Returns
intUndocumented
def __ne__(self, o):

Compares the instance for equality with an object.

  • if the object is of type ArrayInstance, it will be considered equal to this instance if it has the same array type (including the number of elements) and the same elements.
  • if the object can be converted to a list, it will be considered equal to this instance if it has the same elements.
  • if the object is none of the types above, then it will never be considered equal.

Note

  • The context where this enum was spawned at is never taken into consideration for the purpose of equality. This means that two ArrayInstances at different contexts with the same type and values will be considered equal.
  • Similarly, the source from which the instance was read is never taken into consideration for the purpose of equality. This means that two ArrayInstances coming from different addresses in memory or different registers can compare equal if they have the same type and values.
Returns
boolUndocumented
def assert_array(self):

Asserts to the type system that this array produces array values.

Information

Returns
ArrayInstance[ArrayInstance]this instance, with the additional type information that it produces array values.
Raises
ValueErrorif this instance does not, in fact, produce array values, according to its runtime type.
def assert_bool(self):

Asserts to the type system that this array produces boolean values.

Information

Returns
ArrayInstance[bool]this instance, with the additional type information that it produces boolean values.
Raises
ValueErrorif this instance does not, in fact, produce boolean values, according to its runtime type.
def assert_enum(self):

Asserts to the type system that this array produces enum values.

Information

Returns
ArrayInstance[EnumerationInstance]this instance, with the additional type information that it produces enum values.
Raises
ValueErrorif this instance does not, in fact, produce enum values, according to its runtime type.
def assert_float(self):

Asserts to the type system that this array produces float values.

Information

Returns
ArrayInstance[float]this instance, with the additional type information that it produces float values.
Raises
ValueErrorif this instance does not, in fact, produce float values, according to its runtime type.
def assert_int(self):

Asserts to the type system that this array produces integer values.

Information

Returns
ArrayInstance[int]this instance, with the additional type information that it produces integer values.
Raises
ValueErrorif this instance does not, in fact, produce integer values, according to its runtime type.
def assert_ptr(self):

Asserts to the type system that this array produces pointer values.

Information

Returns
ArrayInstance[PointerInstance]this instance, with the additional type information that it produces pointer values.
Raises
ValueErrorif this instance does not, in fact, produce pointer values, according to its runtime type.
def assert_struct(self):

Asserts to the type system that this array produces struct values.

Information

Returns
ArrayInstance[StructInstance]this instance, with the additional type information that it produces struct values.
Raises
ValueErrorif this instance does not, in fact, produce struct values, according to its runtime type.
def list(self):

Produces the values of this instance as a list, whose type of element is determined by the type of this instance.

Returns
_List[_ValueType]Undocumented
def list_bytes(self):

Produces the values of this instance as a list of byte buffers.

Returns
_List[bytes]Undocumented
def slice(self, offset=0, size=None):

Returns a new instance that is a slice of the current instance.

Information

Parameters
offset:intthe first element in the subslice.
size:_Optional[int]the number of elements in the subslice. If None, then the maximum amount of elements.
Returns
ArrayInstance[_ValueType]an instance containing the selected elements.
def slice_str(self, cstring):

Returns the value of this instance, interpreted as a null-terminated string.

Information

Parameters
cstring:_CStringallows to specify the encoding and maximum size of the string to read.
Returns
strthe value pointed to by this field, as a string.
Raises
ValueErrorif, according to its runtime type, this field does not produce a pointer value.
EncodingErrorif the bytes pointed to by the field contain errors wrt to the specified encoding.
def to_bytes(self):

Returns the value of this instance, interpreted as the bytes it is composed of.

Information

Returns
bytesa buffer of bytes of size self.count * self.type.inner.size_bytes(self.context).
SubArrayValueType =

Undocumented

SubPointerValueType =

Undocumented

@property
context: _trace.Context =

The context where this instance was spawned at.

@property
count: int =

The number of elements of the array.

@property
type: _Array =

The type of the instance.

_array =

Undocumented

_ctx =

Undocumented

_elements =

Undocumented