diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-resolve-path.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.h | 60 |
1 files changed, 23 insertions, 37 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.h b/gcc/rust/backend/rust-compile-resolve-path.h index 7654fd9..79bfb86 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.h +++ b/gcc/rust/backend/rust-compile-resolve-path.h @@ -20,53 +20,39 @@ #define RUST_COMPILE_RESOLVE_PATH #include "rust-compile-base.h" -#include "rust-hir-visitor.h" namespace Rust { namespace Compile { -class ResolvePathRef : public HIRCompileBase, public HIR::HIRPatternVisitor +class ResolvePathRef : public HIRCompileBase { public: - static tree Compile (HIR::QualifiedPathInExpression &expr, Context *ctx) - { - ResolvePathRef resolver (ctx); - expr.accept_vis (resolver); - return resolver.resolved; - } - - static tree Compile (HIR::PathInExpression &expr, Context *ctx) - { - ResolvePathRef resolver (ctx); - expr.accept_vis (resolver); - return resolver.resolved; - } - - void visit (HIR::PathInExpression &expr) override; - void visit (HIR::QualifiedPathInExpression &expr) override; - - // Empty visit for unused Pattern HIR nodes. - void visit (HIR::IdentifierPattern &) override {} - void visit (HIR::LiteralPattern &) override {} - void visit (HIR::RangePattern &) override {} - void visit (HIR::ReferencePattern &) override {} - void visit (HIR::SlicePattern &) override {} - void visit (HIR::AltPattern &) override {} - void visit (HIR::StructPattern &) override {} - void visit (HIR::TuplePattern &) override {} - void visit (HIR::TupleStructPattern &) override {} - void visit (HIR::WildcardPattern &) override {} - - ResolvePathRef (Context *ctx) - : HIRCompileBase (ctx), resolved (error_mark_node) - {} - + static tree Compile (HIR::QualifiedPathInExpression &expr, Context *ctx); + + static tree Compile (HIR::PathInExpression &expr, Context *ctx); + + ResolvePathRef (Context *ctx); + + /** + * Generic visitor for both PathInExpression and QualifiedPathInExpression + */ + template <typename T> tree resolve_path_like (T &expr); + + /** + * Inner implementation of `resolve` - resolution with an already known NodeId + */ + tree resolve_with_node_id (const HIR::PathIdentSegment &final_segment, + const Analysis::NodeMapping &mappings, + location_t locus, bool is_qualified_path, + NodeId resolved_node_id); + /** + * Resolve a mappings' NodeId and call into `resolve_with_node_id` which + * performs the rest of the path resolution + */ tree resolve (const HIR::PathIdentSegment &final_segment, const Analysis::NodeMapping &mappings, location_t locus, bool is_qualified_path); - tree resolved; - private: tree attempt_constructor_expression_lookup (TyTy::BaseType *lookup, Context *ctx, |