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 =