aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/ast/rust-expr.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-02-03 16:45:27 +0000
committerPhilip Herron <herron.philip@googlemail.com>2021-02-06 15:45:51 +0000
commit34a39466b2adb9684a1737c6ea4915e0194c26bf (patch)
treedf65323e28a0b4507431969d62ac932fc2efb2d3 /gcc/rust/ast/rust-expr.h
parent59a8fa1a80c3b2c6520c627a6bf200274732d395 (diff)
downloadgcc-34a39466b2adb9684a1737c6ea4915e0194c26bf.zip
gcc-34a39466b2adb9684a1737c6ea4915e0194c26bf.tar.gz
gcc-34a39466b2adb9684a1737c6ea4915e0194c26bf.tar.bz2
Add in support to compile Methods and MethodCallExpr
There is more work to be done here with adjustments to the self argument such as borrows and mutability checking. Method resolution is basic, for now there is code to scan for all possible matches but traits are not supported at the moment so this resolves quite simply for now. Fixes #191 #112
Diffstat (limited to 'gcc/rust/ast/rust-expr.h')
-rw-r--r--gcc/rust/ast/rust-expr.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 6dba7fd..50006d1 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -2355,9 +2355,9 @@ public:
void iterate_params (std::function<bool (Expr *)> cb)
{
- for (auto it = params.begin (); it != params.end (); it++)
+ for (auto &param : params)
{
- if (!cb (it->get ()))
+ if (!cb (param.get ()))
return;
}
}
@@ -2456,6 +2456,15 @@ 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 &param : 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
{