sun::types::ReferenceType

sun::types::ReferenceType

class · Source (opens in a new tab)

class sun::types::ReferenceType : public sun::types::Type

Reference type - behaves like a pointer but with implicit dereferencing Type annotation: ref(T) where T is the referenced type Examples: ref(i32) = reference to i32 When reading a reference, it automatically dereferences When assigning to a reference, it stores to the underlying address.

Inherits

Public Functions

ReferenceType

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

sun::types::ReferenceType::ReferenceType(TypePtr referenced, bool isMutable=true)

Creates a borrowed reference type with the requested mutability.

Related: TypePtr

equals

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

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

Reports whether the other type has the same semantic identity.

Related: Type

getClassLifetimeArgs

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

const std::vector< std::string > & sun::types::ReferenceType::getClassLifetimeArgs() const

Lifetime arguments applied to the referent's class ('ref Bus<'this>'): positionally binding the class's declared lifetimes.

Metadata like lifetimeName_ - never part of the type's identity.

getKind

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

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

Returns the type category used for semantic checks and dispatch.

Related: Kind

getLifetimeName

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

const std::string & sun::types::ReferenceType::getLifetimeName() const

Returns the named lifetime associated with the borrowed value.

getReferencedLLVMType

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

llvm::Type * sun::types::ReferenceType::getReferencedLLVMType(llvm::LLVMContext &ctx) const

Get the LLVM type of the referenced value (for load/store operations).

getReferencedType

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

const TypePtr & sun::types::ReferenceType::getReferencedType() const

Returns the referenced type stored by this object.

Related: TypePtr

isMutable

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

bool sun::types::ReferenceType::isMutable() const

Reports whether the loan grants exclusive write access to its target.

isUnsizedArrayRef

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

bool sun::types::ReferenceType::isUnsizedArrayRef() const

Check if this is a reference to an unsized array.

setClassLifetimeArgs

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

void sun::types::ReferenceType::setClassLifetimeArgs(std::vector< std::string > args)

Updates the lifetime arguments for the referenced class.

setLifetimeName

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

void sun::types::ReferenceType::setLifetimeName(std::string name)

Assigns the named lifetime associated with the borrowed value.

toDisplayString

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

std::string sun::types::ReferenceType::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::ReferenceType::toLLVMType(llvm::LLVMContext &ctx) const override

Returns opaque pointer or fat pointer struct for unsized array refs.

toString

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

std::string sun::types::ReferenceType::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::ReferenceType::StaticKind = Kind::Reference

No documentation comment.

Related: Kind, Kind::Reference

Private Fields

classLifetimeArgs_

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

std::vector<std::string> sun::types::ReferenceType::classLifetimeArgs_

No documentation comment.

lifetimeName_

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

std::string sun::types::ReferenceType::lifetimeName_

No documentation comment.

mutable_

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

bool sun::types::ReferenceType::mutable_

No documentation comment.

referencedType

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

TypePtr sun::types::ReferenceType::referencedType

No documentation comment.

Related: TypePtr