diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 871b4ba..7b01e0e 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -23,6 +23,7 @@ #include "rust-compile-tyty.h" #include "rust-compile-resolve-path.h" #include "rust-compile-block.h" +#include "rust-compile-struct-field-expr.h" namespace Rust { namespace Compile { @@ -56,7 +57,7 @@ public: void visit (HIR::CallExpr &expr) { - Bexpression *fn = ResolvePath::Compile (expr.get_fnexpr (), ctx); + Bexpression *fn = ResolvePathRef::Compile (expr.get_fnexpr (), ctx); rust_assert (fn != nullptr); std::vector<Bexpression *> args; @@ -355,6 +356,25 @@ public: ctx->add_statement (block_stmt); } + void visit (HIR::StructExprStructFields &struct_expr) + { + Btype *type + = ResolvePathType::Compile (&struct_expr.get_struct_name (), ctx); + + // 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; + struct_expr.iterate ([&] (HIR::StructExprField *field) mutable -> bool { + Bexpression *expr = CompileStructExprField::Compile (field, ctx); + vals.push_back (expr); + return true; + }); + + translated + = ctx->get_backend ()->constructor_expression (type, vals, + struct_expr.get_locus ()); + } + private: CompileExpr (Context *ctx) : HIRCompileBase (ctx), translated (nullptr) {} |