diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index 7b01e0e..9081000 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -155,6 +155,36 @@ public: } return; + case HIR::Literal::FLOAT: { + printf ("FLOATY BOYO: [%s]\n", expr.as_string ().c_str ()); + + mpfr_t fval; + if (mpfr_init_set_str (fval, expr.as_string ().c_str (), 10, + MPFR_RNDN) + != 0) + { + rust_fatal_error (expr.get_locus (), + "bad float number in literal"); + return; + } + + TyTy::TyBase *tyty = nullptr; + if (!ctx->get_tyctx ()->lookup_type ( + expr.get_mappings ().get_hirid (), &tyty)) + { + rust_fatal_error (expr.get_locus (), + "did not resolve type for this literal expr"); + return; + } + + printf ("tyty float is [%s]\n", tyty->as_string ().c_str ()); + + Btype *type = TyTyResolveCompile::compile (ctx, tyty); + translated + = ctx->get_backend ()->float_constant_expression (type, fval); + } + return; + default: rust_fatal_error (expr.get_locus (), "unknown literal"); return; |