aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-expr.cc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-02-11 10:29:35 +0000
committerGitHub <noreply@github.com>2022-02-11 10:29:35 +0000
commit9023bb8687347559702340c24cd72301f0656a59 (patch)
treed4059dbe453be902ebd68d4704160db6942bb1b3 /gcc/rust/backend/rust-compile-expr.cc
parente2823b6747b36362387e5b26e8792f06185d7de8 (diff)
parent4242d45d3d6590630ea88909ed996b8cf2640d35 (diff)
downloadgcc-9023bb8687347559702340c24cd72301f0656a59.zip
gcc-9023bb8687347559702340c24cd72301f0656a59.tar.gz
gcc-9023bb8687347559702340c24cd72301f0656a59.tar.bz2
Merge #918
918: Refactor code to reuse a canonical way to compile items r=philberty a=philberty 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 or constant. Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
-rw-r--r--gcc/rust/backend/rust-compile-expr.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc
index f65e1fd..a592e35 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"
@@ -204,7 +205,7 @@ CompileExpr::visit (HIR::MatchExpr &expr)
expr.get_scrutinee_expr ()->get_mappings ().get_hirid (),
&scrutinee_expr_tyty))
{
- translated = ctx->get_backend ()->error_expression ();
+ translated = error_mark_node;
return;
}
@@ -220,7 +221,7 @@ CompileExpr::visit (HIR::MatchExpr &expr)
if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (),
&expr_tyty))
{
- translated = ctx->get_backend ()->error_expression ();
+ translated = error_mark_node;
return;
}
@@ -643,7 +644,7 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn,
}
if (ref == nullptr)
- return ctx->get_backend ()->error_expression ();
+ return error_mark_node;
// get any indirection sorted out
if (receiver->get_kind () == TyTy::TypeKind::REF)
@@ -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))
{