From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 06A7E3892D15; Wed, 8 Jun 2022 12:25:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 06A7E3892D15 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] single_ast_node: Add TYPE kind X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: e8b9587d3a0615f497cfe9c66995c1f21e42a536 X-Git-Newrev: cf94fd8d51fcbf5f857a26dc7ae09e29384abc95 Message-Id: <20220608122511.06A7E3892D15@sourceware.org> Date: Wed, 8 Jun 2022 12:25:11 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 12:25:11 -0000 https://gcc.gnu.org/g:cf94fd8d51fcbf5f857a26dc7ae09e29384abc95 commit cf94fd8d51fcbf5f857a26dc7ae09e29384abc95 Author: Arthur Cohen Date: Mon Mar 28 10:33:25 2022 +0200 single_ast_node: Add TYPE kind Diff: --- gcc/rust/ast/rust-ast.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index a22c2d1ad1d..5368c427b42 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -1515,6 +1515,7 @@ public: TRAIT, IMPL, TRAIT_IMPL, + TYPE, }; private: @@ -1528,6 +1529,7 @@ private: std::unique_ptr trait_item; std::unique_ptr impl_item; std::unique_ptr trait_impl_item; + std::unique_ptr type; public: SingleASTNode (std::unique_ptr expr) @@ -1558,6 +1560,10 @@ public: : kind (TRAIT_IMPL), trait_impl_item (std::move (trait_impl_item)) {} + SingleASTNode (std::unique_ptr type) + : kind (TYPE), type (std::move (type)) + {} + SingleASTNode (SingleASTNode const &other) { kind = other.kind; @@ -1590,6 +1596,10 @@ public: case TRAIT_IMPL: trait_impl_item = other.trait_impl_item->clone_trait_impl_item (); break; + + case TYPE: + type = other.type->clone_type (); + break; } } @@ -1625,6 +1635,10 @@ public: case TRAIT_IMPL: trait_impl_item = other.trait_impl_item->clone_trait_impl_item (); break; + + case TYPE: + type = other.type->clone_type (); + break; } return *this; } @@ -1699,6 +1713,12 @@ public: return std::move (trait_impl_item); } + std::unique_ptr take_type () + { + rust_assert (!is_error ()); + return std::move (type); + } + void accept_vis (ASTVisitor &vis) { switch (kind) @@ -1730,6 +1750,10 @@ public: case TRAIT_IMPL: trait_impl_item->accept_vis (vis); break; + + case TYPE: + type->accept_vis (vis); + break; } } @@ -1751,6 +1775,8 @@ public: return impl_item == nullptr; case TRAIT_IMPL: return trait_impl_item == nullptr; + case TYPE: + return type == nullptr; } gcc_unreachable (); @@ -1775,6 +1801,8 @@ public: return "Impl Item: " + impl_item->as_string (); case TRAIT_IMPL: return "Trait Impl Item: " + impl_item->as_string (); + case TYPE: + return "Type: " + type->as_string (); } gcc_unreachable ();