diff options
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-base.cc | 40 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-base.h | 2 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-block.h | 18 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-enumitem.h | 44 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-expr.cc | 152 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-extern.h | 30 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-implitem.cc | 80 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-item.cc | 143 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-pattern.cc | 65 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-stmt.cc | 18 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-struct-field-expr.h | 4 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-type.cc | 126 | ||||
-rw-r--r-- | gcc/rust/hir/rust-ast-lower.cc | 66 |
13 files changed, 390 insertions, 398 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc index e40c5cd..6803ad4 100644 --- a/gcc/rust/hir/rust-ast-lower-base.cc +++ b/gcc/rust/hir/rust-ast-lower-base.cc @@ -537,11 +537,11 @@ ASTLoweringBase::lower_lifetime (AST::Lifetime &lifetime, lifetime_type = AST::Lifetime::STATIC; } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, lifetime.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); - mappings->insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ()); + mappings.insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ()); return HIR::Lifetime (mapping, lifetime_type, lifetime.get_lifetime_name (), lifetime.get_locus ()); @@ -552,11 +552,11 @@ ASTLoweringBase::lower_loop_label (AST::LoopLabel &loop_label) { HIR::Lifetime life = lower_lifetime (loop_label.get_lifetime ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, loop_label.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); - mappings->insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ()); + mappings.insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ()); return HIR::LoopLabel (mapping, std::move (life), loop_label.get_locus ()); } @@ -578,9 +578,9 @@ ASTLoweringBase::lower_generic_params ( HIR::PathExprSegment ASTLoweringBase::lower_path_expr_seg (AST::PathExprSegment &s) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, s.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); return HIR::PathExprSegment ( @@ -651,10 +651,10 @@ ASTLoweringBase::lower_self (AST::Param ¶m) rust_assert (param.is_self ()); auto self = static_cast<AST::SelfParam &> (param); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, self.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); if (self.has_type ()) { @@ -792,8 +792,8 @@ ASTLoweringBase::handle_lang_item_attribute (const ItemWrapper &item, auto lang_item_type = LangItem::Parse (lang_item_type_str); if (lang_item_type) - mappings->insert_lang_item (*lang_item_type, - item.get_mappings ().get_defid ()); + mappings.insert_lang_item (*lang_item_type, + item.get_mappings ().get_defid ()); else rust_error_at (attr.get_locus (), "unknown lang item"); } @@ -940,10 +940,10 @@ ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block) { HIR::Visibility vis = translate_visibility (extern_block.get_visibility ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, extern_block.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); std::vector<std::unique_ptr<HIR::ExternalItem>> extern_items; for (auto &item : extern_block.get_extern_items ()) @@ -972,7 +972,7 @@ ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block) extern_block.get_outer_attrs (), extern_block.get_locus ()); - mappings->insert_hir_extern_block (hir_extern_block); + mappings.insert_hir_extern_block (hir_extern_block); return hir_extern_block; } @@ -987,9 +987,9 @@ ASTLoweringBase::lower_macro_definition (AST::MacroRulesDefinition &def) if (is_export) { - mappings->insert_exported_macro (def); - mappings->insert_ast_item (&def); - mappings->insert_location (def.get_node_id (), def.get_locus ()); + mappings.insert_exported_macro (def); + mappings.insert_ast_item (&def); + mappings.insert_location (def.get_node_id (), def.get_locus ()); } } diff --git a/gcc/rust/hir/rust-ast-lower-base.h b/gcc/rust/hir/rust-ast-lower-base.h index 1207153..2987bb1 100644 --- a/gcc/rust/hir/rust-ast-lower-base.h +++ b/gcc/rust/hir/rust-ast-lower-base.h @@ -261,7 +261,7 @@ protected: attr_mappings (Analysis::BuiltinAttributeMappings::get ()) {} - Analysis::Mappings *mappings; + Analysis::Mappings &mappings; Analysis::BuiltinAttributeMappings *attr_mappings; HIR::Lifetime lower_lifetime (AST::Lifetime &lifetime, diff --git a/gcc/rust/hir/rust-ast-lower-block.h b/gcc/rust/hir/rust-ast-lower-block.h index 40aec12..be6ca64 100644 --- a/gcc/rust/hir/rust-ast-lower-block.h +++ b/gcc/rust/hir/rust-ast-lower-block.h @@ -37,7 +37,7 @@ public: expr.accept_vis (resolver); if (resolver.translated != nullptr) { - resolver.mappings->insert_hir_expr (resolver.translated); + resolver.mappings.insert_hir_expr (resolver.translated); } *terminated = resolver.terminated; @@ -51,9 +51,9 @@ public: HIR::BlockExpr *block = ASTLoweringBlock::translate (expr.get_block_expr (), terminated); - auto crate_num = resolver.mappings->get_current_crate (); + auto crate_num = resolver.mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - resolver.mappings->get_next_hir_id ( + resolver.mappings.get_next_hir_id ( crate_num), UNKNOWN_LOCAL_DEFID); @@ -62,7 +62,7 @@ public: std::unique_ptr<HIR::BlockExpr> (block), expr.get_outer_attrs (), expr.get_locus ()); - resolver.mappings->insert_hir_expr (translated); + resolver.mappings.insert_hir_expr (translated); return translated; } @@ -89,7 +89,7 @@ public: expr.accept_vis (resolver); if (resolver.translated != nullptr) { - resolver.mappings->insert_hir_expr (resolver.translated); + resolver.mappings.insert_hir_expr (resolver.translated); } *terminated = resolver.terminated; return resolver.translated; @@ -121,7 +121,7 @@ public: expr.accept_vis (resolver); if (resolver.translated != nullptr) { - resolver.mappings->insert_hir_expr (resolver.translated); + resolver.mappings.insert_hir_expr (resolver.translated); } return resolver.translated; } @@ -150,7 +150,7 @@ public: expr.accept_vis (resolver); if (resolver.translated != nullptr) { - resolver.mappings->insert_hir_expr (resolver.translated); + resolver.mappings.insert_hir_expr (resolver.translated); } *terminated = resolver.terminated; @@ -196,9 +196,9 @@ public: HIR::LoopLabel loop_label = lower_loop_label (expr.get_loop_label ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated diff --git a/gcc/rust/hir/rust-ast-lower-enumitem.h b/gcc/rust/hir/rust-ast-lower-enumitem.h index 50baf6a..1b95345 100644 --- a/gcc/rust/hir/rust-ast-lower-enumitem.h +++ b/gcc/rust/hir/rust-ast-lower-enumitem.h @@ -45,19 +45,19 @@ public: auto hirid = resolver.translated->get_mappings ().get_hirid (); auto defid = resolver.translated->get_mappings ().get_defid (); - resolver.mappings->insert_defid_mapping (defid, resolver.translated); - resolver.mappings->insert_location (hirid, - resolver.translated->get_locus ()); + resolver.mappings.insert_defid_mapping (defid, resolver.translated); + resolver.mappings.insert_location (hirid, + resolver.translated->get_locus ()); return resolver.translated; } void visit (AST::EnumItem &item) override { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, item.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); if (item.has_visibility ()) rust_error_at (item.get_locus (), @@ -69,10 +69,10 @@ public: void visit (AST::EnumItemTuple &item) override { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, item.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); if (item.has_visibility ()) rust_error_at (item.get_locus (), @@ -85,11 +85,10 @@ public: HIR::Visibility vis = translate_visibility (field.get_visibility ()); HIR::Type *type = ASTLoweringType::translate (field.get_field_type ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping field_mapping ( - crate_num, field.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + crate_num, field.get_node_id (), mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::TupleField translated_field (field_mapping, std::unique_ptr<HIR::Type> (type), @@ -106,10 +105,10 @@ public: void visit (AST::EnumItemStruct &item) override { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, item.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); if (item.has_visibility ()) rust_error_at (item.get_locus (), @@ -122,11 +121,10 @@ public: HIR::Visibility vis = translate_visibility (field.get_visibility ()); HIR::Type *type = ASTLoweringType::translate (field.get_field_type ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping field_mapping ( - crate_num, field.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + crate_num, field.get_node_id (), mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::StructField translated_field (field_mapping, field.get_field_name (), @@ -148,10 +146,10 @@ public: void visit (AST::EnumItemDiscriminant &item) override { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, item.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); if (item.has_visibility ()) rust_error_at (item.get_locus (), diff --git a/gcc/rust/hir/rust-ast-lower-expr.cc b/gcc/rust/hir/rust-ast-lower-expr.cc index 6ca2d9a..6927139 100644 --- a/gcc/rust/hir/rust-ast-lower-expr.cc +++ b/gcc/rust/hir/rust-ast-lower-expr.cc @@ -45,8 +45,8 @@ ASTLoweringExpr::translate (AST::Expr &expr, bool *terminated) return nullptr; } - resolver.mappings->insert_hir_expr (resolver.translated); - resolver.mappings->insert_location ( + resolver.mappings.insert_hir_expr (resolver.translated); + resolver.mappings.insert_location ( resolver.translated->get_mappings ().get_hirid (), expr.get_locus ()); if (terminated != nullptr) @@ -61,9 +61,9 @@ ASTLoweringExpr::visit (AST::TupleIndexExpr &expr) HIR::Expr *tuple_expr = ASTLoweringExpr::translate (expr.get_tuple_expr (), &terminated); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -82,9 +82,9 @@ ASTLoweringExpr::visit (AST::TupleExpr &expr) tuple_elements.push_back (std::unique_ptr<HIR::Expr> (t)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -150,9 +150,9 @@ ASTLoweringExpr::visit (AST::ReturnExpr &expr) ? ASTLoweringExpr::translate (expr.get_returned_expr ()) : nullptr; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::ReturnExpr (mapping, expr.get_locus (), @@ -172,10 +172,10 @@ ASTLoweringExpr::visit (AST::CallExpr &expr) params.push_back (std::unique_ptr<HIR::Expr> (trans)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping ( crate_num, UNKNOWN_NODEID /* this can map back to the AST*/, - mappings->get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::CallExpr (mapping, std::unique_ptr<HIR::Expr> (func), std::move (params), expr.get_outer_attrs (), @@ -198,9 +198,9 @@ ASTLoweringExpr::visit (AST::MethodCallExpr &expr) params.push_back (std::unique_ptr<HIR::Expr> (trans)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -215,9 +215,9 @@ ASTLoweringExpr::visit (AST::AssignmentExpr &expr) HIR::Expr *lhs = ASTLoweringExpr::translate (expr.get_left_expr ()); HIR::Expr *rhs = ASTLoweringExpr::translate (expr.get_right_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -229,9 +229,9 @@ ASTLoweringExpr::visit (AST::AssignmentExpr &expr) void ASTLoweringExpr::visit (AST::IdentifierExpr &expr) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping1 (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); Analysis::NodeMapping mapping2 (mapping1); @@ -249,9 +249,9 @@ ASTLoweringExpr::visit (AST::ArrayExpr &expr) rust_assert (translated_array_elems != nullptr); HIR::ArrayElems *elems = translated_array_elems; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -267,9 +267,9 @@ ASTLoweringExpr::visit (AST::ArrayIndexExpr &expr) HIR::Expr *array_index_expr = ASTLoweringExpr::translate (expr.get_index_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -288,10 +288,10 @@ ASTLoweringExpr::visit (AST::ArrayElemsValues &elems) elements.push_back (std::unique_ptr<HIR::Expr> (translated_elem)); } - auto crate_num = mappings->get_current_crate (); - Analysis::NodeMapping mapping (mappings->get_current_crate (), + auto crate_num = mappings.get_current_crate (); + Analysis::NodeMapping mapping (mappings.get_current_crate (), elems.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated_array_elems @@ -304,10 +304,10 @@ ASTLoweringExpr::visit (AST::ArrayElemsCopied &elems) HIR::Expr *element = ASTLoweringExpr::translate (elems.get_elem_to_copy ()); HIR::Expr *num_copies = ASTLoweringExpr::translate (elems.get_num_copies ()); - auto crate_num = mappings->get_current_crate (); - Analysis::NodeMapping mapping (mappings->get_current_crate (), + auto crate_num = mappings.get_current_crate (); + Analysis::NodeMapping mapping (mappings.get_current_crate (), elems.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated_array_elems @@ -318,9 +318,9 @@ ASTLoweringExpr::visit (AST::ArrayElemsCopied &elems) void ASTLoweringExpr::visit (AST::LiteralExpr &expr) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::Literal l = lower_literal (expr.get_literal ()); @@ -336,9 +336,9 @@ ASTLoweringExpr::visit (AST::ArithmeticOrLogicalExpr &expr) HIR::Expr *rhs = ASTLoweringExpr::translate (expr.get_right_expr ()); rust_assert (rhs != nullptr); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::ArithmeticOrLogicalExpr ( @@ -354,9 +354,9 @@ ASTLoweringExpr::visit (AST::ComparisonExpr &expr) HIR::Expr *rhs = ASTLoweringExpr::translate (expr.get_right_expr ()); rust_assert (rhs != nullptr); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -373,9 +373,9 @@ ASTLoweringExpr::visit (AST::LazyBooleanExpr &expr) HIR::Expr *rhs = ASTLoweringExpr::translate (expr.get_right_expr ()); rust_assert (rhs != nullptr); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -390,9 +390,9 @@ ASTLoweringExpr::visit (AST::NegationExpr &expr) HIR::Expr *negated_value = ASTLoweringExpr::translate (expr.get_negated_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::NegationExpr (mapping, @@ -409,9 +409,9 @@ ASTLoweringExpr::visit (AST::TypeCastExpr &expr) HIR::Type *type_to_cast_to = lower_type_no_bounds (expr.get_type_to_cast_to ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -464,9 +464,9 @@ ASTLoweringExpr::visit (AST::CompoundAssignmentExpr &expr) HIR::Expr *asignee_expr = ASTLoweringExpr::translate (expr.get_left_expr ()); HIR::Expr *value = ASTLoweringExpr::translate (expr.get_right_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::CompoundAssignmentExpr ( @@ -482,9 +482,9 @@ ASTLoweringExpr::visit (AST::StructExprStruct &struct_expr) HIR::PathInExpression copied_path (*path); delete path; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, struct_expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::StructExprStruct (mapping, copied_path, @@ -519,9 +519,9 @@ ASTLoweringExpr::visit (AST::StructExprStructFields &struct_expr) fields.push_back (std::unique_ptr<HIR::StructExprField> (translated)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, struct_expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -537,9 +537,9 @@ ASTLoweringExpr::visit (AST::GroupedExpr &expr) HIR::Expr *paren_expr = ASTLoweringExpr::translate (expr.get_expr_in_parens ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -553,9 +553,9 @@ ASTLoweringExpr::visit (AST::FieldAccessExpr &expr) { HIR::Expr *receiver = ASTLoweringExpr::translate (expr.get_receiver_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::FieldAccessExpr (mapping, std::unique_ptr<HIR::Expr> (receiver), @@ -591,9 +591,9 @@ ASTLoweringExpr::visit (AST::BreakExpr &expr) ? ASTLoweringExpr::translate (expr.get_break_expr ()) : nullptr; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -607,9 +607,9 @@ ASTLoweringExpr::visit (AST::ContinueExpr &expr) { HIR::Lifetime break_label = lower_lifetime (expr.get_label ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -623,9 +623,9 @@ ASTLoweringExpr::visit (AST::BorrowExpr &expr) HIR::Expr *borrow_lvalue = ASTLoweringExpr::translate (expr.get_borrowed_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); auto *borrow_expr @@ -636,9 +636,9 @@ ASTLoweringExpr::visit (AST::BorrowExpr &expr) if (expr.get_is_double_borrow ()) { - NodeId artificial_double_borrow_id = mappings->get_next_node_id (); + NodeId artificial_double_borrow_id = mappings.get_next_node_id (); Analysis::NodeMapping mapping (crate_num, artificial_double_borrow_id, - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); borrow_expr @@ -658,9 +658,9 @@ ASTLoweringExpr::visit (AST::DereferenceExpr &expr) HIR::Expr *dref_lvalue = ASTLoweringExpr::translate (expr.get_dereferenced_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -675,9 +675,9 @@ ASTLoweringExpr::visit (AST::ErrorPropagationExpr &expr) HIR::Expr *propagating_expr = ASTLoweringExpr::translate (expr.get_propagating_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::ErrorPropagationExpr ( mapping, std::unique_ptr<HIR::Expr> (propagating_expr), @@ -693,9 +693,9 @@ ASTLoweringExpr::visit (AST::MatchExpr &expr) void ASTLoweringExpr::visit (AST::RangeFromToExpr &expr) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::Expr *range_from = ASTLoweringExpr::translate (expr.get_from_expr ()); @@ -711,9 +711,9 @@ ASTLoweringExpr::visit (AST::RangeFromToExpr &expr) void ASTLoweringExpr::visit (AST::RangeFromExpr &expr) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::Expr *range_from = ASTLoweringExpr::translate (expr.get_from_expr ()); @@ -726,9 +726,9 @@ ASTLoweringExpr::visit (AST::RangeFromExpr &expr) void ASTLoweringExpr::visit (AST::RangeToExpr &expr) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::Expr *range_to = ASTLoweringExpr::translate (expr.get_to_expr ()); @@ -741,9 +741,9 @@ ASTLoweringExpr::visit (AST::RangeToExpr &expr) void ASTLoweringExpr::visit (AST::RangeFullExpr &expr) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::RangeFullExpr (mapping, expr.get_locus ()); @@ -752,9 +752,9 @@ ASTLoweringExpr::visit (AST::RangeFullExpr &expr) void ASTLoweringExpr::visit (AST::RangeFromToInclExpr &expr) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::Expr *range_from = ASTLoweringExpr::translate (expr.get_from_expr ()); @@ -780,10 +780,10 @@ ASTLoweringExpr::visit (AST::ClosureExprInner &expr) closure_params.push_back (std::move (p)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::ClosureExpr (mapping, std::move (closure_params), @@ -807,10 +807,10 @@ ASTLoweringExpr::visit (AST::ClosureExprInnerTyped &expr) closure_params.push_back (std::move (p)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::ClosureExpr (mapping, std::move (closure_params), diff --git a/gcc/rust/hir/rust-ast-lower-extern.h b/gcc/rust/hir/rust-ast-lower-extern.h index 6af5940..0105e38 100644 --- a/gcc/rust/hir/rust-ast-lower-extern.h +++ b/gcc/rust/hir/rust-ast-lower-extern.h @@ -39,9 +39,9 @@ public: item->accept_vis (resolver); rust_assert (resolver.translated != nullptr); - resolver.mappings->insert_hir_extern_item (resolver.translated, - parent_hirid); - resolver.mappings->insert_location ( + resolver.mappings.insert_hir_extern_item (resolver.translated, + parent_hirid); + resolver.mappings.insert_location ( resolver.translated->get_mappings ().get_hirid (), resolver.translated->get_locus ()); @@ -53,10 +53,10 @@ public: HIR::Visibility vis = translate_visibility (item.get_visibility ()); HIR::Type *static_type = ASTLoweringType::translate (item.get_type ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, item.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::ExternalStaticItem ( mapping, item.get_identifier (), std::unique_ptr<HIR::Type> (static_type), @@ -103,10 +103,10 @@ public: HIR::Type *param_type = ASTLoweringType::translate (param.get_type ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id ( + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id ( crate_num)); function_params.push_back ( @@ -114,10 +114,10 @@ public: std::unique_ptr<HIR::Type> (param_type))); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, function.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::ExternalFunctionItem ( mapping, function.get_function_name (), std::move (generic_params), @@ -128,10 +128,10 @@ public: void visit (AST::ExternalTypeItem &type) override { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::Visibility vis = translate_visibility (type.get_visibility ()); diff --git a/gcc/rust/hir/rust-ast-lower-implitem.cc b/gcc/rust/hir/rust-ast-lower-implitem.cc index 90ebff2..5380d25 100644 --- a/gcc/rust/hir/rust-ast-lower-implitem.cc +++ b/gcc/rust/hir/rust-ast-lower-implitem.cc @@ -42,10 +42,10 @@ ASTLowerImplItem::translate (AST::AssociatedItem &item, HirId parent_impl_id) auto locus = resolver.translated->get_locus (); resolver.handle_outer_attributes (*resolver.item_cast); - resolver.mappings->insert_hir_implitem (parent_impl_id, - resolver.translated); - resolver.mappings->insert_location (id, locus); - resolver.mappings->insert_defid_mapping (defid, resolver.item_cast); + resolver.mappings.insert_hir_implitem (parent_impl_id, + resolver.translated); + resolver.mappings.insert_location (id, locus); + resolver.mappings.insert_defid_mapping (defid, resolver.item_cast); } return resolver.translated; @@ -65,10 +65,10 @@ ASTLowerImplItem::visit (AST::TypeAlias &alias) HIR::Type *existing_type = ASTLoweringType::translate (alias.get_type_aliased ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, alias.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); auto type_alias = new HIR::TypeAlias (mapping, alias.get_new_type_name (), @@ -89,10 +89,10 @@ ASTLowerImplItem::visit (AST::ConstantItem &constant) HIR::Type *type = ASTLoweringType::translate (constant.get_type (), true); HIR::Expr *expr = ASTLoweringExpr::translate (constant.get_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, constant.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); auto translated_constant = new HIR::ConstantItem (mapping, constant.get_identifier (), vis, @@ -152,9 +152,9 @@ ASTLowerImplItem::visit (AST::Function &function) auto translated_type = std::unique_ptr<HIR::Type> ( ASTLoweringType::translate (param.get_type ())); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); auto hir_param @@ -169,13 +169,13 @@ ASTLowerImplItem::visit (AST::Function &function) ASTLoweringBlock::translate (*function.get_definition ().value (), &terminated)); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, function.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); - mappings->insert_location (function_body->get_mappings ().get_hirid (), - function.get_locus ()); + mappings.insert_location (function_body->get_mappings ().get_hirid (), + function.get_locus ()); auto fn = new HIR::Function (mapping, std::move (function_name), @@ -188,8 +188,8 @@ ASTLowerImplItem::visit (AST::Function &function) if (!fn->get_self_param ().is_error ()) { // insert mappings for self - mappings->insert_hir_self_param (&fn->get_self_param ()); - mappings->insert_location ( + mappings.insert_hir_self_param (&fn->get_self_param ()); + mappings.insert_location ( fn->get_self_param ().get_mappings ().get_hirid (), fn->get_self_param ().get_locus ()); } @@ -197,8 +197,8 @@ ASTLowerImplItem::visit (AST::Function &function) // add the mappings for the function params at the end for (auto ¶m : fn->get_function_params ()) { - mappings->insert_hir_param (¶m); - mappings->insert_location (mapping.get_hirid (), param.get_locus ()); + mappings.insert_hir_param (¶m); + mappings.insert_location (mapping.get_hirid (), param.get_locus ()); } translated = fn; @@ -218,9 +218,9 @@ ASTLowerTraitItem::translate (AST::AssociatedItem &item) auto locus = resolver.translated->get_trait_locus (); resolver.handle_outer_attributes (*resolver.translated); - resolver.mappings->insert_hir_trait_item (resolver.translated); - resolver.mappings->insert_location (id, locus); - resolver.mappings->insert_defid_mapping (defid, resolver.translated); + resolver.mappings.insert_hir_trait_item (resolver.translated); + resolver.mappings.insert_location (id, locus); + resolver.mappings.insert_defid_mapping (defid, resolver.translated); } return resolver.translated; @@ -262,9 +262,9 @@ ASTLowerTraitItem::visit (AST::Function &func) auto translated_type = std::unique_ptr<HIR::Type> ( ASTLoweringType::translate (param.get_type ())); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); auto hir_param @@ -287,10 +287,10 @@ ASTLowerTraitItem::visit (AST::Function &func) &terminated)) : nullptr; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, func.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); auto *trait_item = new HIR::TraitItemFunc (mapping, std::move (decl), std::move (block_expr), @@ -299,16 +299,16 @@ ASTLowerTraitItem::visit (AST::Function &func) if (func.has_self_param ()) { // insert mappings for self - mappings->insert_hir_self_param (&self_param); - mappings->insert_location (self_param.get_mappings ().get_hirid (), - self_param.get_locus ()); + mappings.insert_hir_self_param (&self_param); + mappings.insert_location (self_param.get_mappings ().get_hirid (), + self_param.get_locus ()); } // add the mappings for the function params at the end for (auto ¶m : trait_item->get_decl ().get_function_params ()) { - mappings->insert_hir_param (¶m); - mappings->insert_location (mapping.get_hirid (), param.get_locus ()); + mappings.insert_hir_param (¶m); + mappings.insert_location (mapping.get_hirid (), param.get_locus ()); } } @@ -320,10 +320,10 @@ ASTLowerTraitItem::visit (AST::TraitItemConst &constant) ? ASTLoweringExpr::translate (constant.get_expr ()) : nullptr; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, constant.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::TraitItemConst *trait_item = new HIR::TraitItemConst (mapping, constant.get_identifier (), @@ -338,10 +338,10 @@ void ASTLowerTraitItem::visit (AST::TraitItemType &type) { std::vector<std::unique_ptr<HIR::TypeParamBound> > type_param_bounds; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::TraitItemType *trait_item = new HIR::TraitItemType (mapping, type.get_identifier (), diff --git a/gcc/rust/hir/rust-ast-lower-item.cc b/gcc/rust/hir/rust-ast-lower-item.cc index 89a4895..25345ce 100644 --- a/gcc/rust/hir/rust-ast-lower-item.cc +++ b/gcc/rust/hir/rust-ast-lower-item.cc @@ -44,10 +44,10 @@ ASTLoweringItem::translate (AST::Item &item) auto locus = resolver.translated->get_locus (); resolver.handle_outer_attributes (*resolver.translated); - resolver.mappings->insert_ast_item (&item); - resolver.mappings->insert_hir_item (resolver.translated); - resolver.mappings->insert_location (id, locus); - resolver.mappings->insert_defid_mapping (defid, resolver.translated); + resolver.mappings.insert_ast_item (&item); + resolver.mappings.insert_hir_item (resolver.translated); + resolver.mappings.insert_location (id, locus); + resolver.mappings.insert_defid_mapping (defid, resolver.translated); } return resolver.translated; @@ -56,10 +56,10 @@ ASTLoweringItem::translate (AST::Item &item) void ASTLoweringItem::visit (AST::Module &module) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, module.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); // should be lowered from module.get_vis() HIR::Visibility vis = translate_visibility (module.get_visibility ()); @@ -83,7 +83,7 @@ ASTLoweringItem::visit (AST::Module &module) = new HIR::Module (mapping, module.get_name (), module.get_locus (), std::move (items), std::move (vis), std::move (inner_attrs), std::move (outer_attrs)); - mappings->insert_module (static_cast<Module *> (translated)); + mappings.insert_module (static_cast<Module *> (translated)); } void @@ -107,10 +107,10 @@ ASTLoweringItem::visit (AST::TypeAlias &alias) HIR::Type *existing_type = ASTLoweringType::translate (alias.get_type_aliased ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, alias.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::TypeAlias (mapping, alias.get_new_type_name (), @@ -150,11 +150,10 @@ ASTLoweringItem::visit (AST::TupleStruct &struct_decl) HIR::Visibility vis = translate_visibility (field.get_visibility ()); HIR::Type *type = ASTLoweringType::translate (field.get_field_type ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, field.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id ( - crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::TupleField translated_field (mapping, std::unique_ptr<HIR::Type> (type), vis, @@ -163,10 +162,10 @@ ASTLoweringItem::visit (AST::TupleStruct &struct_decl) fields.push_back (std::move (translated_field)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, struct_decl.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::TupleStruct (mapping, std::move (fields), struct_decl.get_identifier (), @@ -207,11 +206,10 @@ ASTLoweringItem::visit (AST::StructStruct &struct_decl) HIR::Visibility vis = translate_visibility (field.get_visibility ()); HIR::Type *type = ASTLoweringType::translate (field.get_field_type ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, field.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id ( - crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::StructField translated_field (mapping, field.get_field_name (), std::unique_ptr<HIR::Type> (type), vis, @@ -224,10 +222,10 @@ ASTLoweringItem::visit (AST::StructStruct &struct_decl) fields.push_back (std::move (translated_field)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, struct_decl.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::StructStruct (mapping, std::move (fields), struct_decl.get_identifier (), @@ -268,10 +266,10 @@ ASTLoweringItem::visit (AST::Enum &enum_decl) items.push_back (std::unique_ptr<HIR::EnumItem> (hir_item)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, enum_decl.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::Enum *hir_enum = new HIR::Enum (mapping, enum_decl.get_identifier (), vis, @@ -281,7 +279,7 @@ ASTLoweringItem::visit (AST::Enum &enum_decl) translated = hir_enum; for (auto &variant : hir_enum->get_variants ()) { - mappings->insert_hir_enumitem (hir_enum, variant.get ()); + mappings.insert_hir_enumitem (hir_enum, variant.get ()); } } @@ -314,11 +312,10 @@ ASTLoweringItem::visit (AST::Union &union_decl) HIR::Visibility vis = translate_visibility (variant.get_visibility ()); HIR::Type *type = ASTLoweringType::translate (variant.get_field_type ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, variant.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id ( - crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::StructField translated_variant (mapping, variant.get_field_name (), std::unique_ptr<HIR::Type> (type), @@ -331,10 +328,10 @@ ASTLoweringItem::visit (AST::Union &union_decl) variants.push_back (std::move (translated_variant)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, union_decl.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::Union (mapping, union_decl.get_identifier (), vis, @@ -351,10 +348,10 @@ ASTLoweringItem::visit (AST::StaticItem &var) HIR::Type *type = ASTLoweringType::translate (var.get_type (), true); HIR::Expr *expr = ASTLoweringExpr::translate (var.get_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, var.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::StaticItem (mapping, var.get_identifier (), var.is_mutable () ? Mutability::Mut @@ -372,10 +369,10 @@ ASTLoweringItem::visit (AST::ConstantItem &constant) HIR::Type *type = ASTLoweringType::translate (constant.get_type (), true); HIR::Expr *expr = ASTLoweringExpr::translate (constant.get_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, constant.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::ConstantItem (mapping, constant.get_identifier (), vis, std::unique_ptr<HIR::Type> (type), @@ -429,9 +426,9 @@ ASTLoweringItem::visit (AST::Function &function) auto translated_type = std::unique_ptr<HIR::Type> ( ASTLoweringType::translate (param.get_type ())); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); auto hir_param @@ -446,13 +443,13 @@ ASTLoweringItem::visit (AST::Function &function) ASTLoweringBlock::translate (*function.get_definition ().value (), &terminated)); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, function.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); - mappings->insert_location (function_body->get_mappings ().get_hirid (), - function.get_locus ()); + mappings.insert_location (function_body->get_mappings ().get_hirid (), + function.get_locus ()); auto fn = new HIR::Function (mapping, std::move (function_name), @@ -465,8 +462,8 @@ ASTLoweringItem::visit (AST::Function &function) // add the mappings for the function params at the end for (auto ¶m : fn->get_function_params ()) { - mappings->insert_hir_param (¶m); - mappings->insert_location (mapping.get_hirid (), param.get_locus ()); + mappings.insert_hir_param (¶m); + mappings.insert_location (mapping.get_hirid (), param.get_locus ()); } translated = fn; @@ -521,10 +518,10 @@ ASTLoweringItem::visit (AST::InherentImpl &impl_block) HIR::Type *impl_type = ASTLoweringType::translate (impl_block.get_type ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, impl_block.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); std::vector<std::unique_ptr<HIR::ImplItem>> impl_items; std::vector<HirId> impl_item_ids; @@ -548,10 +545,10 @@ ASTLoweringItem::visit (AST::InherentImpl &impl_block) impl_block.get_locus ()); translated = hir_impl_block; - mappings->insert_hir_impl_block (hir_impl_block); + mappings.insert_hir_impl_block (hir_impl_block); for (auto &impl_item_id : impl_item_ids) { - mappings->insert_impl_item_mapping (impl_item_id, hir_impl_block); + mappings.insert_impl_item_mapping (impl_item_id, hir_impl_block); } } @@ -598,10 +595,10 @@ ASTLoweringItem::visit (AST::Trait &trait) trait_item_ids.push_back (lowered->get_mappings ().get_hirid ()); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, trait.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); auto trait_unsafety = Unsafety::Normal; if (trait.is_unsafe ()) @@ -618,7 +615,7 @@ ASTLoweringItem::visit (AST::Trait &trait) for (auto trait_item_id : trait_item_ids) { - mappings->insert_trait_item_mapping (trait_item_id, hir_trait); + mappings.insert_trait_item_mapping (trait_item_id, hir_trait); } } @@ -672,10 +669,10 @@ ASTLoweringItem::visit (AST::TraitImpl &impl_block) HIR::TypePath *trait_ref = ASTLowerTypePath::translate (impl_block.get_trait_path ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, impl_block.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); std::vector<std::unique_ptr<HIR::ImplItem>> impl_items; std::vector<HirId> impl_item_ids; @@ -702,10 +699,10 @@ ASTLoweringItem::visit (AST::TraitImpl &impl_block) impl_block.get_locus ()); translated = hir_impl_block; - mappings->insert_hir_impl_block (hir_impl_block); + mappings.insert_hir_impl_block (hir_impl_block); for (auto &impl_item_id : impl_item_ids) { - mappings->insert_impl_item_mapping (impl_item_id, hir_impl_block); + mappings.insert_impl_item_mapping (impl_item_id, hir_impl_block); } } @@ -732,17 +729,17 @@ ASTLoweringSimplePath::translate (const AST::SimplePath &path) HIR::SimplePathSegment ASTLoweringSimplePath::lower (const AST::SimplePathSegment &segment) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); auto node_id = segment.get_node_id (); auto mapping = Analysis::NodeMapping (crate_num, node_id, - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); auto hir_seg = HIR::SimplePathSegment (mapping); - mappings->insert_node_to_hir (node_id, mapping.get_hirid ()); - // mappings->insert_simple_path_segment (crate_num, node_id, &segment); + mappings.insert_node_to_hir (node_id, mapping.get_hirid ()); + // mappings.insert_simple_path_segment (crate_num, node_id, &segment); return hir_seg; } @@ -754,18 +751,18 @@ ASTLoweringSimplePath::lower (const AST::SimplePath &path) for (auto &segment : path.get_segments ()) segments.emplace_back (lower (segment)); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); auto node_id = path.get_node_id (); auto mapping = Analysis::NodeMapping (crate_num, node_id, - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); auto lowered = HIR::SimplePath (std::move (segments), mapping, path.get_locus ()); - mappings->insert_node_to_hir (node_id, mapping.get_hirid ()); - // mappings->insert_simple_path (crate_num, node_id, &path); + mappings.insert_node_to_hir (node_id, mapping.get_hirid ()); + // mappings.insert_simple_path (crate_num, node_id, &path); return lowered; } diff --git a/gcc/rust/hir/rust-ast-lower-pattern.cc b/gcc/rust/hir/rust-ast-lower-pattern.cc index 95af0f8..b64cf3a 100644 --- a/gcc/rust/hir/rust-ast-lower-pattern.cc +++ b/gcc/rust/hir/rust-ast-lower-pattern.cc @@ -33,8 +33,8 @@ ASTLoweringPattern::translate (AST::Pattern &pattern, bool is_let_top_level) rust_assert (resolver.translated != nullptr); - resolver.mappings->insert_hir_pattern (resolver.translated); - resolver.mappings->insert_location ( + resolver.mappings.insert_hir_pattern (resolver.translated); + resolver.mappings.insert_location ( resolver.translated->get_mappings ().get_hirid (), pattern.get_locus ()); return resolver.translated; @@ -43,9 +43,9 @@ ASTLoweringPattern::translate (AST::Pattern &pattern, bool is_let_top_level) void ASTLoweringPattern::visit (AST::IdentifierPattern &pattern) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); std::unique_ptr<Pattern> to_bind; @@ -95,9 +95,9 @@ ASTLoweringPattern::visit (AST::TupleStructPattern &pattern) break; } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::TupleStructPattern ( @@ -123,10 +123,9 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern) auto &tuple = static_cast<AST::StructPatternFieldTuplePat &> (*field); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, tuple.get_node_id (), - mappings->get_next_hir_id ( - crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); std::unique_ptr<HIR::Pattern> pat ( @@ -144,10 +143,9 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern) AST::StructPatternFieldIdentPat &ident = static_cast<AST::StructPatternFieldIdentPat &> (*field); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, ident.get_node_id (), - mappings->get_next_hir_id ( - crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); std::unique_ptr<HIR::Pattern> pat ( @@ -165,10 +163,9 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern) AST::StructPatternFieldIdent &ident = static_cast<AST::StructPatternFieldIdent &> (*field.get ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, ident.get_node_id (), - mappings->get_next_hir_id ( - crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); f = new HIR::StructPatternFieldIdent ( @@ -182,16 +179,16 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern) // insert the reverse mappings and locations auto field_id = f->get_mappings ().get_hirid (); auto field_node_id = f->get_mappings ().get_nodeid (); - mappings->insert_location (field_id, f->get_locus ()); - mappings->insert_node_to_hir (field_node_id, field_id); + mappings.insert_location (field_id, f->get_locus ()); + mappings.insert_node_to_hir (field_node_id, field_id); // add it to the lowered fields list fields.push_back (std::unique_ptr<HIR::StructPatternField> (f)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::StructPatternElements elems (std::move (fields)); @@ -201,9 +198,9 @@ ASTLoweringPattern::visit (AST::StructPattern &pattern) void ASTLoweringPattern::visit (AST::WildcardPattern &pattern) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::WildcardPattern (mapping, pattern.get_locus ()); @@ -231,9 +228,9 @@ ASTLoweringPattern::visit (AST::TuplePattern &pattern) break; } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -243,9 +240,9 @@ ASTLoweringPattern::visit (AST::TuplePattern &pattern) void ASTLoweringPattern::visit (AST::LiteralPattern &pattern) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::Literal l = lower_literal (pattern.get_literal ()); @@ -259,9 +256,9 @@ ASTLoweringPattern::visit (AST::RangePattern &pattern) auto upper_bound = lower_range_pattern_bound (pattern.get_upper_bound ()); auto lower_bound = lower_range_pattern_bound (pattern.get_lower_bound ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -279,9 +276,9 @@ ASTLoweringPattern::visit (AST::GroupedPattern &pattern) void ASTLoweringPattern::visit (AST::ReferencePattern &pattern) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::Pattern *inner @@ -296,7 +293,7 @@ ASTLoweringPattern::visit (AST::ReferencePattern &pattern) if (pattern.is_double_reference ()) { Analysis::NodeMapping mapping2 (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::ReferencePattern (mapping2, @@ -315,9 +312,9 @@ ASTLoweringPattern::visit (AST::SlicePattern &pattern) items.push_back (std::unique_ptr<HIR::Pattern> (item)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -327,9 +324,9 @@ ASTLoweringPattern::visit (AST::SlicePattern &pattern) void ASTLoweringPattern::visit (AST::AltPattern &pattern) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, pattern.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); std::vector<std::unique_ptr<HIR::Pattern>> alts; diff --git a/gcc/rust/hir/rust-ast-lower-stmt.cc b/gcc/rust/hir/rust-ast-lower-stmt.cc index 8ec498f..c359459 100644 --- a/gcc/rust/hir/rust-ast-lower-stmt.cc +++ b/gcc/rust/hir/rust-ast-lower-stmt.cc @@ -35,10 +35,10 @@ ASTLoweringStmt::translate (AST::Stmt *stmt, bool *terminated) return nullptr; *terminated = resolver.terminated; - resolver.mappings->insert_location ( + resolver.mappings.insert_location ( resolver.translated->get_mappings ().get_hirid (), resolver.translated->get_locus ()); - resolver.mappings->insert_hir_stmt (resolver.translated); + resolver.mappings.insert_hir_stmt (resolver.translated); return resolver.translated; } @@ -48,9 +48,9 @@ ASTLoweringStmt::visit (AST::ExprStmt &stmt) { HIR::Expr *expr = ASTLoweringExpr::translate (stmt.get_expr (), &terminated); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::ExprStmt (mapping, std::unique_ptr<HIR::Expr> (expr), @@ -75,9 +75,9 @@ ASTLoweringStmt::visit (AST::LetStmt &stmt) = stmt.has_init_expr () ? ASTLoweringExpr::translate (stmt.get_init_expr ()) : nullptr; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, stmt.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::LetStmt (mapping, std::unique_ptr<HIR::Pattern> (variables), @@ -113,10 +113,10 @@ ASTLoweringStmt::visit (AST::Enum &enum_decl) void ASTLoweringStmt::visit (AST::EmptyStmt &empty) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, empty.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::EmptyStmt (mapping, empty.get_locus ()); } diff --git a/gcc/rust/hir/rust-ast-lower-struct-field-expr.h b/gcc/rust/hir/rust-ast-lower-struct-field-expr.h index d0ee699..b5f4909 100644 --- a/gcc/rust/hir/rust-ast-lower-struct-field-expr.h +++ b/gcc/rust/hir/rust-ast-lower-struct-field-expr.h @@ -36,8 +36,8 @@ public: field.accept_vis (compiler); rust_assert (compiler.translated != nullptr); - compiler.mappings->insert_hir_struct_field (compiler.translated); - compiler.mappings->insert_location ( + compiler.mappings.insert_hir_struct_field (compiler.translated); + compiler.mappings.insert_location ( compiler.translated->get_mappings ().get_hirid (), field.get_locus ()); return compiler.translated; diff --git a/gcc/rust/hir/rust-ast-lower-type.cc b/gcc/rust/hir/rust-ast-lower-type.cc index b5997c2..f7cb863 100644 --- a/gcc/rust/hir/rust-ast-lower-type.cc +++ b/gcc/rust/hir/rust-ast-lower-type.cc @@ -33,8 +33,8 @@ ASTLowerTypePath::translate (AST::TypePath &type) void ASTLowerTypePath::visit (AST::TypePathSegmentFunction &segment) { - auto crate_num = mappings->get_current_crate (); - auto hirid = mappings->get_next_hir_id (crate_num); + auto crate_num = mappings.get_current_crate (); + auto hirid = mappings.get_next_hir_id (crate_num); Analysis::NodeMapping mapping (crate_num, segment.get_node_id (), hirid, UNKNOWN_LOCAL_DEFID); @@ -64,8 +64,8 @@ ASTLowerTypePath::visit (AST::TypePathSegmentFunction &segment) void ASTLowerTypePath::visit (AST::TypePathSegment &segment) { - auto crate_num = mappings->get_current_crate (); - auto hirid = mappings->get_next_hir_id (crate_num); + auto crate_num = mappings.get_current_crate (); + auto hirid = mappings.get_next_hir_id (crate_num); Analysis::NodeMapping mapping (crate_num, segment.get_node_id (), hirid, UNKNOWN_LOCAL_DEFID); @@ -87,8 +87,8 @@ ASTLowerTypePath::visit (AST::TypePathSegmentGeneric &segment) auto generic_args = lower_generic_args (segment.get_generic_args ()); - auto crate_num = mappings->get_current_crate (); - auto hirid = mappings->get_next_hir_id (crate_num); + auto crate_num = mappings.get_current_crate (); + auto hirid = mappings.get_next_hir_id (crate_num); Analysis::NodeMapping mapping (crate_num, segment.get_node_id (), hirid, UNKNOWN_LOCAL_DEFID); @@ -113,10 +113,10 @@ ASTLowerTypePath::visit (AST::TypePath &path) std::unique_ptr<HIR::TypePathSegment> (translated_segment)); } - auto crate_num = mappings->get_current_crate (); - auto hirid = mappings->get_next_hir_id (crate_num); + auto crate_num = mappings.get_current_crate (); + auto hirid = mappings.get_next_hir_id (crate_num); Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid, - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_localdef_id (crate_num)); translated = new HIR::TypePath (std::move (mapping), std::move (translated_segments), @@ -136,8 +136,8 @@ ASTLowerQualifiedPathInType::translate (AST::QualifiedPathInType &type) void ASTLowerQualifiedPathInType::visit (AST::QualifiedPathInType &path) { - auto crate_num = mappings->get_current_crate (); - auto hirid = mappings->get_next_hir_id (crate_num); + auto crate_num = mappings.get_current_crate (); + auto hirid = mappings.get_next_hir_id (crate_num); Analysis::NodeMapping qual_mappings ( crate_num, path.get_qualified_path_type ().get_node_id (), hirid, UNKNOWN_LOCAL_DEFID); @@ -170,7 +170,7 @@ ASTLowerQualifiedPathInType::visit (AST::QualifiedPathInType &path) } Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid, - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_localdef_id (crate_num)); translated = new HIR::QualifiedPathInType (std::move (mapping), std::move (qual_path_type), std::move (associated_segment), @@ -185,8 +185,8 @@ ASTLoweringType::translate (AST::Type &type, bool default_to_static_lifetime) type.accept_vis (resolver); rust_assert (resolver.translated != nullptr); - resolver.mappings->insert_hir_type (resolver.translated); - resolver.mappings->insert_location ( + resolver.mappings.insert_hir_type (resolver.translated); + resolver.mappings.insert_location ( resolver.translated->get_mappings ().get_hirid (), resolver.translated->get_locus ()); @@ -244,10 +244,10 @@ ASTLoweringType::visit (AST::BareFunctionType &fntype) default_to_static_lifetime); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, fntype.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::BareFunctionType ( std::move (mapping), std::move (lifetime_params), std::move (qualifiers), @@ -266,10 +266,10 @@ ASTLoweringType::visit (AST::TupleType &tuple) elems.push_back (std::unique_ptr<HIR::Type> (t)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, tuple.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::TupleType (std::move (mapping), std::move (elems), tuple.get_locus ()); @@ -295,10 +295,10 @@ ASTLoweringType::visit (AST::ArrayType &type) default_to_static_lifetime); HIR::Expr *array_size = ASTLoweringExpr::translate (type.get_size_expr ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::ArrayType (mapping, std::unique_ptr<HIR::Type> (translated_type), @@ -316,10 +316,10 @@ ASTLoweringType::visit (AST::ReferenceType &type) = ASTLoweringType::translate (type.get_base_type (), default_to_static_lifetime); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::ReferenceType (mapping, type.get_has_mut () ? Mutability::Mut @@ -335,10 +335,10 @@ ASTLoweringType::visit (AST::RawPointerType &type) = ASTLoweringType::translate (type.get_type_pointed_to (), default_to_static_lifetime); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::RawPointerType (mapping, @@ -357,10 +357,10 @@ ASTLoweringType::visit (AST::SliceType &type) = ASTLoweringType::translate (type.get_elem_type (), default_to_static_lifetime); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::SliceType (mapping, std::unique_ptr<HIR::Type> (base_type), @@ -370,10 +370,10 @@ ASTLoweringType::visit (AST::SliceType &type) void ASTLoweringType::visit (AST::InferredType &type) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::InferredType (mapping, type.get_locus ()); } @@ -381,10 +381,10 @@ ASTLoweringType::visit (AST::InferredType &type) void ASTLoweringType::visit (AST::NeverType &type) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::NeverType (mapping, type.get_locus ()); } @@ -397,10 +397,10 @@ ASTLoweringType::visit (AST::TraitObjectTypeOneBound &type) = ASTLoweringTypeBounds::translate (type.get_trait_bound ()); bounds.push_back (std::unique_ptr<HIR::TypeParamBound> (translated_bound)); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::TraitObjectType (mapping, std::move (bounds), type.get_locus (), type.is_dyn ()); @@ -419,10 +419,10 @@ ASTLoweringType::visit (AST::TraitObjectType &type) std::unique_ptr<HIR::TypeParamBound> (translated_bound)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, type.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::TraitObjectType (mapping, std::move (bounds), type.get_locus (), type.is_dyn ()); @@ -435,9 +435,9 @@ ASTLowerGenericParam::translate (AST::GenericParam ¶m) param.accept_vis (resolver); rust_assert (resolver.translated != nullptr); - resolver.mappings->insert_location ( + resolver.mappings.insert_location ( resolver.translated->get_mappings ().get_hirid (), param.get_locus ()); - resolver.mappings->insert_hir_generic_param (resolver.translated); + resolver.mappings.insert_hir_generic_param (resolver.translated); return resolver.translated; } @@ -445,10 +445,10 @@ ASTLowerGenericParam::translate (AST::GenericParam ¶m) void ASTLowerGenericParam::visit (AST::LifetimeParam ¶m) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); HIR::Lifetime lt (mapping, param.get_lifetime ().get_lifetime_type (), param.get_lifetime ().get_lifetime_name (), @@ -461,10 +461,10 @@ ASTLowerGenericParam::visit (AST::LifetimeParam ¶m) void ASTLowerGenericParam::visit (AST::ConstGenericParam ¶m) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); auto type = ASTLoweringType::translate (param.get_type ()); @@ -498,10 +498,10 @@ ASTLowerGenericParam::visit (AST::TypeParam ¶m) ? ASTLoweringType::translate (param.get_type ()) : nullptr; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, param.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); + mappings.get_next_hir_id (crate_num), + mappings.get_next_localdef_id (crate_num)); translated = new HIR::TypeParam (mapping, param.get_type_representation (), @@ -516,7 +516,7 @@ ASTLoweringTypeBounds::translate (AST::TypeParamBound &type) type.accept_vis (resolver); rust_assert (resolver.translated != nullptr); - resolver.mappings->insert_location ( + resolver.mappings.insert_location ( resolver.translated->get_mappings ().get_hirid (), resolver.translated->get_locus ()); @@ -537,9 +537,9 @@ ASTLoweringTypeBounds::visit (AST::TraitBound &bound) AST::TypePath &ast_trait_path = bound.get_type_path (); HIR::TypePath *trait_path = ASTLowerTypePath::translate (ast_trait_path); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, bound.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); BoundPolarity polarity = bound.has_opening_question_mark () @@ -565,7 +565,7 @@ ASTLowerWhereClauseItem::translate (AST::WhereClauseItem &item) rust_assert (compiler.translated != nullptr); // FIXME - // compiler.mappings->insert_location ( + // compiler.mappings.insert_location ( // compiler.translated->get_mappings ().get_hirid (), // compiler.translated->get_locus ()); @@ -583,9 +583,9 @@ ASTLowerWhereClauseItem::visit (AST::LifetimeWhereClauseItem &item) lifetime_bounds.push_back (std::move (ll)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, item.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::LifetimeWhereClauseItem (mapping, std::move (l), @@ -616,9 +616,9 @@ ASTLowerWhereClauseItem::visit (AST::TypeBoundWhereClauseItem &item) type_param_bounds.push_back (std::unique_ptr<HIR::TypeParamBound> (b)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, item.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index c8f1247..5a5c93f 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -81,10 +81,10 @@ ASTLowering::go () items.push_back (std::unique_ptr<HIR::Item> (translated)); } - auto mappings = Analysis::Mappings::get (); - auto crate_num = mappings->get_current_crate (); + auto &mappings = Analysis::Mappings::get (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, astCrate.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); return std::unique_ptr<HIR::Crate> ( @@ -137,9 +137,9 @@ ASTLoweringBlock::visit (AST::BlockExpr &expr) } bool tail_reachable = !block_did_terminate; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::BlockExpr (mapping, std::move (block_stmts), @@ -160,9 +160,9 @@ ASTLoweringIfBlock::visit (AST::IfExpr &expr) HIR::BlockExpr *block = ASTLoweringBlock::translate (expr.get_if_block (), &ignored_terminated); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::IfExpr (mapping, std::unique_ptr<HIR::Expr> (condition), @@ -187,9 +187,9 @@ ASTLoweringIfBlock::visit (AST::IfExprConseqElse &expr) terminated = if_block_terminated && else_block_termianted; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::IfExprConseqElse ( @@ -213,9 +213,9 @@ ASTLoweringIfLetBlock::visit (AST::IfLetExpr &expr) HIR::BlockExpr *block = ASTLoweringBlock::translate (expr.get_if_block (), &ignored_terminated); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::IfLetExpr (mapping, std::move (patterns), @@ -245,9 +245,9 @@ ASTLoweringIfLetBlock::visit (AST::IfLetExprConseqElse &expr) rust_assert (else_block); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::IfLetExprConseqElse ( @@ -263,9 +263,9 @@ ASTLowerStructExprField::visit (AST::StructExprFieldIdentifierValue &field) { HIR::Expr *value = ASTLoweringExpr::translate (field.get_value ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, field.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::StructExprFieldIdentifierValue ( @@ -278,9 +278,9 @@ ASTLowerStructExprField::visit (AST::StructExprFieldIndexValue &field) { HIR::Expr *value = ASTLoweringExpr::translate (field.get_value ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, field.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -292,9 +292,9 @@ ASTLowerStructExprField::visit (AST::StructExprFieldIndexValue &field) void ASTLowerStructExprField::visit (AST::StructExprFieldIdentifier &field) { - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, field.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -314,9 +314,9 @@ ASTLoweringExprWithBlock::visit (AST::WhileLoopExpr &expr) HIR::Expr *loop_condition = ASTLoweringExpr::translate (expr.get_predicate_expr (), &terminated); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -380,9 +380,9 @@ ASTLoweringExprWithBlock::visit (AST::MatchExpr &expr) std::unique_ptr<HIR::Expr> (kase_guard_expr), match_case.get_arm ().get_outer_attrs ()); - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); HIR::MatchCase kase (std::move (mapping), std::move (arm), @@ -390,9 +390,9 @@ ASTLoweringExprWithBlock::visit (AST::MatchExpr &expr) match_arms.push_back (std::move (kase)); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated @@ -414,11 +414,11 @@ ASTLowerPathInExpression::visit (AST::PathInExpression &expr) // insert the mappings for the segment HIR::PathExprSegment *lowered_seg = &path_segments.back (); - mappings->insert_hir_path_expr_seg (lowered_seg); + mappings.insert_hir_path_expr_seg (lowered_seg); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::PathInExpression (mapping, std::move (path_segments), @@ -435,9 +435,9 @@ ASTLoweringBase::lower_qual_path_type (AST::QualifiedPathType &qualified_type) ? ASTLowerTypePath::translate (qualified_type.get_as_type_path ()) : nullptr; - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, qualified_type.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); return HIR::QualifiedPathType (mapping, std::unique_ptr<HIR::Type> (type), @@ -459,12 +459,12 @@ ASTLowerQualPathInExpression::visit (AST::QualifiedPathInExpression &expr) // insert the mappings for the segment HIR::PathExprSegment *lowered_seg = &path_segments.back (); - mappings->insert_hir_path_expr_seg (lowered_seg); + mappings.insert_hir_path_expr_seg (lowered_seg); } - auto crate_num = mappings->get_current_crate (); + auto crate_num = mappings.get_current_crate (); Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - mappings->get_next_hir_id (crate_num), + mappings.get_next_hir_id (crate_num), UNKNOWN_LOCAL_DEFID); translated = new HIR::QualifiedPathInExpression (mapping, qual_path_type, |