sun::types::ArrayType

sun::types::ArrayType

class · Source (opens in a new tab)

class sun::types::ArrayType : public sun::types::Type

Array type: array<T, N> or array<T, M, N> for multi-dimensional.

A sized array OWNS its elements inline - [N x T] wherever it lives (a local, a field, a global, an element of another array) - and moves like every other compound value. An unsized array<T> (empty dimensions) is a view of some sized array with the rank erased; it exists only behind ref and is carried as the fat struct { ptr data, i32 ndims, ptr dims }.

Inherits

Public Functions

ArrayType

public · function · Source (opens in a new tab)

sun::types::ArrayType::ArrayType(TypePtr elemType, std::vector< size_t > dims)

Creates a fixed-size array type with the supplied element type and dimensions.

Related: TypePtr

equals

public · function · Source (opens in a new tab)

bool sun::types::ArrayType::equals(const Type &other) const override

Reports whether the other type has the same semantic identity.

Related: Type

getArrayStructType

public · function · static · Source (opens in a new tab)

static llvm::StructType * sun::types::ArrayType::getArrayStructType(llvm::LLVMContext &ctx)

The view struct { ptr data, i32 ndims, ptr dims } that a ref array<T> is carried as: the element storage, the rank, and the dimension sizes (an i64 table that outlives the view - a private constant global).

getDataStorageType

public · function · Source (opens in a new tab)

llvm::Type * sun::types::ArrayType::getDataStorageType(llvm::LLVMContext &ctx) const

The inline storage type of a sized array: [3 x [2 x i32]] for array<i32, 3, 2>.

Null for an unsized array.

getDimensions

public · function · Source (opens in a new tab)

const std::vector< size_t > & sun::types::ArrayType::getDimensions() const

Returns the array dimension sizes.

getElementLLVMType

public · function · Source (opens in a new tab)

llvm::Type * sun::types::ArrayType::getElementLLVMType(llvm::LLVMContext &ctx) const

Get the LLVM element type.

getElementType

public · function · Source (opens in a new tab)

const TypePtr & sun::types::ArrayType::getElementType() const

Returns the element type stored by this object.

Related: TypePtr

getIndexedType

public · function · Source (opens in a new tab)

TypePtr sun::types::ArrayType::getIndexedType() const

Get the type after indexing once (removes outermost dimension) For array<i32, 3, 2>[i] -> array<i32, 2> For array<i32, 5>[i] -> i32.

Related: TypePtr

getInnermostType

public · function · Source (opens in a new tab)

TypePtr sun::types::ArrayType::getInnermostType() const

Get the innermost element type (for nested arrays, recurse).

Related: TypePtr

getKind

public · function · Source (opens in a new tab)

Kind sun::types::ArrayType::getKind() const override

Returns the type category used for semantic checks and dispatch.

Related: Kind

getTotalElements

public · function · Source (opens in a new tab)

size_t sun::types::ArrayType::getTotalElements() const

Get total number of elements (product of all dimensions) Returns 0 for unsized arrays.

is1D

public · function · Source (opens in a new tab)

bool sun::types::ArrayType::is1D() const

Check if this is a 1D array.

isCompatibleWith

public · function · Source (opens in a new tab)

bool sun::types::ArrayType::isCompatibleWith(const ArrayType &other) const

Check if a sized array is compatible with this type Used for coercion from array<T, m, n> to array<T> (unsized).

Related: ArrayType

isUnsized

public · function · Source (opens in a new tab)

bool sun::types::ArrayType::isUnsized() const

Check if this is an unsized array (array<T> without dimensions).

toDisplayString

public · function · Source (opens in a new tab)

std::string sun::types::ArrayType::toDisplayString() const override

Returns a source-facing type name without internal compiler prefixes.

toLLVMType

public · function · Source (opens in a new tab)

llvm::Type * sun::types::ArrayType::toLLVMType(llvm::LLVMContext &ctx) const override

A sized array is its inline storage; an unsized one is the view struct (reached only through ReferenceType::toLLVMType).

Related: ReferenceType::toLLVMType

toString

public · function · Source (opens in a new tab)

std::string sun::types::ArrayType::toString() const override

Returns a readable representation for diagnostics and debugging.

Public Fields

StaticKind

public · variable · static · Source (opens in a new tab)

Kind sun::types::ArrayType::StaticKind = Kind::Array

No documentation comment.

Related: Kind, Kind::Array

Private Fields

dimensions

private · variable · Source (opens in a new tab)

std::vector<size_t> sun::types::ArrayType::dimensions

No documentation comment.

elementType

private · variable · Source (opens in a new tab)

TypePtr sun::types::ArrayType::elementType

No documentation comment.

Related: TypePtr