sun::types::LambdaType

sun::types::LambdaType

class · Source (opens in a new tab)

class sun::types::LambdaType : public sun::types::Type

Lambda type for anonymous functions (fat pointer call, returnable) Type annotation: () => {}.

Inherits

Public Functions

LambdaType

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

sun::types::LambdaType::LambdaType(TypePtr ret, std::vector< TypePtr > params, bool canThrow=false, bool requiresUnsafe=false)

Creates a captured-callable type from its result, parameters, and restrictions.

Related: TypePtr

acceptsValueOf

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

bool sun::types::LambdaType::acceptsValueOf(const LambdaType &from) const

Can a by-value 'from' argument bind to a parameter of this type?

Same signature, and each marker only widens: a non-throwing lambda may go where a throwing one is expected, and an environment-free lambda may go where a '<'_>' one is expected — never the other way around.

Related: LambdaType

canThrow

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

bool sun::types::LambdaType::canThrow() const

Reports whether calls through this type may produce an error.

equals

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

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

Reports whether the other type has the same semantic identity.

Related: Type

equalsIgnoringThrow

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

bool sun::types::LambdaType::equalsIgnoringThrow(const LambdaType &other) const

Same signature ignoring throwing-ness and the lifetime marker.

Used by the bound-method overload chooser, which picks a method by shape before the chosen value is flagged as frame-bound; assignability rejects it later.

Related: LambdaType

getKind

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

Kind sun::types::LambdaType::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::LambdaType::getLifetimeName() const

Returns the named lifetime associated with the borrowed value.

getParamTypes

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

const std::vector< TypePtr > & sun::types::LambdaType::getParamTypes() const

Provides the ordered semantic types of the function parameters.

Related: TypePtr

getReturnType

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

const TypePtr & sun::types::LambdaType::getReturnType() const

Returns the semantic type of the function result.

Related: TypePtr

hasRefCaptures

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

bool sun::types::LambdaType::hasRefCaptures() const

Reports whether this object has ref captures.

requiresUnsafe

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

bool sun::types::LambdaType::requiresUnsafe() const

Whether calling this value requires an unsafe block.

setHasRefCaptures

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

void sun::types::LambdaType::setHasRefCaptures(bool v)

Records whether the callable retains any borrowed captures.

setLifetimeName

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

void sun::types::LambdaType::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::LambdaType::toDisplayString() const override

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

toLLVMFunctionType

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

llvm::FunctionType * sun::types::LambdaType::toLLVMFunctionType(llvm::LLVMContext &ctx) const

Get the raw LLVM FunctionType (for the actual function signature with closure param).

Related: FunctionType

toLLVMType

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

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

Returns the closure struct type { ptr, ptr } (func*, env*).

toString

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

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

No documentation comment.

Related: Kind, Kind::Lambda

Private Fields

canThrow_

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

bool sun::types::LambdaType::canThrow_ = false

No documentation comment.

hasRefCaptures_

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

bool sun::types::LambdaType::hasRefCaptures_ = false

No documentation comment.

lifetimeName_

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

std::string sun::types::LambdaType::lifetimeName_

No documentation comment.

paramTypes

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

std::vector<TypePtr> sun::types::LambdaType::paramTypes

No documentation comment.

Related: TypePtr

requiresUnsafe_

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

bool sun::types::LambdaType::requiresUnsafe_ = false

No documentation comment.

returnType

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

TypePtr sun::types::LambdaType::returnType

No documentation comment.

Related: TypePtr