sun::types::ArrayType
class · Source (opens in a new tab)
class sun::types::ArrayType : public sun::types::TypeArray 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
- sun::types::Type (public)
Public Functions
- ArrayType
- equals
- getArrayStructType
- getDataStorageType
- getDimensions
- getElementLLVMType
- getElementType
- getIndexedType
- getInnermostType
- getKind
- getTotalElements
- is1D
- isCompatibleWith
- isUnsized
- toDisplayString
- toLLVMType
- toString
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 overrideReports 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) constThe 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() constReturns the array dimension sizes.
getElementLLVMType
public · function · Source (opens in a new tab)
llvm::Type * sun::types::ArrayType::getElementLLVMType(llvm::LLVMContext &ctx) constGet the LLVM element type.
getElementType
public · function · Source (opens in a new tab)
const TypePtr & sun::types::ArrayType::getElementType() constReturns the element type stored by this object.
Related: TypePtr
getIndexedType
public · function · Source (opens in a new tab)
TypePtr sun::types::ArrayType::getIndexedType() constGet 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() constGet 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 overrideReturns 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() constGet 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() constCheck if this is a 1D array.
isCompatibleWith
public · function · Source (opens in a new tab)
bool sun::types::ArrayType::isCompatibleWith(const ArrayType &other) constCheck 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() constCheck 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 overrideReturns 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 overrideA 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 overrideReturns 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::ArrayNo documentation comment.
Related: Kind, Kind::Array
Private Fields
dimensions
private · variable · Source (opens in a new tab)
std::vector<size_t> sun::types::ArrayType::dimensionsNo documentation comment.
elementType
private · variable · Source (opens in a new tab)
TypePtr sun::types::ArrayType::elementTypeNo documentation comment.
Related: TypePtr