diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-06-27 17:48:55 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-06-27 17:48:55 +0100 |
commit | da2dda70637ecd42a9ba3fba976a5f280e880852 (patch) | |
tree | 81eb97e6254ec27917d6a5d2181fec1ec0d50c85 /gcc/rust | |
parent | 31e63dd6c2b4753d035496b9145e34b7b7d168c0 (diff) | |
download | gcc-da2dda70637ecd42a9ba3fba976a5f280e880852.zip gcc-da2dda70637ecd42a9ba3fba976a5f280e880852.tar.gz gcc-da2dda70637ecd42a9ba3fba976a5f280e880852.tar.bz2 |
refactor away from helper utility methods and just use the constructor directly
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-implitem.h | 22 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-item.cc | 22 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-stmt.h | 6 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-toplevel.h | 6 | ||||
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve-type.h | 70 |
5 files changed, 38 insertions, 88 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index c0cb3a7..192ecaf 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -66,7 +66,8 @@ public: void visit (AST::ConstantItem &constant) override { - auto decl = ResolveConstantItemToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); resolver->get_name_scope ().insert ( @@ -80,7 +81,8 @@ public: void visit (AST::Function &function) override { - auto decl = ResolveFunctionItemToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ()); auto path = prefix.append (decl); resolver->get_name_scope ().insert ( @@ -94,7 +96,8 @@ public: void visit (AST::Method &method) override { - auto decl = ResolveMethodItemToCanonicalPath::resolve (method); + auto decl = CanonicalPath::new_seg (method.get_node_id (), + method.get_method_name ()); auto path = prefix.append (decl); resolver->get_name_scope ().insert ( @@ -130,7 +133,9 @@ public: void visit (AST::TraitItemFunc &function) override { - auto decl = ResolveTraitItemFunctionToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg ( + function.get_node_id (), + function.get_trait_function_decl ().get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -148,7 +153,8 @@ public: void visit (AST::TraitItemMethod &method) override { - auto decl = ResolveTraitItemMethodToCanonicalPath::resolve (method); + auto decl = CanonicalPath::new_seg ( + method.get_node_id (), method.get_trait_method_decl ().get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -166,7 +172,8 @@ public: void visit (AST::TraitItemConst &constant) override { - auto decl = ResolveTraitItemConstToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -184,7 +191,8 @@ public: void visit (AST::TraitItemType &type) override { - auto decl = ResolveTraitItemTypeToCanonicalPath::resolve (type); + auto decl + = CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index 7b0c31b..0c9536f 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -42,7 +42,8 @@ ResolveTraitItems::go (AST::TraitItem *item, const CanonicalPath &prefix, void ResolveTraitItems::visit (AST::TraitItemType &type) { - auto decl = ResolveTraitItemTypeToCanonicalPath::resolve (type); + auto decl + = CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -55,7 +56,8 @@ ResolveTraitItems::visit (AST::TraitItemType &type) void ResolveTraitItems::visit (AST::TraitItemFunc &func) { - auto decl = ResolveTraitItemFunctionToCanonicalPath::resolve (func); + auto decl = CanonicalPath::new_seg ( + func.get_node_id (), func.get_trait_function_decl ().get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -102,7 +104,9 @@ ResolveTraitItems::visit (AST::TraitItemFunc &func) void ResolveTraitItems::visit (AST::TraitItemMethod &func) { - auto decl = ResolveTraitItemMethodToCanonicalPath::resolve (func); + auto decl + = CanonicalPath::new_seg (func.get_node_id (), + func.get_trait_method_decl ().get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -166,7 +170,8 @@ ResolveTraitItems::visit (AST::TraitItemMethod &func) void ResolveTraitItems::visit (AST::TraitItemConst &constant) { - auto decl = ResolveTraitItemConstToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -486,7 +491,8 @@ ResolveItem::visit (AST::StaticItem &var) void ResolveItem::visit (AST::ConstantItem &constant) { - auto decl = ResolveConstantItemToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -501,7 +507,8 @@ ResolveItem::visit (AST::ConstantItem &constant) void ResolveItem::visit (AST::Function &function) { - auto decl = ResolveFunctionItemToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -638,7 +645,8 @@ ResolveItem::visit (AST::InherentImpl &impl_block) void ResolveItem::visit (AST::Method &method) { - auto decl = ResolveMethodItemToCanonicalPath::resolve (method); + auto decl + = CanonicalPath::new_seg (method.get_node_id (), method.get_method_name ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h index 95c25a5..1d2ecd3 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.h +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h @@ -56,7 +56,8 @@ public: void visit (AST::ConstantItem &constant) override { - auto decl = ResolveConstantItemToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = decl; // this ensures we have the correct relative resolution auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), @@ -330,7 +331,8 @@ public: void visit (AST::Function &function) override { - auto decl = ResolveFunctionItemToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ()); auto path = decl; // this ensures we have the correct relative resolution auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (mappings->get_current_crate (), diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index c495786..aed8565 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -283,7 +283,8 @@ public: void visit (AST::ConstantItem &constant) override { - auto decl = ResolveConstantItemToCanonicalPath::resolve (constant); + auto decl = CanonicalPath::new_seg (constant.get_node_id (), + constant.get_identifier ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); @@ -303,7 +304,8 @@ public: void visit (AST::Function &function) override { - auto decl = ResolveFunctionItemToCanonicalPath::resolve (function); + auto decl = CanonicalPath::new_seg (function.get_node_id (), + function.get_function_name ()); auto path = prefix.append (decl); auto cpath = canonical_prefix.append (decl); diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h index aab6a1a..b8ad6d1 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.h +++ b/gcc/rust/resolve/rust-ast-resolve-type.h @@ -25,76 +25,6 @@ namespace Rust { namespace Resolver { -class ResolveConstantItemToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::ConstantItem &constant) - { - return CanonicalPath::new_seg (constant.get_node_id (), - constant.get_identifier ()); - } -}; - -class ResolveFunctionItemToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::Function &function) - { - return CanonicalPath::new_seg (function.get_node_id (), - function.get_function_name ()); - } -}; - -class ResolveMethodItemToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::Method &method) - { - return CanonicalPath::new_seg (method.get_node_id (), - method.get_method_name ()); - } -}; - -class ResolveTraitItemFunctionToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::TraitItemFunc &function) - { - return CanonicalPath::new_seg ( - function.get_node_id (), - function.get_trait_function_decl ().get_identifier ()); - } -}; - -class ResolveTraitItemMethodToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::TraitItemMethod &method) - { - return CanonicalPath::new_seg ( - method.get_node_id (), method.get_trait_method_decl ().get_identifier ()); - } -}; - -class ResolveTraitItemConstToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::TraitItemConst &constant) - { - return CanonicalPath::new_seg (constant.get_node_id (), - constant.get_identifier ()); - } -}; - -class ResolveTraitItemTypeToCanonicalPath -{ -public: - static CanonicalPath resolve (AST::TraitItemType &type) - { - return CanonicalPath::new_seg (type.get_node_id (), type.get_identifier ()); - } -}; - class ResolveTypeToCanonicalPath : public ResolverBase { protected: |