public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] Got rid of lambda in TyTy::FnPtr iterate_params
Date: Wed,  8 Jun 2022 12:15:21 +0000 (GMT)	[thread overview]
Message-ID: <20220608121521.E8689380FDF7@sourceware.org> (raw)

https://gcc.gnu.org/g:3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62

commit 3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62
Author: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
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 <mvvsmanojkumar@gmail.com>

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<tree> parameters;
-  type.iterate_params ([&] (TyTy::BaseType *p) mutable -> bool {
-    tree pty = TyTyResolveCompile::compile (ctx, p);
-    parameters.push_back (pty);
-    return true;
-  });
+
+  auto &params = 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 &params = 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<TyVar> &get_params () { return params; }
+  const std::vector<TyVar> &get_params () const { return params; }
+
   bool is_concrete () const override final
   {
     for (auto &p : params)


                 reply	other threads:[~2022-06-08 12:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220608121521.E8689380FDF7@sourceware.org \
    --to=tschwinge@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).