diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-13 14:52:57 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-13 14:52:57 +0000 |
| commit | a484f314b719aec5ed7bdc6f08403342b2125561 (patch) | |
| tree | 531e331cf823517eae4c350d37bca6a500b2de9f /include/cps/FunctionGen.h | |
| parent | 4297086c86f4d11e8a14b76b50705b419d6b7f13 (diff) | |
feat(compiler)!: add try-catch with C++ stack unwinding
Add TRY/CATCH/ENDTRY and anonymous THROW statements. Use LLVM exception
handling and the C++ ABI to propagate exceptions across function calls,
clean up catch state, and handle uncaught exceptions at the program boundary.
Register exception runtime symbols for the statically linked embedded runner.
Verify runtime checks, nested catches, returns, loops, and invalid syntax
with smoke programs; exercise unwinding with MCJIT, lli, and native binaries.
BREAKING CHANGE: Runtime check failures now throw anonymous exceptions and
print only a generic message when uncaught. Native binaries require linking
the C++ runtime.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'include/cps/FunctionGen.h')
| -rw-r--r-- | include/cps/FunctionGen.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/include/cps/FunctionGen.h b/include/cps/FunctionGen.h index d914162..a7cead5 100644 --- a/include/cps/FunctionGen.h +++ b/include/cps/FunctionGen.h @@ -12,6 +12,8 @@ namespace cps { +class ExceptionHandler; + // Array-parameter ABI: each rank-R array parameter is flattened into the // data pointer followed by kBoundArgsPerDim i64 bounds per dimension. inline constexpr unsigned kBoundArgsPerDim = 2; // lower, upper @@ -51,6 +53,7 @@ private: llvm::Module &Module; llvm::IRBuilder<> &Builder; TypeSystem &Types; + ExceptionHandler &Exceptions; std::map<std::string, SymbolInfo> &Symbols; bool &HadError; @@ -65,9 +68,10 @@ public: llvm::Module &M, llvm::IRBuilder<> &B, TypeSystem &TS, + ExceptionHandler &EH, std::map<std::string, SymbolInfo> &Sym, bool &HadErrorFlag) - : Context(C), Module(M), Builder(B), Types(TS), Symbols(Sym), HadError(HadErrorFlag) {} + : Context(C), Module(M), Builder(B), Types(TS), Exceptions(EH), Symbols(Sym), HadError(HadErrorFlag) {} llvm::Type *getLLVMType(const std::string &TypeName); |
