diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-17 08:34:42 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-17 08:34:42 +0000 |
| commit | abd56ef20bc8061bbecec29edd1301d324c2cb34 (patch) | |
| tree | 8da9a14372a60d4df8bf58693c62c187765e7240 /lib/CodeGen/StatementGen.cc | |
| parent | 59e3c50bcd58130e81e1f57b21d6e57b4d4aba6d (diff) | |
feat(classes): destroy stack objects at scope exit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/StatementGen.cc')
| -rw-r--r-- | lib/CodeGen/StatementGen.cc | 6 |
1 files changed, 5 insertions, 1 deletions
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)); |
