compiler/shared/l0/stdlib/std/array.l0
Module std.array
Overview Symbols grouped by source file: compiler/shared/l0/stdlib/std/array.l0
Module: std.array
Source: compiler/shared/l0/stdlib/std/array.l0 Language: Dea/L0
Imports / Includes
std.stringstd.assertsys.memorysys.rt
Symbols
- arr_create
- arr_check
- arr_resize
- arr_get
- arr_zap
- arr_free
- ba_create
- ba_capacity
- ba_get
- ba_set
- ba_zap
- ba_free
- ArrayBase
- ByteArray
Function arr_create
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
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
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
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
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
func arr_free(self: ArrayBase*)
Free an ArrayBase and its element storage.
Parameters:
self: Array to free.
Function ba_create
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
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
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
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
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
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
capacity: int
ArrayBase Field element_size
element_size: int
ArrayBase Field data
data: void*
Struct ByteArray
Byte-specialized fixed-size array wrapper.
ByteArray Field storage
storage: ArrayBase*