Skip to content

Commit b4bd389

Browse files
bors[bot]mvvsmk
andauthored
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>
2 parents e35da26 + 3f2d5a7 commit b4bd389

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

gcc/rust/backend/rust-compile-type.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,13 @@ TyTyResolveCompile::visit (const TyTy::FnPtr &type)
148148
tree result_type = TyTyResolveCompile::compile (ctx, type.get_return_type ());
149149

150150
std::vector<tree> parameters;
151-
type.iterate_params ([&] (TyTy::BaseType *p) mutable -> bool {
152-
tree pty = TyTyResolveCompile::compile (ctx, p);
153-
parameters.push_back (pty);
154-
return true;
155-
});
151+
152+
auto &params = type.get_params ();
153+
for (auto &p : params)
154+
{
155+
tree pty = TyTyResolveCompile::compile (ctx, p.get_tyty ());
156+
parameters.push_back (pty);
157+
}
156158

157159
translated = ctx->get_backend ()->function_ptr_type (result_type, parameters,
158160
type.get_ident ().locus);

gcc/rust/typecheck/rust-tyty.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,10 +1295,13 @@ std::string
12951295
FnPtr::as_string () const
12961296
{
12971297
std::string params_str;
1298-
iterate_params ([&] (BaseType *p) mutable -> bool {
1299-
params_str += p->as_string () + " ,";
1300-
return true;
1301-
});
1298+
1299+
auto &params = get_params ();
1300+
for (auto &p : params)
1301+
{
1302+
params_str += p.get_tyty ()->as_string () + " ,";
1303+
}
1304+
13021305
return "fnptr (" + params_str + ") -> " + get_return_type ()->as_string ();
13031306
}
13041307

gcc/rust/typecheck/rust-tyty.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,9 @@ class FnPtr : public BaseType
15271527
}
15281528
}
15291529

1530+
std::vector<TyVar> &get_params () { return params; }
1531+
const std::vector<TyVar> &get_params () const { return params; }
1532+
15301533
bool is_concrete () const override final
15311534
{
15321535
for (auto &p : params)

0 commit comments

Comments
 (0)