aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-early-name-resolver-2.0.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/resolve/rust-early-name-resolver-2.0.h')
-rw-r--r--gcc/rust/resolve/rust-early-name-resolver-2.0.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.h b/gcc/rust/resolve/rust-early-name-resolver-2.0.h
index a7ad0f7..e78bec0 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.h
@@ -34,6 +34,7 @@ class Early : public DefaultResolver
{
using DefaultResolver::visit;
+ TopLevel toplevel;
bool dirty;
public:
@@ -59,6 +60,7 @@ public:
void visit (AST::Function &) override;
void visit (AST::StructStruct &) override;
+ void visit (AST::UseDeclaration &) override;
struct ImportData
{
@@ -216,7 +218,6 @@ private:
std::vector<std::pair<Rib::Definition, Namespace>>
resolve_path_in_all_ns (const P &path)
{
- const auto &segments = path.get_segments ();
std::vector<std::pair<Rib::Definition, Namespace>> resolved;
// Pair a definition with the namespace it was found in
@@ -227,9 +228,21 @@ private:
};
};
- ctx.values.resolve_path (segments).map (pair_with_ns (Namespace::Values));
- ctx.types.resolve_path (segments).map (pair_with_ns (Namespace::Types));
- ctx.macros.resolve_path (segments).map (pair_with_ns (Namespace::Macros));
+ std::vector<Error> value_errors;
+ std::vector<Error> type_errors;
+ std::vector<Error> macro_errors;
+
+ ctx.resolve_path (path, value_errors, Namespace::Values)
+ .map (pair_with_ns (Namespace::Values));
+ ctx.resolve_path (path, type_errors, Namespace::Types)
+ .map (pair_with_ns (Namespace::Types));
+ ctx.resolve_path (path, macro_errors, Namespace::Macros)
+ .map (pair_with_ns (Namespace::Macros));
+
+ if (!value_errors.empty () && !type_errors.empty ()
+ && !macro_errors.empty ())
+ for (auto &ent : value_errors)
+ collect_error (std::move (ent));
return resolved;
}
@@ -243,6 +256,13 @@ private:
std::vector<Error> macro_resolve_errors;
void collect_error (Error e) { macro_resolve_errors.push_back (e); }
+
+ void finalize_simple_import (const Early::ImportPair &mapping);
+
+ void finalize_glob_import (NameResolutionContext &ctx,
+ const Early::ImportPair &mapping);
+
+ void finalize_rebind_import (const Early::ImportPair &mapping);
};
} // namespace Resolver2_0