diff options
Diffstat (limited to 'gcc/rust/hir/rust-ast-lower-implitem.cc')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-implitem.cc | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-implitem.cc b/gcc/rust/hir/rust-ast-lower-implitem.cc index 77230e7..399c3fb 100644 --- a/gcc/rust/hir/rust-ast-lower-implitem.cc +++ b/gcc/rust/hir/rust-ast-lower-implitem.cc @@ -314,165 +314,6 @@ ASTLowerTraitItem::visit (AST::Function &func) } void -ASTLowerTraitItem::visit (AST::TraitItemFunc &func) -{ - AST::TraitFunctionDecl &ref = func.get_trait_function_decl (); - std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items; - HIR::WhereClause where_clause (std::move (where_clause_items)); - HIR::FunctionQualifiers qualifiers - = lower_qualifiers (func.get_trait_function_decl ().get_qualifiers ()); - - std::vector<std::unique_ptr<HIR::GenericParam> > generic_params; - if (ref.has_generics ()) - { - generic_params = lower_generic_params (ref.get_generic_params ()); - } - - std::unique_ptr<HIR::Type> return_type - = ref.has_return_type () ? std::unique_ptr<HIR::Type> ( - ASTLoweringType::translate (ref.get_return_type ().get ())) - : nullptr; - - std::vector<HIR::FunctionParam> function_params; - for (auto &p : ref.get_function_params ()) - { - if (p->is_variadic () || p->is_self ()) - continue; - - auto param = static_cast<AST::FunctionParam *> (p.get ()); - - auto translated_pattern = std::unique_ptr<HIR::Pattern> ( - ASTLoweringPattern::translate (param->get_pattern ().get ())); - auto translated_type = std::unique_ptr<HIR::Type> ( - ASTLoweringType::translate (param->get_type ().get ())); - - auto crate_num = mappings->get_current_crate (); - Analysis::NodeMapping mapping (crate_num, param->get_node_id (), - mappings->get_next_hir_id (crate_num), - UNKNOWN_LOCAL_DEFID); - - auto hir_param - = HIR::FunctionParam (mapping, std::move (translated_pattern), - std::move (translated_type), param->get_locus ()); - function_params.push_back (std::move (hir_param)); - } - - HIR::TraitFunctionDecl decl (ref.get_identifier (), std::move (qualifiers), - std::move (generic_params), - HIR::SelfParam::error (), - std::move (function_params), - std::move (return_type), - std::move (where_clause)); - bool terminated = false; - std::unique_ptr<HIR::BlockExpr> block_expr - = func.has_definition () ? std::unique_ptr<HIR::BlockExpr> ( - ASTLoweringBlock::translate (func.get_definition ().get (), - &terminated)) - : nullptr; - - 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)); - - HIR::TraitItemFunc *trait_item - = new HIR::TraitItemFunc (mapping, std::move (decl), std::move (block_expr), - func.get_outer_attrs (), func.get_locus ()); - translated = trait_item; - - // 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 ()); - } -} - -void -ASTLowerTraitItem::visit (AST::TraitItemMethod &method) -{ - AST::TraitMethodDecl &ref = method.get_trait_method_decl (); - - std::vector<std::unique_ptr<HIR::WhereClauseItem> > where_clause_items; - HIR::WhereClause where_clause (std::move (where_clause_items)); - HIR::FunctionQualifiers qualifiers - = lower_qualifiers (method.get_trait_method_decl ().get_qualifiers ()); - - std::vector<std::unique_ptr<HIR::GenericParam> > generic_params; - if (ref.has_generics ()) - { - generic_params = lower_generic_params (ref.get_generic_params ()); - } - - std::unique_ptr<HIR::Type> return_type - = ref.has_return_type () ? std::unique_ptr<HIR::Type> ( - ASTLoweringType::translate (ref.get_return_type ().get ())) - : nullptr; - - HIR::SelfParam self_param = lower_self (ref.get_self_param ()); - - std::vector<HIR::FunctionParam> function_params; - for (auto &p : ref.get_function_params ()) - { - if (p->is_variadic () || p->is_self ()) - continue; - - auto param = static_cast<AST::FunctionParam *> (p.get ()); - - auto translated_pattern = std::unique_ptr<HIR::Pattern> ( - ASTLoweringPattern::translate (param->get_pattern ().get ())); - auto translated_type = std::unique_ptr<HIR::Type> ( - ASTLoweringType::translate (param->get_type ().get ())); - - auto crate_num = mappings->get_current_crate (); - Analysis::NodeMapping mapping (crate_num, param->get_node_id (), - mappings->get_next_hir_id (crate_num), - UNKNOWN_LOCAL_DEFID); - - auto hir_param - = HIR::FunctionParam (mapping, std::move (translated_pattern), - std::move (translated_type), param->get_locus ()); - function_params.push_back (hir_param); - } - - HIR::TraitFunctionDecl decl (ref.get_identifier (), std::move (qualifiers), - std::move (generic_params), - std::move (self_param), - std::move (function_params), - std::move (return_type), - std::move (where_clause)); - - bool terminated = false; - std::unique_ptr<HIR::BlockExpr> block_expr - = method.has_definition () ? std::unique_ptr<HIR::BlockExpr> ( - ASTLoweringBlock::translate (method.get_definition ().get (), - &terminated)) - : nullptr; - - auto crate_num = mappings->get_current_crate (); - Analysis::NodeMapping mapping (crate_num, method.get_node_id (), - mappings->get_next_hir_id (crate_num), - mappings->get_next_localdef_id (crate_num)); - - HIR::TraitItemFunc *trait_item - = new HIR::TraitItemFunc (mapping, std::move (decl), std::move (block_expr), - method.get_outer_attrs (), method.get_locus ()); - translated = trait_item; - - // insert mappings for self - 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 ()); - } -} - -void ASTLowerTraitItem::visit (AST::TraitItemConst &constant) { HIR::Type *type = ASTLoweringType::translate (constant.get_type ().get ()); |