sun::types::ErrorUnionType
class · Source (opens in a new tab)
class sun::types::ErrorUnionType : public sun::types::TypeError union type - represents a type that can be either a value or an error Following Zig's model where errors are values Represented as a struct { bool isError; union { ValueType value; i32 errorCode; } } For simplicity, we use { i1 isError, T value } where we check isError first.
Inherits
- sun::types::Type (public)
Public Functions
ErrorUnionType
public · function · Source (opens in a new tab)
sun::types::ErrorUnionType::ErrorUnionType(TypePtr value)Creates a result type that can hold either a value or an error.
Related: TypePtr
equals
public · function · Source (opens in a new tab)
bool sun::types::ErrorUnionType::equals(const Type &other) const overrideReports whether the other type has the same semantic identity.
Related: Type
getKind
public · function · Source (opens in a new tab)
Kind sun::types::ErrorUnionType::getKind() const overrideReturns the type category used for semantic checks and dispatch.
Related: Kind
getValueLLVMType
public · function · Source (opens in a new tab)
llvm::Type * sun::types::ErrorUnionType::getValueLLVMType(llvm::LLVMContext &ctx) constGet the LLVM type of the value (for extracting the value when not an error).
getValueType
public · function · Source (opens in a new tab)
const TypePtr & sun::types::ErrorUnionType::getValueType() constReturns the value type stored by this object.
Related: TypePtr
toDisplayString
public · function · Source (opens in a new tab)
std::string sun::types::ErrorUnionType::toDisplayString() const overrideSpelled the way the source spells it: "i32 throws IError".
toLLVMType
public · function · Source (opens in a new tab)
llvm::Type * sun::types::ErrorUnionType::toLLVMType(llvm::LLVMContext &ctx) const overrideError union is represented as a struct: { i1 isError, <valueType> value } If isError is true, the error code is stored in the value field (as i64).
toString
public · function · Source (opens in a new tab)
std::string sun::types::ErrorUnionType::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::ErrorUnionType::StaticKind = Kind::ErrorUnionNo documentation comment.
Related: Kind, Kind::ErrorUnion
Private Fields
valueType
private · variable · Source (opens in a new tab)
TypePtr sun::types::ErrorUnionType::valueTypeNo documentation comment.
Related: TypePtr