From d50f76a77024d830c3dd7311ed910d689c9d5f16 Mon Sep 17 00:00:00 2001 From: rain2133 <1370973498@qq.com> Date: Tue, 24 Jun 2025 16:39:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DIR=E5=87=BD=E6=95=B0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E8=BE=93=E5=87=BA=EF=BC=8C=E5=8F=98=E9=87=8F=E5=91=BD?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/IR.cpp | 4 ++-- src/SysYIRPrinter.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/IR.cpp b/src/IR.cpp index c86e529..1483bf3 100644 --- a/src/IR.cpp +++ b/src/IR.cpp @@ -598,11 +598,11 @@ auto SymbolTable::addVariable(const std::string &name, User *variable) -> User * std::stringstream ss; auto iter = variableIndex.find(name); if (iter != variableIndex.end()) { - ss << name << "(" << iter->second << ")"; + ss << name << iter->second ; iter->second += 1; } else { variableIndex.emplace(name, 1); - ss << name << "(" << 0 << ")"; + ss << name << 0 ; } variable->setName(ss.str()); diff --git a/src/SysYIRPrinter.cpp b/src/SysYIRPrinter.cpp index 4812106..04be4da 100644 --- a/src/SysYIRPrinter.cpp +++ b/src/SysYIRPrinter.cpp @@ -128,12 +128,15 @@ void SysYPrinter::printFunction(Function *function) { std::cout << " @" << function->getName() << "("; auto entryBlock = function->getEntryBlock(); + const auto &args_types = function->getParamTypes(); auto &args = entryBlock->getArguments(); - for (size_t i = 0; i < args.size(); i++) { + int i = 0; + for (const auto &args_type : args_types) { if (i > 0) std::cout << ", "; - printType(args[i]->getType()); + printType(args_type); std::cout << " %" << args[i]->getName(); + i++; } std::cout << ") {" << std::endl;