diff options
Diffstat (limited to 'gcc/rust/backend')
-rw-r--r-- | gcc/rust/backend/rust-compile-base.cc | 6 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-context.h | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.cc | 22 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-extern.h | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-implitem.cc | 4 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-intrinsic.cc | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-item.cc | 10 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 12 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile-type.cc | 22 | ||||
-rw-r--r-- | gcc/rust/backend/rust-compile.cc | 2 | ||||
-rw-r--r-- | gcc/rust/backend/rust-mangle-v0.cc | 14 |
11 files changed, 50 insertions, 50 deletions
diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index 67d8797..e313820 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -877,7 +877,7 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype, // Now we can try and resolve the address since this might be a forward // declared function, generic function which has not be compiled yet or // its an not yet trait bound function - HIR::Item *resolved_item = ctx->get_mappings ()->lookup_defid (id); + HIR::Item *resolved_item = ctx->get_mappings ().lookup_defid (id); if (resolved_item != nullptr) { if (!fntype->has_substitutions_defined ()) @@ -888,8 +888,8 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype, // it might be resolved to a trait item HIR::TraitItem *trait_item - = ctx->get_mappings ()->lookup_trait_item_defid (id); - HIR::Trait *trait = ctx->get_mappings ()->lookup_trait_item_mapping ( + = ctx->get_mappings ().lookup_trait_item_defid (id); + HIR::Trait *trait = ctx->get_mappings ().lookup_trait_item_mapping ( trait_item->get_mappings ().get_hirid ()); Resolver::TraitReference *trait_ref diff --git a/gcc/rust/backend/rust-compile-context.h b/gcc/rust/backend/rust-compile-context.h index 156c7b1..a446388 100644 --- a/gcc/rust/backend/rust-compile-context.h +++ b/gcc/rust/backend/rust-compile-context.h @@ -89,7 +89,7 @@ public: Resolver::Resolver *get_resolver () { return resolver; } Resolver::TypeCheckContext *get_tyctx () { return tyctx; } - Analysis::Mappings *get_mappings () { return mappings; } + Analysis::Mappings &get_mappings () { return mappings; } void push_block (tree scope) { @@ -390,7 +390,7 @@ public: private: Resolver::Resolver *resolver; Resolver::TypeCheckContext *tyctx; - Analysis::Mappings *mappings; + Analysis::Mappings &mappings; Mangler mangler; // state diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 9ffd863..0980e6c 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -120,7 +120,7 @@ CompileExpr::visit (HIR::ReturnExpr &expr) TyTy::BaseType *expected = fncontext.retty; location_t lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ref ()); TyTy::BaseType *actual = nullptr; bool ok = ctx->get_tyctx ()->lookup_type ( @@ -456,7 +456,7 @@ CompileExpr::visit (HIR::StructExprStructFields &struct_expr) // process arguments auto &argument = struct_expr.get_fields ().at (0); auto lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); auto rvalue_locus = argument->get_locus (); auto rvalue = CompileStructExprField::Compile (argument.get (), ctx); @@ -488,7 +488,7 @@ CompileExpr::visit (HIR::StructExprStructFields &struct_expr) // process arguments auto &argument = struct_expr.get_fields ().at (i); auto lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); auto rvalue_locus = argument->get_locus (); auto rvalue = CompileStructExprField::Compile (argument.get (), ctx); @@ -735,7 +735,7 @@ CompileExpr::visit (HIR::BreakExpr &expr) } HirId ref = UNKNOWN_HIRID; - if (!ctx->get_mappings ()->lookup_node_to_hir (resolved_node_id, &ref)) + if (!ctx->get_mappings ().lookup_node_to_hir (resolved_node_id, &ref)) { rust_fatal_error (expr.get_locus (), "reverse lookup label failure"); return; @@ -779,7 +779,7 @@ CompileExpr::visit (HIR::ContinueExpr &expr) } HirId ref = UNKNOWN_HIRID; - if (!ctx->get_mappings ()->lookup_node_to_hir (resolved_node_id, &ref)) + if (!ctx->get_mappings ().lookup_node_to_hir (resolved_node_id, &ref)) { rust_fatal_error (expr.get_locus (), "reverse lookup label failure"); return; @@ -1153,7 +1153,7 @@ CompileExpr::visit (HIR::CallExpr &expr) // coerce it if required location_t lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); location_t rvalue_locus = argument->get_locus (); rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue, @@ -1257,7 +1257,7 @@ CompileExpr::visit (HIR::CallExpr &expr) // coerce it if required location_t lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); location_t rvalue_locus = argument->get_locus (); rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue, actual, expected, lvalue_locus, rvalue_locus); @@ -1346,7 +1346,7 @@ CompileExpr::visit (HIR::MethodCallExpr &expr) // coerce it if required location_t lvalue_locus - = ctx->get_mappings ()->lookup_location (expected->get_ty_ref ()); + = ctx->get_mappings ().lookup_location (expected->get_ty_ref ()); location_t rvalue_locus = argument->get_locus (); rvalue = coercion_site (argument->get_mappings ().get_hirid (), rvalue, actual, expected, lvalue_locus, rvalue_locus); @@ -2175,7 +2175,7 @@ CompileExpr::visit (HIR::ClosureExpr &expr) { // lookup the HirId HirId ref = UNKNOWN_HIRID; - bool ok = ctx->get_mappings ()->lookup_node_to_hir (capture, &ref); + bool ok = ctx->get_mappings ().lookup_node_to_hir (capture, &ref); rust_assert (ok); // lookup the var decl @@ -2209,7 +2209,7 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr, const Resolver::CanonicalPath &parent_canonical_path = closure_tyty.get_ident ().path; NodeId node_id; - bool ok = ctx->get_mappings ()->lookup_hir_to_node ( + bool ok = ctx->get_mappings ().lookup_hir_to_node ( expr.get_mappings ().get_hirid (), &node_id); rust_assert (ok); Resolver::CanonicalPath path = parent_canonical_path.append ( @@ -2245,7 +2245,7 @@ CompileExpr::generate_closure_function (HIR::ClosureExpr &expr, { // lookup the HirId HirId ref = UNKNOWN_HIRID; - bool ok = ctx->get_mappings ()->lookup_node_to_hir (capture, &ref); + bool ok = ctx->get_mappings ().lookup_node_to_hir (capture, &ref); rust_assert (ok); // get the assessor diff --git a/gcc/rust/backend/rust-compile-extern.h b/gcc/rust/backend/rust-compile-extern.h index 7dbf7d7..f596ed2f 100644 --- a/gcc/rust/backend/rust-compile-extern.h +++ b/gcc/rust/backend/rust-compile-extern.h @@ -135,7 +135,7 @@ public: { // then we need to get the canonical path of it and mangle it const Resolver::CanonicalPath *canonical_path = nullptr; - bool ok = ctx->get_mappings ()->lookup_canonical_path ( + bool ok = ctx->get_mappings ().lookup_canonical_path ( function.get_mappings ().get_nodeid (), &canonical_path); rust_assert (ok); diff --git a/gcc/rust/backend/rust-compile-implitem.cc b/gcc/rust/backend/rust-compile-implitem.cc index 7435833..0f24417 100644 --- a/gcc/rust/backend/rust-compile-implitem.cc +++ b/gcc/rust/backend/rust-compile-implitem.cc @@ -28,7 +28,7 @@ CompileTraitItem::visit (HIR::TraitItemConst &constant) TyTy::BaseType *resolved_type = concrete; const Resolver::CanonicalPath *canonical_path = nullptr; - bool ok = ctx->get_mappings ()->lookup_canonical_path ( + bool ok = ctx->get_mappings ().lookup_canonical_path ( constant.get_mappings ().get_nodeid (), &canonical_path); rust_assert (ok); @@ -78,7 +78,7 @@ CompileTraitItem::visit (HIR::TraitItemFunc &func) } const Resolver::CanonicalPath *canonical_path = nullptr; - bool ok = ctx->get_mappings ()->lookup_canonical_path ( + bool ok = ctx->get_mappings ().lookup_canonical_path ( func.get_mappings ().get_nodeid (), &canonical_path); rust_assert (ok); diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc index f94659c..de3bb6e 100644 --- a/gcc/rust/backend/rust-compile-intrinsic.cc +++ b/gcc/rust/backend/rust-compile-intrinsic.cc @@ -269,7 +269,7 @@ Intrinsics::compile (TyTy::FnType *fntype) if (it != generic_intrinsics.end ()) return it->second (ctx, fntype); - location_t locus = ctx->get_mappings ()->lookup_location (fntype->get_ref ()); + location_t locus = ctx->get_mappings ().lookup_location (fntype->get_ref ()); rust_error_at (locus, ErrorCode::E0093, "unrecognized intrinsic function: %qs", fntype->get_identifier ().c_str ()); diff --git a/gcc/rust/backend/rust-compile-item.cc b/gcc/rust/backend/rust-compile-item.cc index 7c62adc..9d65b61 100644 --- a/gcc/rust/backend/rust-compile-item.cc +++ b/gcc/rust/backend/rust-compile-item.cc @@ -43,7 +43,7 @@ CompileItem::visit (HIR::StaticItem &var) tree type = TyTyResolveCompile::compile (ctx, resolved_type); const Resolver::CanonicalPath *canonical_path = nullptr; - ok = ctx->get_mappings ()->lookup_canonical_path ( + ok = ctx->get_mappings ().lookup_canonical_path ( var.get_mappings ().get_nodeid (), &canonical_path); rust_assert (ok); @@ -103,8 +103,8 @@ CompileItem::visit (HIR::ConstantItem &constant) else { const Resolver::CanonicalPath *canonical_path_ptr = nullptr; - ok = ctx->get_mappings ()->lookup_canonical_path (mappings.get_nodeid (), - &canonical_path_ptr); + ok = ctx->get_mappings ().lookup_canonical_path (mappings.get_nodeid (), + &canonical_path_ptr); rust_assert (ok); canonical_path = *canonical_path_ptr; } @@ -155,7 +155,7 @@ CompileItem::visit (HIR::Function &function) HirId parent_impl_block = UNKNOWN_HIRID; HirId id = function.get_mappings ().get_hirid (); HIR::ImplItem *impl_item - = ctx->get_mappings ()->lookup_hir_implitem (id, &parent_impl_block); + = ctx->get_mappings ().lookup_hir_implitem (id, &parent_impl_block); if (impl_item != nullptr) { Resolver::AssociatedImplTrait *impl = nullptr; @@ -182,7 +182,7 @@ CompileItem::visit (HIR::Function &function) else { const Resolver::CanonicalPath *path = nullptr; - bool ok = ctx->get_mappings ()->lookup_canonical_path ( + bool ok = ctx->get_mappings ().lookup_canonical_path ( function.get_mappings ().get_nodeid (), &path); rust_assert (ok); diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 91f2deb..ea8bb5b 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -126,7 +126,7 @@ ResolvePathRef::resolve (const HIR::PathIdentSegment &final_segment, } HirId ref; - if (!ctx->get_mappings ()->lookup_node_to_hir (ref_node_id, &ref)) + if (!ctx->get_mappings ().lookup_node_to_hir (ref_node_id, &ref)) { rust_error_at (expr_locus, "reverse call path lookup failure"); return error_mark_node; @@ -199,10 +199,10 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, const Analysis::NodeMapping &mappings, location_t expr_locus, bool is_qualified_path) { - HIR::Item *resolved_item = ctx->get_mappings ()->lookup_hir_item (ref); + HIR::Item *resolved_item = ctx->get_mappings ().lookup_hir_item (ref); HirId parent_block; HIR::ExternalItem *resolved_extern_item - = ctx->get_mappings ()->lookup_hir_extern_item (ref, &parent_block); + = ctx->get_mappings ().lookup_hir_extern_item (ref, &parent_block); bool is_hir_item = resolved_item != nullptr; bool is_hir_extern_item = resolved_extern_item != nullptr; bool is_fn = lookup->get_kind () == TyTy::TypeKind::FNDEF; @@ -242,7 +242,7 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, HirId parent_impl_id = UNKNOWN_HIRID; HIR::ImplItem *resolved_item - = ctx->get_mappings ()->lookup_hir_implitem (ref, &parent_impl_id); + = ctx->get_mappings ().lookup_hir_implitem (ref, &parent_impl_id); bool is_impl_item = resolved_item != nullptr; if (is_impl_item) { @@ -257,8 +257,8 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, { // it might be resolved to a trait item HIR::TraitItem *trait_item - = ctx->get_mappings ()->lookup_hir_trait_item (ref); - HIR::Trait *trait = ctx->get_mappings ()->lookup_trait_item_mapping ( + = ctx->get_mappings ().lookup_hir_trait_item (ref); + HIR::Trait *trait = ctx->get_mappings ().lookup_trait_item_mapping ( trait_item->get_mappings ().get_hirid ()); Resolver::TraitReference *trait_ref diff --git a/gcc/rust/backend/rust-compile-type.cc b/gcc/rust/backend/rust-compile-type.cc index bfc2464..4b42cef 100644 --- a/gcc/rust/backend/rust-compile-type.cc +++ b/gcc/rust/backend/rust-compile-type.cc @@ -147,7 +147,7 @@ TyTyResolveCompile::visit (const TyTy::PlaceholderType &type) void TyTyResolveCompile::visit (const TyTy::ClosureType &type) { - auto mappings = ctx->get_mappings (); + auto &mappings = ctx->get_mappings (); std::vector<Backend::typed_identifier> fields; @@ -156,7 +156,7 @@ TyTyResolveCompile::visit (const TyTy::ClosureType &type) { // lookup the HirId HirId ref = UNKNOWN_HIRID; - bool ok = mappings->lookup_node_to_hir (capture, &ref); + bool ok = mappings.lookup_node_to_hir (capture, &ref); rust_assert (ok); // lookup the var decl type @@ -201,7 +201,7 @@ TyTyResolveCompile::visit (const TyTy::FnType &type) { auto ret = TyTyResolveCompile::compile (ctx, hir_type, trait_object_mode); location_t return_type_locus - = ctx->get_mappings ()->lookup_location (hir_type->get_ref ()); + = ctx->get_mappings ().lookup_location (hir_type->get_ref ()); results.push_back ( Backend::typed_identifier ("_", ret, return_type_locus)); } @@ -214,7 +214,7 @@ TyTyResolveCompile::visit (const TyTy::FnType &type) auto compiled_param = Backend::typed_identifier ( param_pair.first->as_string (), compiled_param_type, - ctx->get_mappings ()->lookup_location (param_tyty->get_ref ())); + ctx->get_mappings ().lookup_location (param_tyty->get_ref ())); parameters.push_back (compiled_param); } @@ -263,7 +263,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) = TyTyResolveCompile::compile (ctx, field->get_field_type ()); Backend::typed_identifier f (field->get_name (), compiled_field_ty, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -307,7 +307,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) tree enumeral_type = TyTyResolveCompile::get_implicit_enumeral_node_type (ctx); Backend::typed_identifier f (RUST_ENUM_DISR_FIELD_NAME, enumeral_type, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( variant->get_id ())); fields.push_back (std::move (f)); @@ -326,7 +326,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) Backend::typed_identifier f ( field_name, compiled_field_ty, - ctx->get_mappings ()->lookup_location (type.get_ty_ref ())); + ctx->get_mappings ().lookup_location (type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -353,7 +353,7 @@ TyTyResolveCompile::visit (const TyTy::ADTType &type) std::string implicit_variant_name = variant->get_identifier (); Backend::typed_identifier f (implicit_variant_name, variant_record, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); enum_fields.push_back (std::move (f)); } @@ -411,7 +411,7 @@ TyTyResolveCompile::visit (const TyTy::TupleType &type) // approach makes it simpler to use a C-only debugger, or // GDB's C mode, when debugging Rust. Backend::typed_identifier f ("__" + std::to_string (i), compiled_field_ty, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); } @@ -714,14 +714,14 @@ TyTyResolveCompile::create_dyn_obj_record (const TyTy::DynamicObjectType &type) tree uintptr_ty = build_pointer_type (uint); Backend::typed_identifier f ("pointer", uintptr_ty, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (f)); tree vtable_size = build_int_cst (size_type_node, items.size ()); tree vtable_type = Backend::array_type (uintptr_ty, vtable_size); Backend::typed_identifier vtf ("vtable", vtable_type, - ctx->get_mappings ()->lookup_location ( + ctx->get_mappings ().lookup_location ( type.get_ty_ref ())); fields.push_back (std::move (vtf)); diff --git a/gcc/rust/backend/rust-compile.cc b/gcc/rust/backend/rust-compile.cc index 47a6dad..20190c3 100644 --- a/gcc/rust/backend/rust-compile.cc +++ b/gcc/rust/backend/rust-compile.cc @@ -189,7 +189,7 @@ HIRCompileBase::coerce_to_dyn_object (tree compiled_ref, location_t locus) { // DST's get wrapped in a pseudo reference that doesnt exist... - const TyTy::ReferenceType r (ctx->get_mappings ()->get_next_hir_id (), + const TyTy::ReferenceType r (ctx->get_mappings ().get_next_hir_id (), TyTy::TyVar (ty->get_ref ()), Mutability::Imm); tree dynamic_object = TyTyResolveCompile::compile (ctx, &r); diff --git a/gcc/rust/backend/rust-mangle-v0.cc b/gcc/rust/backend/rust-mangle-v0.cc index c8582b5..0c85d42 100644 --- a/gcc/rust/backend/rust-mangle-v0.cc +++ b/gcc/rust/backend/rust-mangle-v0.cc @@ -369,13 +369,13 @@ static std::string v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, const Resolver::CanonicalPath &cpath) { - auto mappings = Analysis::Mappings::get (); + auto &mappings = Analysis::Mappings::get (); V0Path v0path = {}; cpath.iterate_segs ([&] (const Resolver::CanonicalPath &seg) { HirId hir_id; - bool ok = mappings->lookup_node_to_hir (seg.get_node_id (), &hir_id); + bool ok = mappings.lookup_node_to_hir (seg.get_node_id (), &hir_id); if (!ok) { // FIXME: generic arg in canonical path? (e.g. <i32> in crate::S<i32>) @@ -384,10 +384,10 @@ v0_path (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, HirId parent_impl_id = UNKNOWN_HIRID; HIR::ImplItem *impl_item - = mappings->lookup_hir_implitem (hir_id, &parent_impl_id); - HIR::TraitItem *trait_item = mappings->lookup_hir_trait_item (hir_id); - HIR::Item *item = mappings->lookup_hir_item (hir_id); - HIR::Expr *expr = mappings->lookup_hir_expr (hir_id); + = mappings.lookup_hir_implitem (hir_id, &parent_impl_id); + HIR::TraitItem *trait_item = mappings.lookup_hir_trait_item (hir_id); + HIR::Item *item = mappings.lookup_hir_item (hir_id); + HIR::Expr *expr = mappings.lookup_hir_expr (hir_id); if (impl_item != nullptr) { @@ -490,7 +490,7 @@ v0_mangle_item (Rust::Compile::Context *ctx, const TyTy::BaseType *ty, rust_debug ("Start mangling: %s", path.get ().c_str ()); // TODO: get Instanciating CrateNum - // auto mappings = Analysis::Mappings::get (); + // auto &mappings = Analysis::Mappings::get (); // std::string crate_name; // bool ok = mappings->get_crate_name (path.get_crate_num (), crate_name); // rust_assert (ok); |