diff options
author | Marc Poulhiès <dkm@kataplop.net> | 2023-04-06 19:20:55 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:28:46 +0100 |
commit | cd773704975f399a8c736a84509dfe2e106412a7 (patch) | |
tree | 715cceae0c9950946dcfa86ee8857d242a47f074 /gcc/rust/hir/tree/rust-hir-expr.h | |
parent | e64909cebf611f469ed0fea3083a567274b340ad (diff) | |
download | gcc-cd773704975f399a8c736a84509dfe2e106412a7.zip gcc-cd773704975f399a8c736a84509dfe2e106412a7.tar.gz gcc-cd773704975f399a8c736a84509dfe2e106412a7.tar.bz2 |
gccrs: Introduce AST::Visitable class for AST
AST::Visitable is an abstract class with a unique accept_vis() method.
Make all abstract AST node class inherit from this class.
Allows for easy definition of operations on nodes that must accept a
visitor.
The static Dump::dump() is an example of such use: the static method
accepts any AST node, creates a Dump visitor and have it visit the AST
starting at the node.
This change also inserts a debug(Visitable&) function in the global
namespace to make it easy to call from the debugger (similar to
debug_tree or debug(rtx*) functions).
gcc/rust/ChangeLog:
* ast/rust-ast-dump.cc (Dump::debug): New.
* ast/rust-ast-dump.h (Dump::debug): Untemplate it.
(debug): New.
* ast/rust-ast.h (class Visitable): New.
(class TokenTree): Inherit from Visitable.
(class MacroMatch): Likewise.
(class AttrInput): Likewise.
(class MetaItemInner): Likewise.
(class Pattern): Likewise.
(classTypeParamBound): Likewise.
(class GenericParam): Likewise.
(class TraitItem): Likewise.
(classInherentImplItem): Likewise.
(class TraitImplItem): Likewise.
(class ExternalItem): Likewise.
(class SingleASTNode): Likewise.
Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/hir/tree/rust-hir-expr.h')
0 files changed, 0 insertions, 0 deletions