diff options
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 6 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 27 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.cc | 1 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-item.cc | 1 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 15 |
5 files changed, 17 insertions, 33 deletions
diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index de9d03f..d17034b 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -254,7 +254,11 @@ public: bool in_fn () { return fn_stack.size () != 0; } // Note: it is undefined behavior to call peek_fn () if fn_stack is empty. - fncontext peek_fn () { return fn_stack.back (); } + fncontext peek_fn () + { + rust_assert (!fn_stack.empty ()); + return fn_stack.back (); + } void push_type (tree t) { type_decls.push_back (t); } void push_var (::Bvariable *v) { var_decls.push_back (v); } diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 2128f25..edeea8d 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -497,10 +497,8 @@ CompileExpr::visit (HIR::CallExpr &expr) // must be a call to a function auto fn_address = CompileExpr::Compile (expr.get_fnexpr (), ctx); - auto fncontext = ctx->peek_fn (); - translated - = ctx->get_backend ()->call_expression (fncontext.fndecl, fn_address, args, - nullptr, expr.get_locus ()); + translated = ctx->get_backend ()->call_expression (fn_address, args, nullptr, + expr.get_locus ()); } void @@ -610,10 +608,8 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) args.push_back (rvalue); } - auto fncontext = ctx->peek_fn (); - translated - = ctx->get_backend ()->call_expression (fncontext.fndecl, fn_expr, args, - nullptr, expr.get_locus ()); + translated = ctx->get_backend ()->call_expression (fn_expr, args, nullptr, + expr.get_locus ()); } tree @@ -696,8 +692,8 @@ CompileExpr::compile_dyn_dispatch_call (const TyTy::DynamicObjectType *dyn, tree fn_expr = ctx->get_backend ()->var_expression (fn_convert_expr_tmp, expr_locus); - return ctx->get_backend ()->call_expression (fnctx.fndecl, fn_expr, args, - nullptr, expr_locus); + return ctx->get_backend ()->call_expression (fn_expr, args, nullptr, + expr_locus); } tree @@ -866,9 +862,8 @@ CompileExpr::resolve_operator_overload ( if (rhs != nullptr) // can be null for negation_expr (unary ones) args.push_back (rhs); - auto fncontext = ctx->peek_fn (); - return ctx->get_backend ()->call_expression (fncontext.fndecl, fn_expr, args, - nullptr, expr.get_locus ()); + return ctx->get_backend ()->call_expression (fn_expr, args, nullptr, + expr.get_locus ()); } tree @@ -1289,10 +1284,8 @@ HIRCompileBase::resolve_deref_adjustment (Resolver::Adjustment &adjustment, } // make the call - auto fncontext = ctx->peek_fn (); - return ctx->get_backend ()->call_expression (fncontext.fndecl, fn_address, - {adjusted_argument}, nullptr, - locus); + return ctx->get_backend ()->call_expression (fn_address, {adjusted_argument}, + nullptr, locus); } tree diff --git a/gcc/rust/backend/rust-compile-implitem.cc b/gcc/rust/backend/rust-compile-implitem.cc index 7cc214c..9dc6d14 100644 --- a/gcc/rust/backend/rust-compile-implitem.cc +++ b/gcc/rust/backend/rust-compile-implitem.cc @@ -52,6 +52,7 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func) rust_assert (concrete->get_kind () == TyTy::TypeKind::FNDEF); TyTy::FnType *fntype = static_cast<TyTy::FnType *> (concrete); + fntype->monomorphize (); // items can be forward compiled which means we may not need to invoke this // code. We might also have already compiled this generic function as well. diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc index 80b7ceb..969c852 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -127,6 +127,7 @@ CompileItem::visit (HIR::Function &function) { rust_assert (concrete->get_kind () == TyTy::TypeKind::FNDEF); fntype = static_cast<TyTy::FnType *> (concrete); + fntype->monomorphize (); } } diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 2ad672d..55a2fff 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -251,21 +251,6 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, rust_assert (ok); // found rust_assert (trait_item_ref->is_optional ()); // has definition - Analysis::NodeMapping trait_mappings - = trait_item_ref->get_parent_trait_mappings (); - - HirId associated_impl_id; - ok = ctx->get_tyctx ()->lookup_associated_impl_mapping_for_self ( - trait_mappings.get_hirid (), receiver, &associated_impl_id); - rust_assert (ok); - - Resolver::AssociatedImplTrait *associated = nullptr; - bool found_associated_trait_impl - = ctx->get_tyctx ()->lookup_associated_trait_impl ( - associated_impl_id, &associated); - rust_assert (found_associated_trait_impl); - associated->setup_associated_types (); - return CompileTraitItem::Compile ( trait_item_ref->get_hir_trait_item (), ctx, lookup, true, expr_locus); |