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

@ -64,15 +64,17 @@ static bool elna_langhook_init(void)
static void elna_parse_file(const char *filename)
{
std::ifstream file{ filename, std::ios::in };
if (!file)
{
fatal_error(UNKNOWN_LOCATION, "cannot open filename %s: %m", filename);
}
elna::boot::dependency_graph outcome = elna::boot::read_sources(file, filename);
std::shared_ptr<elna::boot::symbol_table> info_table = elna::boot::builtin_symbol_table();
auto x = std::make_shared<elna::boot::symbol_table>(info_table);
elna::boot::dependency dependency = elna::boot::read_sources("source/Common.elna", x);
linemap_add(line_table, LC_ENTER, 0, "source/Common.elna", 1);
if (dependency.has_errors())
{
elna::gcc::report_errors(dependency.errors());
}
auto y = std::make_shared<elna::boot::symbol_table>(info_table);
elna::boot::dependency outcome = elna::boot::read_sources(filename, y, x);
std::shared_ptr<elna::gcc::symbol_table> symbol_table = elna::gcc::builtin_symbol_table();
linemap_add(line_table, LC_ENTER, 0, filename, 1);
@ -82,34 +84,11 @@ static void elna_parse_file(const char *filename)
}
else
{
for (const std::unique_ptr<elna::boot::program>& module_tree : outcome.modules)
{
elna::boot::declaration_visitor declaration_visitor(filename);
declaration_visitor.visit(module_tree.get());
elna::gcc::rewrite_symbol_table(x, symbol_table);
elna::gcc::rewrite_symbol_table(y, symbol_table);
if (declaration_visitor.errors().empty())
{
elna::boot::name_analysis_visitor name_analysis_visitor(filename, info_table,
std::move(declaration_visitor.unresolved));
name_analysis_visitor.visit(module_tree.get());
if (name_analysis_visitor.errors().empty())
{
elna::gcc::rewrite_symbol_table(info_table, symbol_table);
elna::gcc::generic_visitor generic_visitor{ symbol_table, info_table };
generic_visitor.visit(module_tree.get());
}
else
{
elna::gcc::report_errors(name_analysis_visitor.errors());
}
}
else
{
elna::gcc::report_errors(declaration_visitor.errors());
}
}
elna::gcc::generic_visitor generic_visitor{ symbol_table, outcome.bag };
outcome.tree->accept(&generic_visitor);
}
linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
}