From b9013bda082602ecdc6519009fe82c8f17d2cc4d Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Tue, 14 Jun 2022 13:20:45 +0200 Subject: ast: Add get_kind() virtual function for GenericParam class --- gcc/rust/ast/rust-ast.h | 11 +++++++++++ gcc/rust/ast/rust-item.h | 2 ++ 2 files changed, 13 insertions(+) (limited to 'gcc/rust/ast') diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 8f5657f..2d7d31a 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -1255,6 +1255,13 @@ protected: class GenericParam { public: + enum class Kind + { + Lifetime, + Type, + Const, + }; + virtual ~GenericParam () {} // Unique pointer custom clone function @@ -1269,6 +1276,8 @@ public: virtual Location get_locus () const = 0; + virtual Kind get_kind () const = 0; + NodeId get_node_id () { return node_id; } protected: @@ -1322,6 +1331,8 @@ public: Location get_locus () const override final { return locus; } + Kind get_kind () const override final { return Kind::Lifetime; } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 6d953fb..94ffffb 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -132,6 +132,8 @@ public: Location get_locus () const override final { return locus; } + Kind get_kind () const override final { return Kind::Type; } + void accept_vis (ASTVisitor &vis) override; // TODO: is this better? Or is a "vis_block" better? -- cgit v1.1