From b2aa172ff69591452e3566c105f2a4cd8450eab5 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Thu, 10 Feb 2022 17:08:13 +0000 Subject: 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. --- gcc/rust/backend/rust-compile-expr.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gcc/rust/backend/rust-compile-expr.cc') diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index f65e1fd..ab560e8 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -18,6 +18,7 @@ #include "rust-compile.h" #include "rust-compile-item.h" +#include "rust-compile-implitem.h" #include "rust-compile-expr.h" #include "rust-compile-struct-field-expr.h" #include "rust-hir-trait-resolve.h" @@ -713,7 +714,7 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref, tree fn = NULL_TREE; if (ctx->lookup_function_decl (fntype->get_ty_ref (), &fn)) { - return ctx->get_backend ()->function_code_expression (fn, expr_locus); + return address_expression (fn, expr_locus); } // Now we can try and resolve the address since this might be a forward @@ -765,8 +766,7 @@ CompileExpr::resolve_method_address (TyTy::FnType *fntype, HirId ref, // contain an implementation we should actually return // error_mark_node - return CompileTraitItem::Compile (receiver, - trait_item_ref->get_hir_trait_item (), + return CompileTraitItem::Compile (trait_item_ref->get_hir_trait_item (), ctx, fntype, true, expr_locus); } else @@ -1343,8 +1343,7 @@ CompileExpr::visit (HIR::IdentifierExpr &expr) } else if (ctx->lookup_function_decl (ref, &fn)) { - translated - = ctx->get_backend ()->function_code_expression (fn, expr.get_locus ()); + translated = address_expression (fn, expr.get_locus ()); } else if (ctx->lookup_var_decl (ref, &var)) { -- cgit v1.1