aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.cc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-02-10 17:08:13 +0000
committerPhilip Herron <philip.herron@embecosm.com>2022-02-10 19:28:10 +0000
commitb2aa172ff69591452e3566c105f2a4cd8450eab5 (patch)
treef9ba781f9c6b29fd8d70f1964f7e238d1ade4f77 /gcc/rust/backend/rust-compile-expr.cc
parent1b487d72cd2ba46671f5a1bcc20970f2dad1b759 (diff)
downloadgcc-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-expr.cc')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc9
1 files changed, 4 insertions, 5 deletions
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))
{