sun::types::FunctionType

sun::types::FunctionType

class · Source (opens in a new tab)

class sun::types::FunctionType : public sun::types::Type

A non-null, one-word pointer to a module-scope function.

Type annotation: function (Args) Result

Inherits

Public Functions

FunctionType

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

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

Creates a function type from its result, parameters, and calling restrictions.

Related: TypePtr

canThrow

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

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

Whether calls through this pointer may throw.

equals

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

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

Reports whether the other type has the same semantic identity.

Related: Type

getKind

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

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

Returns the type category used for semantic checks and dispatch.

Related: Kind

getParamTypes

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

const std::vector< TypePtr > & sun::types::FunctionType::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::FunctionType::getReturnType() const

Returns the semantic type of the function result.

Related: TypePtr

requiresUnsafe

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

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

Whether calling this value requires an unsafe block.

setCanThrow

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

void sun::types::FunctionType::setCanThrow(bool v)

Records whether calls through this signature may throw an error.

toDisplayString

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

std::string sun::types::FunctionType::toDisplayString() const override

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

toLLVMClosureType

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

llvm::StructType * sun::types::FunctionType::toLLVMClosureType(llvm::LLVMContext &ctx) const

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

toLLVMFunctionType

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

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

Get the raw LLVM FunctionType (for indirect calls).

Related: FunctionType

toLLVMType

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

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

Function values use LLVM's opaque pointer representation.

toPointerType

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

llvm::Type * sun::types::FunctionType::toPointerType(llvm::LLVMContext &ctx) const

Returns a pointer to the function type (for function pointer variables).

toString

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

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

No documentation comment.

Related: Kind, Kind::Function

Private Fields

canThrow_

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

bool sun::types::FunctionType::canThrow_ = false

No documentation comment.

paramTypes

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

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

No documentation comment.

Related: TypePtr

requiresUnsafe_

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

bool sun::types::FunctionType::requiresUnsafe_ = false

No documentation comment.

returnType

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

TypePtr sun::types::FunctionType::returnType

No documentation comment.

Related: TypePtr