From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id E8689380FDF7; Wed, 8 Jun 2022 12:15:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8689380FDF7 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] Got rid of lambda in TyTy::FnPtr iterate_params X-Act-Checkin: gcc X-Git-Author: M V V S Manoj Kumar X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: 10de9cf4f3765526a1a82a4a7d14908b58c6538c X-Git-Newrev: 3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62 Message-Id: <20220608121521.E8689380FDF7@sourceware.org> Date: Wed, 8 Jun 2022 12:15:21 +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:15:22 -0000 https://gcc.gnu.org/g:3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62 commit 3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62 Author: M V V S Manoj Kumar Date: Thu Feb 24 06:56:32 2022 +0530 Got rid of lambda in TyTy::FnPtr iterate_params Fixes issue #734 1)Removed iterate_params function 2)Created a get_params function which returns std::vector& params Signed-off-by : M V V S Manoj Kumar Diff: --- gcc/rust/backend/rust-compile-type.cc | 12 +++++++----- gcc/rust/typecheck/rust-tyty.cc | 11 +++++++---- gcc/rust/typecheck/rust-tyty.h | 3 +++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc index 6de063b7f6e..6c0b0a0c57b 100644 --- a/gcc/rust/backend/rust-compile-type.cc +++ b/gcc/rust/backend/rust-compile-type.cc @@ -148,11 +148,13 @@ TyTyResolveCompile::visit (const TyTy::FnPtr &type) tree result_type = TyTyResolveCompile::compile (ctx, type.get_return_type ()); std::vector parameters; - type.iterate_params ([&] (TyTy::BaseType *p) mutable -> bool { - tree pty = TyTyResolveCompile::compile (ctx, p); - parameters.push_back (pty); - return true; - }); + + auto ¶ms = type.get_params (); + for (auto &p : params) + { + tree pty = TyTyResolveCompile::compile (ctx, p.get_tyty ()); + parameters.push_back (pty); + } translated = ctx->get_backend ()->function_ptr_type (result_type, parameters, type.get_ident ().locus); diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 0dde2998bf2..52bb5717257 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -1294,10 +1294,13 @@ std::string FnPtr::as_string () const { std::string params_str; - iterate_params ([&] (BaseType *p) mutable -> bool { - params_str += p->as_string () + " ,"; - return true; - }); + + auto ¶ms = get_params (); + for (auto &p : params) + { + params_str += p.get_tyty ()->as_string () + " ,"; + } + return "fnptr (" + params_str + ") -> " + get_return_type ()->as_string (); } diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 036d7723bad..940352584dd 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -1526,6 +1526,9 @@ public: } } + std::vector &get_params () { return params; } + const std::vector &get_params () const { return params; } + bool is_concrete () const override final { for (auto &p : params)