summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCpp/AST.cpp
diff options
context:
space:
mode:
authoriyush <aayushsharma889@gmail.com>2023-04-15 16:40:40 +0200
committerSam Atkins <atkinssj@gmail.com>2023-04-26 09:40:25 +0100
commitac435f914c2461691263b1becc64854f9de2fddd (patch)
tree51ff9f96b54d3f80058af342ad7ae3413441f030 /Userland/Libraries/LibCpp/AST.cpp
parent34b04271f40b8ecaeb43603187266f5398313d5b (diff)
downloadserenity-ac435f914c2461691263b1becc64854f9de2fddd.zip
LibCpp: Support for parsing c-style fixed arrays (arr[2])
Also adds tests for finding declaration of arrays inside CppComprehension which requires proper parsing for passing. Side-effect of this patch: if we ctrl+click on array variables, it should jump to the correct declaration inside HackStudio.
Diffstat (limited to 'Userland/Libraries/LibCpp/AST.cpp')
-rw-r--r--Userland/Libraries/LibCpp/AST.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp
index 610f7ada75..92c666b9a0 100644
--- a/Userland/Libraries/LibCpp/AST.cpp
+++ b/Userland/Libraries/LibCpp/AST.cpp
@@ -572,6 +572,24 @@ StringView TemplatizedName::full_name() const
return *m_full_name;
}
+void SizedName::dump(FILE* output, size_t indent) const
+{
+ Name::dump(output, indent);
+ print_indent(output, indent + 1);
+
+ StringBuilder dimension_info;
+ for (auto const& dim : m_dimensions) {
+ dimension_info.append('[');
+ dimension_info.append(dim);
+ dimension_info.append(']');
+ }
+
+ if (dimension_info.is_empty()) {
+ dimension_info.append("[]"sv);
+ }
+ outln(output, "{}", dimension_info.to_deprecated_string());
+}
+
void CppCastExpression::dump(FILE* output, size_t indent) const
{
ASTNode::dump(output, indent);