diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-02-25 15:21:34 +0000 |
---|---|---|
committer | Philip Herron <herron.philip@googlemail.com> | 2021-03-01 10:35:07 +0000 |
commit | ec9ead44a40ee68de7fc39e32a47662c44281deb (patch) | |
tree | 72af294bf6f54e4becebb22a860823f12aed062c /gcc/rust/backend/rust-compile.cc | |
parent | 9af2ae0ff91535da104db0d3828d863770439fad (diff) | |
download | gcc-ec9ead44a40ee68de7fc39e32a47662c44281deb.zip gcc-ec9ead44a40ee68de7fc39e32a47662c44281deb.tar.gz gcc-ec9ead44a40ee68de7fc39e32a47662c44281deb.tar.bz2 |
Adds the same support from generic structs in #235 onto tuple structs
Type binding still not supported here but the same generic support is added
to tuples.
Fixes #236
Diffstat (limited to 'gcc/rust/backend/rust-compile.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 61bacf3..2c83527 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -53,11 +53,21 @@ CompileCrate::go () void CompileExpr::visit (HIR::CallExpr &expr) { - Btype *type = ResolvePathType::Compile (expr.get_fnexpr (), ctx); - if (type != nullptr) + TyTy::BaseType *tyty = nullptr; + if (!ctx->get_tyctx ()->lookup_type ( + expr.get_fnexpr ()->get_mappings ().get_hirid (), &tyty)) { - // this assumes all fields are in order from type resolution and if a base - // struct was specified those fields are filed via accesors + rust_error_at (expr.get_locus (), "unknown type"); + return; + } + + // must be a tuple constructor + if (tyty->get_kind () != TyTy::TypeKind::FNDEF) + { + Btype *type = TyTyResolveCompile::compile (ctx, tyty); + + // this assumes all fields are in order from type resolution and if a + // base struct was specified those fields are filed via accesors std::vector<Bexpression *> vals; expr.iterate_params ([&] (HIR::Expr *argument) mutable -> bool { Bexpression *e = CompileExpr::Compile (argument, ctx); |