public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Got rid of lambda in TyTy::FnPtr iterate_params
@ 2022-06-08 12:15 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:15 UTC (permalink / raw)
  To: gcc-cvs

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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-08 12:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:15 [gcc/devel/rust/master] Got rid of lambda in TyTy::FnPtr iterate_params Thomas Schwinge

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).