sun::types
namespace · Source (opens in a new tab)
Resolves declarations and checks the types and meaning of Sun programs.
Walks type descriptions to compute cleanup and lifetime properties.
Compares shared type descriptions without applying conversions.
Implements base-type queries that inspect concrete type representations.
Implements borrow representation queries that require complete array types.
Implements raw pointer compatibility without implicit ownership changes.
Resolves the source declaration of a session-owned nominal type.
Implements class relationships that require complete interface definitions.
Queries reference, ownership, lifetime, and diagnostic properties of types.
Describes generic type parameters and deferred projections.
Declares exact type identity comparisons without conversions.
Constructs common primitive and structural type descriptions.
Defines the common type interface and shared ownership handle.
Describes the builtin indexing range type.
Describes mutable and const borrows and their lifetime metadata.
Describes the primitive scalar and void types.
Describes raw pointers, static pointers, and the null value.
Describes references to modules during name resolution.
Describes closure signatures and capture lifetimes.
Describes interface requirements, generic arguments, and vtable layout.
Describes callable function-pointer signatures.
Describes values paired with an error alternative.
Describes enum variants, payloads, and representation metadata.
Describes class fields, methods, layout, and interface relationships.
Describes array elements, dimensions, and LLVM views.
Type definitions shared by analysis and code generation.
Defines shared type descriptions used by portable identities.
Defines shared type descriptions used throughout the compiler.
Implements shared type descriptions and queries.
Defines shared type descriptions and their identity rules.
Classes
- sun::types::ArrayType (public)
- sun::types::ClassType (public)
- sun::types::EnumType (public)
- sun::types::ErrorUnionType (public)
- sun::types::FunctionType (public)
- sun::types::InterfaceType (public)
- sun::types::LambdaType (public)
- sun::types::ModuleType (public)
- sun::types::NominalType (public)
- sun::types::RawPointerType (public)
- sun::types::StaticPointerType (public)
- sun::types::NullPointerType (public)
- sun::types::PrimitiveType (public)
- sun::types::ReferenceType (public)
- sun::types::SliceType (public)
- sun::types::Type (public)
- sun::types::Types (public)
- sun::types::TypeParameterType (public)
Structs
- sun::types::ClassField (public)
- sun::types::ClassMethod (public)
- sun::types::EnumVariant (public)
- sun::types::InterfaceField (public)
- sun::types::InterfaceMethod (public)
Functions
- areDifferentInterfaces
- argumentAccepts
- eraseLifetimeNames
- formatTypeList
- isAssignableTo
- isBytePointerArgument
- isConstRef
- isMutableRef
- logAndThrowError
- refMutabilityConvertible
- referenceParameterAccepts
- sameTypeArguments
- sameTypeIdentity
- typeCopiesByRead
- typeIsFrameCarrying
- typeMovesOnRead
- typeNeedsDrop
- unwrapRef
areDifferentInterfaces
public · function · Source (opens in a new tab)
bool sun::types::areDifferentInterfaces(const TypePtr &sourceType, const TypePtr &targetType)Reports whether both types name different interfaces after unwrapping references.
This does not check whether either interface extends the other.
Related: TypePtr
argumentAccepts
public · function · Source (opens in a new tab)
bool sun::types::argumentAccepts(const TypePtr &argType, const TypePtr ¶mType, bool allowBytePointer)Whether an argument of type argType may be passed to a parameter of type paramType.
Applies the call-site rules, then falls back to assignability.
On top of isAssignableTo, a call site also accepts: the referent or a compatible borrow for a ref parameter, a raw_ptr<T> where ref T or a primitive T is expected (read through the pointer), and null for any pointer. With allowBytePointer, any raw_ptr passes as a byte pointer; only intrinsics ask for that. Both types must be non-null.
Related: TypePtr
eraseLifetimeNames
public · function · Source (opens in a new tab)
TypePtr sun::types::eraseLifetimeNames(const TypePtr &type)Copies a type with relative lifetime names removed, preserving lifetime markers.
A copy of the type with every lifetime NAME stripped, recursively.
Lifetime names are relative to one signature's lifetime list; a type that crosses into another namespace - a generic type-parameter binding, whose specialization is shared by every caller - must not carry them along. The <'_> marker itself is identity and stays.
Related: TypePtr
formatTypeList
public · function · Source (opens in a new tab)
std::string sun::types::formatTypeList(const std::vector< TypePtr > &types)"i32, ref Vec<i32>" — a list of types as it reads in a diagnostic.
Related: TypePtr
isAssignableTo
public · function · Source (opens in a new tab)
bool sun::types::isAssignableTo(const TypePtr &from, const TypePtr &to)True when a value of type from may be used where to is expected.
Reports whether a value of one type can be assigned to another.
Covers exact equality, integer widening, f32/f64 conversion, static_ptr to raw_ptr narrowing, class-to-interface conformance (through a ref on either side), a non-throwing lambda where a throwing one is expected, and reading a scalar out of a borrow. A compound read out of a borrow is rejected: that would give the copy and the borrowed value the same buffer.
Related: TypePtr
isBytePointerArgument
public · function · Source (opens in a new tab)
bool sun::types::isBytePointerArgument(const TypePtr &argType, const TypePtr ¶mType)Whether a raw_ptr argument may be passed as a byte pointer parameter (raw_ptr<i8> or raw_ptr<u8>), like C's void*.
Accepts any raw_ptr where a raw_ptr to i8 or u8 is expected.
Only intrinsic callees allow this, to avoid accidental type erasure in user code.
Related: TypePtr
isConstRef
public · function · Source (opens in a new tab)
bool sun::types::isConstRef(const TypePtr &type)const ref T (the referent may only be read through it)
Related: TypePtr
isMutableRef
public · function · Source (opens in a new tab)
bool sun::types::isMutableRef(const TypePtr &type)ref T (the referent may be changed through it)
Related: TypePtr
refMutabilityConvertible
public · function · Source (opens in a new tab)
bool sun::types::refMutabilityConvertible(const ReferenceType &from, const ReferenceType &to)A reference of kind from may stand in for one of kind to unless that would let a const borrow be written through.
Related: ReferenceType
referenceParameterAccepts
public · function · Source (opens in a new tab)
bool sun::types::referenceParameterAccepts(const ReferenceType ¶m, const TypePtr &argType)Whether an argument of type argType can bind to a ref parameter of type param without conversion: it is the referenced type itself, a borrow of it whose mutability may convert (only ref to const ref), or a sized array whose element type matches an unsized ref array<T> parameter.
Checks the referent, borrow mutability, and unsized array view rules.
Related: ReferenceType, TypePtr
sameTypeArguments
public · function · Source (opens in a new tab)
bool sun::types::sameTypeArguments(const std::vector< TypePtr > &left, const std::vector< TypePtr > &right)Compare ordered parameter or specialization argument types exactly.
Compare concrete argument lists in their declared order.
Related: TypePtr
sameTypeIdentity
public · function · Source (opens in a new tab)
bool sun::types::sameTypeIdentity(const TypePtr &left, const TypePtr &right)Compare semantic types exactly, without accepting implicit conversions.
Compare identity recursively without accepting implicit conversions.
Related: TypePtr
typeCopiesByRead
typeCopiesByRead(const TypePtr &type)
public · function · Source (opens in a new tab)
bool sun::types::typeCopiesByRead(const TypePtr &type)Reports whether reading this type can duplicate its value without transferring ownership.
Related: TypePtr
typeCopiesByRead(const Type *type)
public · function · Source (opens in a new tab)
bool sun::types::typeCopiesByRead(const Type *type)True if a read can honestly duplicate a value of this type.
Scalars can: primitives, pointers, functions. A class, payload enum, interface or array value cannot: it has one owner, so reading one out of a borrow would hand back a second value backed by the borrowed storage. Borrow it with ref instead, or copy it explicitly with a clone method. Unbound type parameters answer true; the specialization is checked with the concrete type in hand.
Related: Type
typeIsFrameCarrying
typeIsFrameCarrying(const TypePtr &type)
public · function · Source (opens in a new tab)
bool sun::types::typeIsFrameCarrying(const TypePtr &type)Reports whether this type can retain storage tied to a stack frame.
Related: TypePtr
typeIsFrameCarrying(const Type *type)
public · function · Source (opens in a new tab)
bool sun::types::typeIsFrameCarrying(const Type *type)Reports whether this type can retain storage tied to a stack frame.
Related: Type
typeMovesOnRead
typeMovesOnRead(const Type *type)
public · function · Source (opens in a new tab)
bool sun::types::typeMovesOnRead(const Type *type)True if reading a value of this type out of a place MOVES it: an owned compound value.
A borrow stays put and a scalar copies.
Related: Type
typeMovesOnRead(const TypePtr &type)
public · function · Source (opens in a new tab)
bool sun::types::typeMovesOnRead(const TypePtr &type)Reports whether reading this type transfers ownership of its value.
Related: TypePtr
typeNeedsDrop
typeNeedsDrop(const TypePtr &type)
public · function · Source (opens in a new tab)
bool sun::types::typeNeedsDrop(const TypePtr &type)Reports whether values of this type require cleanup when their lifetime ends.
Related: TypePtr
typeNeedsDrop(const Type *type)
public · function · Source (opens in a new tab)
bool sun::types::typeNeedsDrop(const Type *type)Reports whether values of this type require cleanup when their lifetime ends.
Related: Type
unwrapRef
public · function · Source (opens in a new tab)
TypePtr sun::types::unwrapRef(TypePtr type)Helper: unwrap reference types (ref(T) -> T, otherwise unchanged) References should behave like values, transparently dereferenced.
Related: TypePtr
Enums
TypeProjection
public · enum · Source (opens in a new tab)
enum class sun::types::TypeProjection : uint8_tSomething computed from a type parameter rather than the parameter itself.
_return_type_of<F> names a type that is only known once F is, so until then it travels as the parameter F plus the projection to apply to it.
None
None
No documentation comment.
ReturnType
ReturnType
No documentation comment.
Type Aliases
EnumTypePtr
public · typedef · Source (opens in a new tab)
using sun::types::EnumTypePtr = std::shared_ptr<EnumType>Shared ownership of a semantic enum description.
Related: EnumType
InterfaceTypePtr
public · typedef · Source (opens in a new tab)
using sun::types::InterfaceTypePtr = std::shared_ptr<InterfaceType>Shared ownership of a semantic interface description.
Related: InterfaceType
TypePtr
public · typedef · Source (opens in a new tab)
using sun::types::TypePtr = std::shared_ptr<Type>Shared ownership of a semantic type description.
Related: Type