Support one hardcoded import

This commit is contained in:
2025-07-10 00:43:17 +02:00
parent 181b19eefe
commit f02b2c49e5
14 changed files with 210 additions and 111 deletions

View File

@ -313,13 +313,9 @@ namespace elna::boot
}
procedure_info::procedure_info(const procedure_type symbol, const std::vector<std::string> names,
std::shared_ptr<symbol_table> parent_table)
: symbol(symbol), names(names)
std::shared_ptr<symbol_table> scope)
: symbol(symbol), names(names), symbols(scope)
{
if (parent_table != nullptr)
{
this->symbols = std::make_shared<symbol_table>(parent_table);
}
}
std::shared_ptr<procedure_info> procedure_info::is_procedure()
@ -361,4 +357,51 @@ namespace elna::boot
return result;
}
symbol_bag::symbol_bag()
{
this->symbols = std::make_shared<symbol_table>();
this->imports = std::make_shared<symbol_table>();
}
symbol_bag::symbol_bag(forward_table&& unresolved, std::shared_ptr<symbol_table> symbols)
: symbols(symbols), unresolved(unresolved)
{
this->imports = std::make_shared<symbol_table>();
}
std::shared_ptr<info> symbol_bag::lookup(const std::string& name)
{
if (auto result = this->imports->lookup(name))
{
return result;
}
return this->symbols->lookup(name);
}
bool symbol_bag::enter(const std::string& name, std::shared_ptr<info> entry)
{
return this->symbols->enter(name, entry);
}
std::shared_ptr<symbol_table> symbol_bag::enter()
{
this->symbols = std::make_shared<symbol_table>(this->symbols);
return this->symbols;
}
void symbol_bag::enter(std::shared_ptr<symbol_table> child)
{
this->symbols = child;
}
void symbol_bag::leave()
{
this->symbols = this->symbols->scope();
}
void symbol_bag::add_import(std::shared_ptr<symbol_table> table)
{
this->imports = table;
}
}