引入了常量池优化,修改constvalue类并对IR生成修复,能够编译通过

This commit is contained in:
rain2133
2025-06-19 00:18:58 +08:00
parent 1aa785efc3
commit 1de8c0e7d7
4 changed files with 194 additions and 64 deletions

View File

@@ -552,10 +552,10 @@ std::any SysYIRGenerator::visitNumber(SysYParser::NumberContext *ctx) {
} else if (text.find("0") == 0) {
base = 8;
}
res = ConstantValue::get((int)std::stol(text, 0, base));
res = ConstantValue::get(Type::getIntType() ,(int)std::stol(text, 0, base));
} else if (auto fLiteral = ctx->FLITERAL()) {
const auto text = fLiteral->getText();
res = ConstantValue::get((float)std::stof(text));
res = ConstantValue::get(Type::getFloatType(), (float)std::stof(text));
}
cout << "number: ";
res->print(cout);