Format ref-structs correctly

This commit is contained in:
Sofia 2026-04-15 19:07:49 +03:00
parent 94d1c15897
commit 8e7facc593
3 changed files with 9 additions and 3 deletions

View File

@ -564,13 +564,13 @@ namespace types {
fields.push_back(field.second->codegen(builder, structs)); fields.push_back(field.second->codegen(builder, structs));
} }
auto ty = llvm::StructType::get(*builder.context, fields); auto ty = llvm::StructType::create(*builder.context, fields);
if (this->m_name) if (this->m_name)
ty->setName(*this->m_name); ty->setName(*this->m_name);
return ty; return ty;
} }
else { else {
auto ty = llvm::StructType::get(*builder.context); auto ty = llvm::StructType::create(*builder.context);
if (this->m_name) if (this->m_name)
ty->setName(*this->m_name); ty->setName(*this->m_name);
return ty; return ty;

View File

@ -164,6 +164,10 @@ namespace types {
std::string StructType::formatted() { std::string StructType::formatted() {
std::stringstream out{ "" }; std::stringstream out{ "" };
out << "struct"; out << "struct";
if (this->m_is_ref)
out << "(ref)";
out << " ";
if (this->m_name) { if (this->m_name) {
out << *this->m_name << " "; out << *this->m_name << " ";
} }

2
test.c
View File

@ -24,5 +24,7 @@ int main() {
printf(" first element: %d!", somelist[0]); printf(" first element: %d!", somelist[0]);
struct Otus otus;
return 0; return 0;
} }