1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:17:45 +00:00

LibCpp: Add support for parsing reference types

This commit is contained in:
Ali Mohammad Pur 2021-07-28 05:37:24 +04:30 committed by Andreas Kling
parent 3c1422d774
commit 3319114127
3 changed files with 60 additions and 0 deletions

View file

@ -100,6 +100,19 @@ String Pointer::to_string() const
return builder.to_string();
}
String Reference::to_string() const
{
if (!m_referenced_type)
return {};
StringBuilder builder;
builder.append(m_referenced_type->to_string());
if (m_kind == Kind::Lvalue)
builder.append("&");
else
builder.append("&&");
return builder.to_string();
}
void Parameter::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);
@ -359,6 +372,16 @@ void Pointer::dump(FILE* output, size_t indent) const
}
}
void Reference::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);
print_indent(output, indent + 1);
outln(output, "{}", m_kind == Kind::Lvalue ? "&" : "&&");
if (!m_referenced_type.is_null()) {
m_referenced_type->dump(output, indent + 1);
}
}
void MemberExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);