aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-03-04 11:30:52 +0000
committerGitHub <noreply@github.com>2022-03-04 11:30:52 +0000
commitb4bd389c66a3e3bf0489626a1a70c2500d415ef8 (patch)
treeb9fbe9d56d8d2220768c3bbf104de4a1f4dc8e26 /gcc
parente35da26d8ed884b27050c6cbfe2460696e4c9ebe (diff)
parent3f2d5a720b2be5b75eab2aa56af0b48a9bae5f62 (diff)
downloadgcc-b4bd389c66a3e3bf0489626a1a70c2500d415ef8.zip
gcc-b4bd389c66a3e3bf0489626a1a70c2500d415ef8.tar.gz
gcc-b4bd389c66a3e3bf0489626a1a70c2500d415ef8.tar.bz2
Merge #984
984: Implimented Soluion 1 and solution 2 for issue_734 r=philberty a=mvvsmk Fixes #734 Done : - [x] Remove iterate_params function - [x] Create new get_params function Solution 1 1) Created a new get_params function which returns the parameters. 2) Changed the references of the iterate_params to use get_params. Solution 2 1) Added get_params2 which returns `std::vector<TyTy::BaseType*>` 2) Changed the references of the iterate_params to use get_params. Status : Currently I have implemented the first solution. Signed-off-by : M V V S Manoj Kumar <mvvsmanojkumar@gmail.com> Co-authored-by: M V V S Manoj Kumar <mvvsmanojkumar@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-compile-type.cc12
-rw-r--r--gcc/rust/typecheck/rust-tyty.cc11
-rw-r--r--gcc/rust/typecheck/rust-tyty.h3
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 21da9af..ba6a206 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 fa5dcfb..0a29644 100644
--- a/gcc/rust/typecheck/rust-tyty.cc
+++ b/gcc/rust/typecheck/rust-tyty.cc
@@ -1295,10 +1295,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 85948b2..bf4110b 100644
--- a/gcc/rust/typecheck/rust-tyty.h
+++ b/gcc/rust/typecheck/rust-tyty.h
@@ -1527,6 +1527,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)