diff options
author | Marc Poulhiès <dkm@kataplop.net> | 2023-07-03 21:04:45 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:55:56 +0100 |
commit | bcd76dbcaabe6752657befcd8f4fec4d53126fd2 (patch) | |
tree | 48390d0818e4e435c2ddfa691f1f80d446cc831d /gcc/rust/hir/tree | |
parent | 8288dc0fedc2fd227b9cd31c5e36ee39839689ee (diff) | |
download | gcc-bcd76dbcaabe6752657befcd8f4fec4d53126fd2.zip gcc-bcd76dbcaabe6752657befcd8f4fec4d53126fd2.tar.gz gcc-bcd76dbcaabe6752657befcd8f4fec4d53126fd2.tar.bz2 |
gccrs: rework the HIR dump pass
Nearly complete rewrite of the HIR dump pass.
fixes #693
gcc/rust/ChangeLog:
* hir/rust-hir-dump.cc (convert_param_kind_to_str): New.
(convert_new_bind_type_to_str): New.
(convert_mut_to_str): New.
(Dump::go): New.
(Dump::put): New.
(Dump::begin): New.
(Dump::end): New.
(Dump::begin_field): New.
(Dump::end_field): New.
(Dump::put_field): New.
(Dump::visit_field): New.
(Dump::visit): Refactor.
(Dump::visit_collection): New.
(Dump::do_traititem): New.
(Dump::do_vis_item): New.
(Dump::do_functionparam): New.
(Dump::do_pathpattern): New.
(Dump::do_structexprstruct): New.
(Dump::do_expr): New.
(Dump::do_pathexpr): New.
(Dump::do_typepathsegment): New.
(Dump::do_typepathfunction): New.
(Dump::do_qualifiedpathtype): New.
(Dump::do_operatorexpr): New.
(Dump::do_mappings): New.
(Dump::do_inner_attrs): New.
(Dump::do_outer_attrs): New.
(Dump::do_baseloopexpr): New.
(Dump::do_ifletexpr): New.
(Dump::do_struct): New.
(Dump::do_enumitem): New.
(Dump::do_traitfunctiondecl): New.
(Dump::do_externalitem): New.
(Dump::do_namefunctionparam): New.
(Dump::do_stmt): New.
(Dump::do_type): New.
(Dump::do_item): New.
(Dump::do_tuplefield): New.
(Dump::do_structfield): New.
(Dump::do_genericargs): New.
(Dump::do_maybenamedparam): New.
* hir/rust-hir-dump.h: Refactor.
* hir/tree/rust-hir-item.h (enum_to_str): New.
* hir/tree/rust-hir-type.h (enum_to_str): New.
* hir/tree/rust-hir.cc (enum_to_str): New.
* util/rust-common.h (enum_to_str): New.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/hir/tree')
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-item.h | 2 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir-type.h | 2 | ||||
-rw-r--r-- | gcc/rust/hir/tree/rust-hir.cc | 30 |
3 files changed, 34 insertions, 0 deletions
diff --git a/gcc/rust/hir/tree/rust-hir-item.h b/gcc/rust/hir/tree/rust-hir-item.h index 2d4cae5..cb0dc13 100644 --- a/gcc/rust/hir/tree/rust-hir-item.h +++ b/gcc/rust/hir/tree/rust-hir-item.h @@ -1009,6 +1009,8 @@ protected: } }; +std::string enum_to_str (UseTreeRebind::NewBindType); + // Rust use declaration (i.e. for modules) HIR node class UseDeclaration : public VisItem { diff --git a/gcc/rust/hir/tree/rust-hir-type.h b/gcc/rust/hir/tree/rust-hir-type.h index 08a389e..37d108e 100644 --- a/gcc/rust/hir/tree/rust-hir-type.h +++ b/gcc/rust/hir/tree/rust-hir-type.h @@ -750,6 +750,8 @@ public: Identifier get_name () const { return name; } }; +std::string enum_to_str (MaybeNamedParam::ParamKind); + /* A function pointer type - can be created via coercion from function items and * non- capturing closures. */ class BareFunctionType : public TypeNoBounds diff --git a/gcc/rust/hir/tree/rust-hir.cc b/gcc/rust/hir/tree/rust-hir.cc index 276c1a7..6e626c6 100644 --- a/gcc/rust/hir/tree/rust-hir.cc +++ b/gcc/rust/hir/tree/rust-hir.cc @@ -3670,6 +3670,36 @@ MaybeNamedParam::as_string () const return str; } +std::string +enum_to_str (MaybeNamedParam::ParamKind pk) +{ + switch (pk) + { + case MaybeNamedParam::ParamKind::UNNAMED: + return "UNNAMED"; + case MaybeNamedParam::ParamKind::IDENTIFIER: + return "IDENTIFIER"; + case MaybeNamedParam::ParamKind::WILDCARD: + return "WILDCARD"; + } + gcc_unreachable (); +} + +std::string +enum_to_str (UseTreeRebind::NewBindType nbt) +{ + switch (nbt) + { + case UseTreeRebind::NewBindType::NONE: + return "NONE"; + case UseTreeRebind::NewBindType::IDENTIFIER: + return "IDENTIFIER"; + case UseTreeRebind::NewBindType::WILDCARD: + return "WILDCARD"; + } + gcc_unreachable (); +} + /* Override that calls the function recursively on all items contained within * the module. */ void |