array.l0

array.l0

Module: std.array

Source: compiler/shared/l0/stdlib/std/array.l0 Language: Dea/L0

Imports / Includes

  • std.string
  • std.assert
  • sys.memory
  • sys.rt

Symbols

Function arr_create

1
func arr_create(element_size: int, length: int) -> ArrayBase*

Creates a new ArrayBase with the specified element size and length.

Parameters:

  • element_size: The size of each element in bytes.
  • length: The number of elements in the array.

Returns: A pointer to the newly created ArrayBase.

Function arr_check

1
func arr_check(self: ArrayBase*, index: int)

Checks if the given index is within the bounds of the array.

Parameters:

  • self: The pointer to the ArrayBase.
  • index: The index to check.

Function arr_resize

1
func arr_resize(self: ArrayBase*, new_length: int)

Resizes the array to a new length.

Parameters:

  • self: The pointer to the ArrayBase.
  • new_length: The new length of the array.

Function arr_get

1
func arr_get(self: ArrayBase*, index: int) -> void*

Returns a pointer to the element at the specified index.

Parameters:

  • self: The pointer to the ArrayBase.
  • index: The index of the element.

Returns: A pointer to the element.

Function arr_zap

1
func arr_zap(self: ArrayBase*, index: int)

Zeros out the element at the specified index.

Parameters:

  • self: The pointer to the ArrayBase.
  • index: The index of the element to zap.

Function arr_free

1
func arr_free(self: ArrayBase*)

Free an ArrayBase and its element storage.

Parameters:

  • self: Array to free.

Function ba_create

1
func ba_create(length: int) -> ByteArray*

Create a fixed-size byte array.

Parameters:

  • length: Number of bytes to allocate.

Returns: New byte array wrapper.

Function ba_capacity

1
func ba_capacity(self: ByteArray*) -> int

Return the capacity of a byte array.

Parameters:

  • self: Byte array to inspect.

Returns: Number of byte slots.

Function ba_get

1
func ba_get(self: ByteArray*, index: int) -> byte

Return one byte from the array.

Parameters:

  • self: Byte array to inspect.
  • index: Byte index to read.

Returns: Byte value at index.

Function ba_set

1
func ba_set(self: ByteArray*, index: int, value: byte)

Store one byte into the array.

Parameters:

  • self: Byte array to update.
  • index: Byte index to write.
  • value: Byte value to store.

Function ba_zap

1
func ba_zap(self: ByteArray*, index: int)

Zero one byte slot in the array.

Parameters:

  • self: Byte array to update.
  • index: Byte index to clear.

Function ba_free

1
func ba_free(self: ByteArray*)

Free a byte array and its backing storage.

Parameters:

  • self: Byte array to free.

Struct ArrayBase

ArrayBase implements an array of elements of a given size.

Elements can be accessed via index, and the array can be resized on demand. See VectorBase for a dynamic array implementation.

Note: This is a low-level implementation and does not provide type safety. It is the caller’s responsibility to manage types and casting.

ArrayBase Field capacity

1
capacity: int

ArrayBase Field element_size

1
element_size: int

ArrayBase Field data

1
data: void*

Struct ByteArray

Byte-specialized fixed-size array wrapper.

ByteArray Field storage

1
storage: ArrayBase*