aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-name-resolution-context.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/resolve/rust-name-resolution-context.h')
-rw-r--r--gcc/rust/resolve/rust-name-resolution-context.h41
1 files changed, 36 insertions, 5 deletions
diff --git a/gcc/rust/resolve/rust-name-resolution-context.h b/gcc/rust/resolve/rust-name-resolution-context.h
index ea81bde..84c0800 100644
--- a/gcc/rust/resolve/rust-name-resolution-context.h
+++ b/gcc/rust/resolve/rust-name-resolution-context.h
@@ -221,6 +221,7 @@ public:
template <typename S>
tl::optional<Rib::Definition> resolve_path (const std::vector<S> &segments,
+ bool has_opening_scope_resolution,
Namespace ns)
{
std::function<void (const S &, NodeId)> insert_segment_resolution
@@ -232,13 +233,17 @@ public:
switch (ns)
{
case Namespace::Values:
- return values.resolve_path (segments, insert_segment_resolution);
+ return values.resolve_path (segments, has_opening_scope_resolution,
+ insert_segment_resolution);
case Namespace::Types:
- return types.resolve_path (segments, insert_segment_resolution);
+ return types.resolve_path (segments, has_opening_scope_resolution,
+ insert_segment_resolution);
case Namespace::Macros:
- return macros.resolve_path (segments, insert_segment_resolution);
+ return macros.resolve_path (segments, has_opening_scope_resolution,
+ insert_segment_resolution);
case Namespace::Labels:
- return labels.resolve_path (segments, insert_segment_resolution);
+ return labels.resolve_path (segments, has_opening_scope_resolution,
+ insert_segment_resolution);
default:
rust_unreachable ();
}
@@ -246,19 +251,45 @@ public:
template <typename S, typename... Args>
tl::optional<Rib::Definition> resolve_path (const std::vector<S> &segments,
+ bool has_opening_scope_resolution,
Args... ns_args)
{
std::initializer_list<Namespace> namespaces = {ns_args...};
for (auto ns : namespaces)
{
- if (auto ret = resolve_path (segments, ns))
+ if (auto ret
+ = resolve_path (segments, has_opening_scope_resolution, ns))
return ret;
}
return tl::nullopt;
}
+ template <typename... Args>
+ tl::optional<Rib::Definition> resolve_path (const AST::SimplePath &path,
+ Args... ns_args)
+ {
+ return resolve_path (path.get_segments (),
+ path.has_opening_scope_resolution (), ns_args...);
+ }
+
+ template <typename... Args>
+ tl::optional<Rib::Definition> resolve_path (const AST::PathInExpression &path,
+ Args... ns_args)
+ {
+ return resolve_path (path.get_segments (), path.opening_scope_resolution (),
+ ns_args...);
+ }
+
+ template <typename... Args>
+ tl::optional<Rib::Definition> resolve_path (const AST::TypePath &path,
+ Args... ns_args)
+ {
+ return resolve_path (path.get_segments (),
+ path.has_opening_scope_resolution_op (), ns_args...);
+ }
+
private:
/* Map of "usage" nodes which have been resolved to a "definition" node */
std::map<Usage, Definition> resolved_nodes;