diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index fa6a539..2a147ab 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -417,6 +417,24 @@ public: = ctx->get_backend ()->negation_expression (op, negated_expr, location); } + void visit (HIR::TypeCastExpr &expr) override + { + TyTy::BaseType *tyty_to_cast_to = nullptr; + if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), + &tyty_to_cast_to)) + { + translated = ctx->get_backend ()->error_expression (); + return; + } + + auto type_to_cast_to = TyTyResolveCompile::compile (ctx, tyty_to_cast_to); + auto casted_expr + = CompileExpr::Compile (expr.get_casted_expr ().get (), ctx); + translated + = ctx->get_backend ()->convert_expression (type_to_cast_to, casted_expr, + expr.get_locus ()); + } + void visit (HIR::IfExpr &expr) override { auto stmt = CompileConditionalBlocks::compile (&expr, ctx, nullptr); |