From abd56ef20bc8061bbecec29edd1301d324c2cb34 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Sat, 17 Oct 2026 08:34:42 +0000 Subject: feat(classes): destroy stack objects at scope exit Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/StatementGen.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/StatementGen.cc') diff --git a/lib/CodeGen/StatementGen.cc b/lib/CodeGen/StatementGen.cc index a7c8eda..df8c396 100644 --- a/lib/CodeGen/StatementGen.cc +++ b/lib/CodeGen/StatementGen.cc @@ -31,11 +31,15 @@ void CodeGen::emitStmt(StmtAST *Stmt) { // to the emitting function), mirroring FunctionGen's Symbols handling. auto SavedArrays = Arrays->exchangeTable({}); + auto SavedObjects = std::move(StackObjects); + StackObjects.clear(); auto SavedScopes = std::move(ConstantScopes); ConstantScopes = {{NextScopeID++, {}}}; - FuncGen->emitFunctionDef(FuncDef, [this](StmtAST *S) { + Function *Emitted = FuncGen->emitFunctionDef(FuncDef, [this](StmtAST *S) { this->emitStmt(S); }, ConstantScopes.back().ID); + if (Emitted) finishStackObjects(Emitted); + StackObjects = std::move(SavedObjects); ConstantScopes = std::move(SavedScopes); Arrays->exchangeTable(std::move(SavedArrays)); -- cgit v1.3.1-4-g156e