From 897dbe999358746bb27ec5a38317960f61ca753d Mon Sep 17 00:00:00 2001 From: writemorecode Date: Tue, 10 Feb 2026 17:32:38 +0100 Subject: [PATCH] Fix: include class fields in VM activation variables --- src/ir/CFG.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ir/CFG.cpp b/src/ir/CFG.cpp index eb8a7bf..ff9679e 100644 --- a/src/ir/CFG.cpp +++ b/src/ir/CFG.cpp @@ -94,12 +94,19 @@ void CFG::generateBytecode(BytecodeProgram &program, SymbolTable &st) { const auto &className = basicBlock->getClassName(); const auto &methodName = basicBlock->getMethodName(); - const auto *methodScope = st.resolveScope(className, methodName); + auto *methodScope = st.resolveScope(className, methodName); const auto *method = dynamic_cast(methodScope->getRecord()); const auto methodParameters = method->getParameterNames(); const auto &blockName = basicBlock->getName(); - const auto variableNames = methodScope->getVariableNames(); + auto variableNames = methodScope->getVariableNames(); + if (const auto *classScope = methodScope->getParent(); + classScope != nullptr) { + const auto classVariableNames = classScope->getVariableNames(); + variableNames.insert(classVariableNames.begin(), + classVariableNames.end()); + } + std::vector variables(variableNames.begin(), variableNames.end()); auto &bytecodeMethod =