List

Module

Provides utilities for working with static and variadic lists.

Dim

A static or dynamic dimension modeled with an optional integer.

This class is meant to represent an optional static dimension. When a value is present, the dimension has that static value. When a value is not present, the dimension is dynamic.

Aliases:

  • type = Variant[i1, Int]

Fields:

value

Either a boolean indicating that the dimension is dynamic, or the static value of the dimension.

Functions:

__init__

__init__(value: Int) -> Self

Create a statically-known dimension.

Args:

  • value (Int): The static dimension value.

Returns:

A dimension with a static value.

__init__(value: index) -> Self

Create a statically-known dimension.

Args:

  • value (index): The static dimension value.

Returns:

A dimension with a static value.

__init__() -> Self

Create a dynamic dimension.

Returns:

A dimension value with no static value.

__init__(value: Variant[i1, Int]) -> Self

__bool__

__bool__(self: Self) -> Bool

Return True if the dimension has a static value.

Returns:

Whether the dimension has a static value.

__eq__

__eq__(self: Self, rhs: Self) -> Bool

Compare two dimensions for equality.

Args:

  • rhs (Self): The other dimension.

Returns:

True if the dimensions are the same.

__mul__

__mul__(self: Self, rhs: Self) -> Self

Multiply two dimensions.

If either are unknown, the result is unknown as well.

Args:

  • rhs (Self): The other dimension.

Returns:

The product of the two dimensions.

get

get(self: Self) -> Int

Get the static dimension value.

Returns:

The static dimension value.

has_value

has_value(self: Self) -> Bool

Return True if the dimension has a static value.

Returns:

Whether the dimension has a static value.

is_dynamic

is_dynamic(self: Self) -> Bool

Return True if the dimension has a dynamic value.

Returns:

Whether the dimension is dynamic.

is_multiple

is_multiple[alignment: Int](self: Self) -> Bool

Check if the dimension is aligned.

Parameters:

  • alignment (Int): The alignment requirement.

Returns:

Whether the dimension is aligned.

DimList

This type represents a list of dimensions. Each dimension may have a static value or not have a value, which represents a dynamic dimension.

Fields:

value

The underlying storage for the list of dimensions.

Functions:

__init__

__init__(values: VariadicList[Dim]) -> Self

Create a dimension list from the given list of values.

Args:

  • values (VariadicList[Dim]): The initial dim values list.

Returns:

A dimension list.

__init__(*values: Dim) -> Self

Create a dimension list from the given Dim values.

Args:

  • values (*Dim): The initial dim values.

Returns:

A dimension list.

all_known

all_known[length: Int](self: Self) -> Bool

Determine whether all dimensions are statically known.

Parameters:

  • length (Int): The number of elements in the list.

Returns:

True if all dimensions have a static value.

at

at[i: Int](self: Self) -> Dim

Get the dimension at a specified index.

Parameters:

  • i (Int): The dimension index.

Returns:

The dimension at the specified index.

contains

contains[length: Int](self: Self, value: Dim) -> Bool

Determine whether the dimension list contains a specified dimension value.

Parameters:

  • length (Int): The number of elements in the list.

Args:

  • value (Dim): The value to find.

Returns:

True if the list contains a dimension of the specified value.

create_unknown

create_unknown[length: Int]() -> Self

Create a dimension list of all dynamic dimension values.

Parameters:

  • length (Int): The number of elements in the list.

Returns:

A list of all dynamic dimension values.

product

product[length: Int](self: Self) -> Dim

Compute the product of all the dimensions in the list.

If any are dynamic, the result is a dynamic dimension value.

Parameters:

  • length (Int): The number of elements in the list.

Returns:

The product of all the dimensions.

product_range

product_range[start: Int, end: Int](self: Self) -> Dim

Compute the product of a range of the dimensions in the list.

If any in the range are dynamic, the result is a dynamic dimension value.

Parameters:

  • start (Int): The starting index.
  • end (Int): The end index.

Returns:

The product of all the dimensions.

VariadicList

A utility class to access variadic function arguments. Provides a “list” view of the function argument so that the size of the argument list and each individual argument can be accessed.

Parameters:

  • type (AnyType): The type of the elements in the list.

Aliases:

  • StorageType = variadic<type>

Fields:

value

The underlying storage for the variadic list.

Functions:

__init__

__init__(*value: type) -> Self

Constructs a VariadicList from a variadic list of arguments.

Args:

  • value (*type): The variadic argument list to construct the variadic list with.

Returns:

The VariadicList constructed.

__init__(*value: type) -> Self

Constructs a VariadicList from a variadic argument type.

Args:

  • value (*type): The variadic argument to construct the list with.

Returns:

The VariadicList constructed.

__getitem__

__getitem__(self: Self, index: Int) -> type

Accessor to a single element on the variadic list.

Args:

  • index (Int): The index of the element to access on the list.

Returns:

The element on the list corresponding to the given index.

__len__

__len__(self: Self) -> Int

Gets the size of the list.

Returns:

The number of elements on the variadic list.

VariadicListMem

A utility class to access variadic function arguments of memory-only types that may have ownership. It exposes pointers to the elements in a way that can be enumerated. Each element may be accessed with __get_address_as_lvalue.

Parameters:

  • type (AnyType): The type of the elements in the list.

Aliases:

  • StorageType = variadic<!pop.pointer<type>>

Fields:

value

The underlying storage, a variadic list of pointers to elements of the given type.

Functions:

__init__

__init__(*value: pointer<type>) -> Self

Constructs a VariadicList from a variadic argument type.

Args:

  • value (*pointer<type>): The variadic argument to construct the list with.

Returns:

The VariadicList constructed.

__getitem__

__getitem__(self: Self, index: Int) -> pointer<type>

Accessor to a single element on the variadic list.

Args:

  • index (Int): The index of the element to access on the list.

Returns:

A low-level pointer to the element on the list corresponding to the given index.

__len__

__len__(self: Self) -> Int

Gets the size of the list.

Returns:

The number of elements on the variadic list.