diff options
author | Nirmal Patel <npate012@gmail.com> | 2021-10-28 13:58:03 -0400 |
---|---|---|
committer | Nirmal Patel <npate012@gmail.com> | 2021-10-28 13:58:03 -0400 |
commit | 08b83163db07c903a6524f15f9adce4a0e7fa359 (patch) | |
tree | 22cc4400519d1b4826596dceb1faf6cb07520fc8 /gcc | |
parent | e28c43f2f40cf405e89b3892aa65f6a06fa1c802 (diff) | |
download | gcc-08b83163db07c903a6524f15f9adce4a0e7fa359.zip gcc-08b83163db07c903a6524f15f9adce4a0e7fa359.tar.gz gcc-08b83163db07c903a6524f15f9adce4a0e7fa359.tar.bz2 |
Remove iterate_params from AST::CallExpr and AST::MethodCallExpr
These lambda iterators are removed because they make working
with IR more complex. Instead, we are using the get_params ()
to access the parameters with the help of a for loop.
Fixes #722 #723
Signed-off-by: Nirmal Patel <npate012@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-expr.h | 18 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-expr.h | 23 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-expr.h | 14 |
3 files changed, 19 insertions, 36 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h index 0d3c50e..05c78b7 100644 --- a/gcc/rust/ast/rust-expr.h +++ b/gcc/rust/ast/rust-expr.h @@ -1916,15 +1916,6 @@ public: void mark_for_strip () override { function = nullptr; } bool is_marked_for_strip () const override { return function == nullptr; } - void iterate_params (std::function<bool (Expr *)> cb) - { - for (auto ¶m : params) - { - if (!cb (param.get ())) - return; - } - } - // TODO: this mutable getter seems really dodgy. Think up better way. const std::vector<std::unique_ptr<Expr> > &get_params () const { @@ -2025,15 +2016,6 @@ public: void mark_for_strip () override { receiver = nullptr; } bool is_marked_for_strip () const override { return receiver == nullptr; } - void iterate_params (std::function<bool (Expr *)> cb) - { - for (auto ¶m : params) - { - if (!cb (param.get ())) - return; - } - } - // TODO: this mutable getter seems really dodgy. Think up better way. const std::vector<std::unique_ptr<Expr> > &get_params () const { diff --git a/gcc/rust/hir/rust-ast-lower-expr.h b/gcc/rust/hir/rust-ast-lower-expr.h index 782045d..54cb6113 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.h +++ b/gcc/rust/hir/rust-ast-lower-expr.h @@ -192,12 +192,14 @@ public: { HIR::Expr *func = ASTLoweringExpr::translate (expr.get_function_expr ().get ()); + + auto const &in_params = expr.get_params (); std::vector<std::unique_ptr<HIR::Expr> > params; - expr.iterate_params ([&] (AST::Expr *p) mutable -> bool { - auto trans = ASTLoweringExpr::translate (p); - params.push_back (std::unique_ptr<HIR::Expr> (trans)); - return true; - }); + for (auto ¶m : in_params) + { + auto trans = ASTLoweringExpr::translate (param.get ()); + params.push_back (std::unique_ptr<HIR::Expr> (trans)); + } auto crate_num = mappings->get_current_crate (); Analysis::NodeMapping mapping ( @@ -217,12 +219,13 @@ public: HIR::Expr *receiver = ASTLoweringExpr::translate (expr.get_receiver_expr ().get ()); + auto const &in_params = expr.get_params (); std::vector<std::unique_ptr<HIR::Expr> > params; - expr.iterate_params ([&] (AST::Expr *p) mutable -> bool { - auto trans = ASTLoweringExpr::translate (p); - params.push_back (std::unique_ptr<HIR::Expr> (trans)); - return true; - }); + for (auto ¶m : in_params) + { + auto trans = ASTLoweringExpr::translate (param.get ()); + params.push_back (std::unique_ptr<HIR::Expr> (trans)); + } auto crate_num = mappings->get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.h b/gcc/rust/resolve/rust-ast-resolve-expr.h index 48906f5..12a4f8c 100644 --- a/gcc/rust/resolve/rust-ast-resolve-expr.h +++ b/gcc/rust/resolve/rust-ast-resolve-expr.h @@ -101,10 +101,9 @@ public: void visit (AST::CallExpr &expr) override { ResolveExpr::go (expr.get_function_expr ().get (), expr.get_node_id ()); - expr.iterate_params ([&] (AST::Expr *p) mutable -> bool { - ResolveExpr::go (p, expr.get_node_id ()); - return true; - }); + auto const &in_params = expr.get_params (); + for (auto ¶m : in_params) + ResolveExpr::go (param.get (), expr.get_node_id ()); } void visit (AST::MethodCallExpr &expr) override @@ -117,10 +116,9 @@ public: ResolveTypeToCanonicalPath::type_resolve_generic_args (args); } - expr.iterate_params ([&] (AST::Expr *p) mutable -> bool { - ResolveExpr::go (p, expr.get_node_id ()); - return true; - }); + auto const &in_params = expr.get_params (); + for (auto ¶m : in_params) + ResolveExpr::go (param.get (), expr.get_node_id ()); } void visit (AST::AssignmentExpr &expr) override |