aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-07-14 15:06:22 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-07-14 15:07:15 +0100
commit2ff776d36416adbade8161eeda4ee478a288af87 (patch)
tree67638d91bb831d2d243c0d2c81a7ab5d330f09c7 /gcc
parentab9f7f287ef0a775ac6a504d743e20c2f5488f6f (diff)
downloadgcc-2ff776d36416adbade8161eeda4ee478a288af87.zip
gcc-2ff776d36416adbade8161eeda4ee478a288af87.tar.gz
gcc-2ff776d36416adbade8161eeda4ee478a288af87.tar.bz2
Support ast dump of generic parameters on functions
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast-dump.cc32
1 files changed, 28 insertions, 4 deletions
diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index a06dd72..9af8fa8 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -48,7 +48,11 @@ void
Dump::go (AST::Crate &crate)
{
for (auto &item : crate.items)
- item->accept_vis (*this);
+ {
+ stream << indentation;
+ item->accept_vis (*this);
+ stream << "\n";
+ }
}
void
@@ -401,8 +405,12 @@ Dump::visit (AsyncBlockExpr &expr)
void
Dump::visit (TypeParam &param)
{
- // Is it possible to have a null type here?
- param.get_type ()->accept_vis (*this);
+ stream << param.get_type_representation ();
+ if (param.has_type ())
+ {
+ stream << ": ";
+ param.get_type ()->accept_vis (*this);
+ }
}
void
@@ -473,8 +481,24 @@ Dump::visit (UseDeclaration &use_decl)
void
Dump::visit (Function &function)
{
- stream << indentation << "fn " << function.get_function_name () << '(';
+ stream << "fn " << function.get_function_name ();
+
+ if (function.has_generics ())
+ {
+ stream << "<";
+ for (size_t i = 0; i < function.get_generic_params ().size (); i++)
+ {
+ auto &param = function.get_generic_params ().at (i);
+ param->accept_vis (*this);
+
+ bool has_next = (i + 1) < function.get_generic_params ().size ();
+ if (has_next)
+ stream << ", ";
+ }
+ stream << ">";
+ }
+ stream << '(';
auto &params = function.get_function_params ();
if (params.size () >= 1)
{