Gyoji Compiler
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Gyoji::frontend::namespaces::NS2Context Class Reference

#include <ns2.hpp>

Collaboration diagram for Gyoji::frontend::namespaces::NS2Context:
Collaboration graph
[legend]

Public Member Functions

void namespace_using (std::string name, NS2Entity *alias)
 
NS2Entitynamespace_find_in (NS2Entity *current, std::string _name) const
 
void namespace_push (NS2Entity *ns)
 

Detailed Description

This is the context used for namespace resolution. It consists of a 'stack' structure which is updated as the parse progresses. It contains the names available in the namespace as well as the search path that is currently active in the namespace through 'using' statements which operate to update our search path.

Member Function Documentation

◆ namespace_find_in()

NS2Entity * NS2Context::namespace_find_in ( NS2Entity current,
std::string  _name 
) const

Add a new namespace to the current namespace. The name here may be a composite name with foo::bar::baz representing 3 new namespaces to add nested.

This can return an error if the name conflicts with an entity defined in a namespace already.

Returns the leaf-node namespace added. Resolve the name in the current namespace resolution context.

◆ namespace_push()

void NS2Context::namespace_push ( NS2Entity ns)

Pushes our namespace resolution context using the given namespace.

◆ namespace_using()

void NS2Context::namespace_using ( std::string  name,
NS2Entity alias 
)

When we define a 'using', we're really just defining an alias to another namespace. This 'using' will be added in the current namespace's search path. The 'using' will only be relevant in this (and child) contexts, so when a namespace is left, all of the 'using' namespaces that were active inside that namespace will be no longer used even if we re-enter that namespace, the search paths will be forgotten.


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