diff options
author | M V V S Manoj Kumar <mvvsmanojkumar@gmail.com> | 2022-02-24 06:56:32 +0530 |
---|---|---|
committer | M V V S Manoj Kumar <mvvsmanojkumar@gmail.com> | 2022-03-04 08:27:22 +0530 |
commit | 3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62 (patch) | |
tree | 8fe1d64cb0fadf75eaef84c12b17b8a5da8da9f0 /gcc | |
parent | 10de9cf4f3765526a1a82a4a7d14908b58c6538c (diff) | |
download | gcc-3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62.zip gcc-3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62.tar.gz gcc-3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62.tar.bz2 |
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/backend/rust-compile-type.cc | 12 | ||||
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 11 | ||||
-rw-r--r-- | 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 6de063b..6c0b0a0 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 ¶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 0dde299..52bb571 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 036d772..9403525 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) |