sun::codegen::exceptions::ExceptionGenerator

sun::codegen::exceptions::ExceptionGenerator

class · Source (opens in a new tab)

class sun::codegen::exceptions::ExceptionGenerator

Emits throws, handlers, unsafe blocks, and calls with ownership cleanup.

Types

Functions

codegen

codegen(const ExprAST &expr)

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

llvm::Value * sun::codegen::exceptions::ExceptionGenerator::codegen(const ExprAST &expr)

Delegates expression generation to the enclosing visitor.

Related: ExprAST

codegen(const sun::ast::ThrowAST &statement)

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

Value * sun::codegen::exceptions::ExceptionGenerator::codegen(const sun::ast::ThrowAST &statement)

Emits a bounded transfer through the native unwinder.

Related: sun::ast::ThrowAST

codegen(const sun::ast::TryCatchAST &statement)

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

Value * sun::codegen::exceptions::ExceptionGenerator::codegen(const sun::ast::TryCatchAST &statement)

Emits protected blocks and stack-owned catches.

Related: sun::ast::TryCatchAST

codegen(const sun::ast::BlockExprAST &block)

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

llvm::Value * sun::codegen::exceptions::ExceptionGenerator::codegen(const sun::ast::BlockExprAST &block)

Emits LLVM instructions for this syntax node and returns its generated value.

Related: sun::ast::BlockExprAST

codegen(const T &)=delete

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

template <typename T>
llvm::Value * sun::codegen::exceptions::ExceptionGenerator::codegen(const T &)=delete

A node kind with its own overload must not silently bind to the ExprAST forwarder above: that path attaches an expression debug location, so a block routed through it changes DWARF output.

Make it a compile error instead. Add an overload here when a new kind is needed.

Related: ExprAST, sun::ast::BlockExprAST, ExprAST

codegen(const sun::ast::UnsafeBlockAST &expr)

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

Value * sun::codegen::exceptions::ExceptionGenerator::codegen(const sun::ast::UnsafeBlockAST &expr)

The body is emitted as written, in a scope of its own; the block's value is handed out to the enclosing scope.

Safety checks are done in sema.

Related: sun::ast::UnsafeBlockAST

Public Functions

ExceptionGenerator

ExceptionGenerator(sun::codegen::CodegenState &state, sun::codegen::CodegenVisitor &gen)

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

sun::codegen::exceptions::ExceptionGenerator::ExceptionGenerator(sun::codegen::CodegenState &state, sun::codegen::CodegenVisitor &gen)

Binds exception propagation generation to the shared expression visitor and state.

Related: sun::codegen::CodegenState, sun::codegen::CodegenVisitor

ExceptionGenerator(const ExceptionGenerator &)=delete

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

sun::codegen::exceptions::ExceptionGenerator::ExceptionGenerator(const ExceptionGenerator &)=delete

Binds exception propagation generation to the shared expression visitor and state.

emitDestructorCall

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

void sun::codegen::exceptions::ExceptionGenerator::emitDestructorCall(llvm::Function *callee, llvm::Value *receiver)

Terminates if a destructor violates its non-throwing boundary.

emitPossiblyThrowingCall

emitPossiblyThrowingCall(llvm::FunctionType *fnTy, llvm::Value *callee, llvm::ArrayRef< llvm::Value * > args, bool canThrow, const llvm::Twine &name)

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

llvm::Value * sun::codegen::exceptions::ExceptionGenerator::emitPossiblyThrowingCall(llvm::FunctionType *fnTy, llvm::Value *callee, llvm::ArrayRef< llvm::Value * > args, bool canThrow, const llvm::Twine &name)

Applies the callee ABI and drops live owners if the call unwinds.

emitPossiblyThrowingCall(llvm::FunctionCallee callee, llvm::ArrayRef< llvm::Value * > args, bool canThrow, const llvm::Twine &name)

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

llvm::Value * sun::codegen::exceptions::ExceptionGenerator::emitPossiblyThrowingCall(llvm::FunctionCallee callee, llvm::ArrayRef< llvm::Value * > args, bool canThrow, const llvm::Twine &name)

