1 #include "ast/context.h"
4 using namespace tanlang;
6 ASTBase *Context::owner()
const {
return _owner; }
8 Context::Context(
ASTBase *owner) : _owner(owner) {}
10 void Context::set_decl(
const str &name,
Decl *decl) {
11 TAN_ASSERT(!name.empty());
12 _type_decls[name] = decl;
16 TAN_ASSERT(name !=
"");
17 auto q = _type_decls.find(name);
18 if (q != _type_decls.end()) {
25 vector<Decl *> ret(_type_decls.size(),
nullptr);
27 for (
const auto &p : _type_decls)
33 TAN_ASSERT(name !=
"");
34 auto q = _func_decls.find(name);
35 if (q != _func_decls.end()) {
42 str name = func->get_name();
43 TAN_ASSERT(!name.empty());
44 _func_decls[name] = func;
48 vector<FunctionDecl *> ret(_func_decls.size(),
nullptr);
50 for (
const auto &p : _func_decls)
vector< Decl * > get_decls() const
Get all type declarations in the context.
Decl * get_decl(const str &name) const
Search for a declaration by name.
void set_function_decl(FunctionDecl *func)
Register a function declaration.
vector< FunctionDecl * > get_func_decls() const
Get all functions registered in the context.
FunctionDecl * get_func_decl(const str &name) const
Search for a function declaration by name.