diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-02-10 17:08:13 +0000 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-02-10 19:28:10 +0000 |
commit | b2aa172ff69591452e3566c105f2a4cd8450eab5 (patch) | |
tree | f9ba781f9c6b29fd8d70f1964f7e238d1ade4f77 /gcc/rust/backend/rust-compile-stmt.h | |
parent | 1b487d72cd2ba46671f5a1bcc20970f2dad1b759 (diff) | |
download | gcc-b2aa172ff69591452e3566c105f2a4cd8450eab5.zip gcc-b2aa172ff69591452e3566c105f2a4cd8450eab5.tar.gz gcc-b2aa172ff69591452e3566c105f2a4cd8450eab5.tar.bz2 |
Refactor code to reuse a canonical way to compile functions and constants
This is a big cleanup so all paths that compile functions and constants
end up in the same path so we avoid any duplication in how we actually
compile a function.
Diffstat (limited to 'gcc/rust/backend/rust-compile-stmt.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-stmt.h | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/gcc/rust/backend/rust-compile-stmt.h b/gcc/rust/backend/rust-compile-stmt.h index 10f9a52..24a2084 100644 --- a/gcc/rust/backend/rust-compile-stmt.h +++ b/gcc/rust/backend/rust-compile-stmt.h @@ -48,34 +48,6 @@ public: translated = CompileExpr::Compile (stmt.get_expr (), ctx); } - void visit (HIR::ConstantItem &constant) override - { - TyTy::BaseType *resolved_type = nullptr; - bool ok - = ctx->get_tyctx ()->lookup_type (constant.get_mappings ().get_hirid (), - &resolved_type); - rust_assert (ok); - - tree type = TyTyResolveCompile::compile (ctx, resolved_type); - tree value = CompileExpr::Compile (constant.get_expr (), ctx); - - const Resolver::CanonicalPath *canonical_path = nullptr; - ok = ctx->get_mappings ()->lookup_canonical_path ( - constant.get_mappings ().get_crate_num (), - constant.get_mappings ().get_nodeid (), &canonical_path); - rust_assert (ok); - - std::string ident = canonical_path->get (); - tree const_expr - = ctx->get_backend ()->named_constant_expression (type, ident, value, - constant.get_locus ()); - - ctx->push_const (const_expr); - ctx->insert_const_decl (constant.get_mappings ().get_hirid (), const_expr); - - translated = const_expr; - } - void visit (HIR::LetStmt &stmt) override { // nothing to do |