Emits a declared callee using the same ABI and ownership cleanup rules.

emitTraceOperation

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

std::optional< Value * > sun::codegen::exceptions::ExceptionGenerator::emitTraceOperation(const sun::ast::ExprAST &call, const std::vector< std::unique_ptr< sun::ast::ExprAST > > &arguments)

Lowers current-stack reporting and catch-only exception trace intrinsics.

Related: sun::ast::ExprAST

omitInfallibleDestructorStorage

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

void sun::codegen::exceptions::ExceptionGenerator::omitInfallibleDestructorStorage()

Removes destructor storage only when a fixed-point call analysis proves it unnecessary.

operator=

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

ExceptionGenerator & sun::codegen::exceptions::ExceptionGenerator::operator=(const ExceptionGenerator &)=delete

Disallows assignment so ownership and object identity cannot be duplicated.

Related: ExceptionGenerator

protectDestructor

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

void sun::codegen::exceptions::ExceptionGenerator::protectDestructor(llvm::Function *function)

Reserves destructor-owned propagation storage and restores it at every return.

reportCurrentException

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

Value * sun::codegen::exceptions::ExceptionGenerator::reportCurrentException(const sun::support::Position &location, bool unhandled)

Reports the retained value of this function's current catch, including anonymous catches.

Related: sun::support::Position

Private Functions

emitExceptionTermination

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

void sun::codegen::exceptions::ExceptionGenerator::emitExceptionTermination(llvm::Value *exception)

Terminates at a non-throwing boundary without invoking further cleanup.

emitNativeCall

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

Value * sun::codegen::exceptions::ExceptionGenerator::emitNativeCall(llvm::FunctionType *type, llvm::Value *callee, llvm::ArrayRef< llvm::Value * > args, const llvm::Twine &name)

Emits an invoke and the cleanup edges needed for Sun-native exceptions.

emitNativeCleanup

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

void sun::codegen::exceptions::ExceptionGenerator::emitNativeCleanup(std::size_t depth)

Runs exceptional cleanup with a separate stable record for nested throws.

ensurePersonality

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

void sun::codegen::exceptions::ExceptionGenerator::ensurePersonality(llvm::Function *fn)

Ensure fn has a personality function set (needed for any function that contains an invoke/landingpad).

Idempotent.

exceptionDescriptor

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

Constant * sun::codegen::exceptions::ExceptionGenerator::exceptionDescriptor(const sun::types::ClassType &type)

Emits immutable nominal metadata including the payload layout contract.

Related: sun::types::ClassType

exceptionStorage

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

AllocaInst * sun::codegen::exceptions::ExceptionGenerator::exceptionStorage(llvm::Type *type, const llvm::Twine &name)

Allocates bounded storage in the entry block instead of growing loops.

getPersonalityFunction

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

Constant * sun::codegen::exceptions::ExceptionGenerator::getPersonalityFunction()

Returns the personality function stored by this object.

scopes

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

sun::codegen::scopes::ScopeManager & sun::codegen::exceptions::ExceptionGenerator::scopes()

Provides the scope manager responsible for variable storage and cleanup.

Related: sun::codegen::scopes::ScopeManager

Private Fields

ctx

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

sun::codegen::CodegenContext& sun::codegen::exceptions::ExceptionGenerator::ctx

No documentation comment.

Related: sun::codegen::CodegenContext

gen_

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

sun::codegen::CodegenVisitor& sun::codegen::exceptions::ExceptionGenerator::gen_

No documentation comment.

Related: sun::codegen::CodegenVisitor

module

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

llvm::Module* sun::codegen::exceptions::ExceptionGenerator::module

No documentation comment.

nativeCatches_

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

std::vector<NativeCatch> sun::codegen::exceptions::ExceptionGenerator::nativeCatches_

No documentation comment.

Related: NativeCatch

nativeHandlers_

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

std::vector<NativeHandler> sun::codegen::exceptions::ExceptionGenerator::nativeHandlers_

No documentation comment.

Related: NativeHandler

state_

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

sun::codegen::CodegenState& sun::codegen::exceptions::ExceptionGenerator::state_

No documentation comment.

Related: sun::codegen::CodegenState