Joos1W Compiler Framework
All Classes Functions Typedefs Pages
semantic::NameResolver::Pkg Struct Reference

Represents a tree of packages. The leaf nodes are declarations. More...

#include <NameResolver.h>

Public Member Functions

 Pkg (BumpAllocator &alloc)
 
 Pkg (BumpAllocator &alloc, std::string_view name)
 
ConstImportOpt lookup (std::string_view name, BumpAllocator &alloc) const
 Gets a child package by name. If the child is not found, then nullptr is returned. More...
 
std::ostream & print (std::ostream &os, int indentation=0) const
 
void dump () const
 

Friends

class NameResolver
 

Detailed Description

Represents a tree of packages. The leaf nodes are declarations.

Definition at line 36 of file NameResolver.h.

Member Function Documentation

◆ lookup()

ConstImportOpt semantic::NameResolver::Pkg::lookup ( std::string_view  name,
BumpAllocator &  alloc 
) const
inline

Gets a child package by name. If the child is not found, then nullptr is returned.

Parameters
nameThe name of the child package to get.
allocThe allocator to use for the string.
Returns
Pkg const* The child package if found, otherwise nullptr.

Definition at line 55 of file NameResolver.h.

55  {
56  auto it = children.find(std::pmr::string{name, alloc});
57  if(it == children.end()) return std::nullopt;
58  if(auto* pkg = std::get_if<Pkg*>(&it->second)) return *pkg;
59  return std::get<ast::Decl*>(it->second);
60  }

The documentation for this struct was generated from the following files: