mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 02:29:21 +00:00
LibCpp: Add support for parsing reference types
This commit is contained in:
parent
3c1422d774
commit
3319114127
Notes:
sideshowbarker
2024-07-18 07:36:29 +09:00
Author: https://github.com/alimpfard
Commit: 3319114127
Pull-request: https://github.com/SerenityOS/serenity/pull/9156
Reviewed-by: https://github.com/itamar8910 ✅
3 changed files with 60 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue