diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-02-03 16:45:27 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-02-06 15:45:51 +0000 |
commit | 34a39466b2adb9684a1737c6ea4915e0194c26bf (patch) | |
tree | df65323e28a0b4507431969d62ac932fc2efb2d3 /gcc/rust/backend/rust-compile-item.h | |
parent | 59a8fa1a80c3b2c6520c627a6bf200274732d395 (diff) | |
download | gcc-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/backend/rust-compile-item.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-item.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/rust/backend/rust-compile-item.h b/gcc/rust/backend/rust-compile-item.h index b08c49e..7f93af9f 100644 --- a/gcc/rust/backend/rust-compile-item.h +++ b/gcc/rust/backend/rust-compile-item.h @@ -282,9 +282,18 @@ public: void visit (HIR::InherentImpl &impl_block) { + TyTy::TyBase *self_lookup = nullptr; + if (!ctx->get_tyctx ()->lookup_type ( + impl_block.get_type ()->get_mappings ().get_hirid (), &self_lookup)) + { + rust_error_at (impl_block.get_locus (), + "failed to resolve type of impl"); + return; + } + for (auto &impl_item : impl_block.get_impl_items ()) - CompileInherentImplItem::Compile (impl_block.get_type ().get (), - impl_item.get (), ctx, compile_fns); + CompileInherentImplItem::Compile (self_lookup, impl_item.get (), ctx, + compile_fns); } private: |