Gyoji Compiler
|
#include <ns2.hpp>
Public Member Functions | |
void | namespace_using (std::string name, NS2Entity *alias) |
NS2Entity * | namespace_find_in (NS2Entity *current, std::string _name) const |
void | namespace_push (NS2Entity *ns) |
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.
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.
void NS2Context::namespace_push | ( | NS2Entity * | ns | ) |
Pushes our namespace resolution context using the given namespace.
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.