aboutsummaryrefslogtreecommitdiff
path: root/boot/dependency.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-28 02:39:42 +0200
committerEugen Wissner <belka@caraus.de>2026-08-28 02:39:42 +0200
commit8e655a0786aec5e0215e09f2a9629c6f32e34793 (patch)
tree0788634cf66fed9c1a1d264b5b8c30da49380559 /boot/dependency.cc
parent4d4537866690a1ef3d882f5e9a6e01d8220a3650 (diff)
downloadelna-8e655a0786aec5e0215e09f2a9629c6f32e34793.tar.gz
Reject declarations shadowing imports
Diffstat (limited to 'boot/dependency.cc')
-rw-r--r--boot/dependency.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/boot/dependency.cc b/boot/dependency.cc
index 7f87e40..7e103aa 100644
--- a/boot/dependency.cc
+++ b/boot/dependency.cc
@@ -37,36 +37,36 @@ namespace elna::boot
return "Circular import of module '" + this->module_name + "'";
}
- dependency read_source(std::istream& entry_point, const target_info& target)
+ read_result read_source(std::istream& entry_point, const target_info& target)
{
driver parse_driver;
lexer tokenizer(entry_point);
yy::parser parser(tokenizer, parse_driver);
- dependency outcome;
if (parser() != 0)
{
- std::swap(outcome.errors, parse_driver.errors());
- return outcome;
- }
- else
- {
- std::swap(outcome.value, parse_driver.tree);
+ diagnostic_list errors;
+ std::swap(errors, parse_driver.errors());
+ return read_result{ std::in_place_type<diagnostic_list>, std::move(errors) };
}
+ std::unique_ptr<unit> tree;
+ std::swap(tree, parse_driver.tree);
materialization_visitor materialization_visitor(target);
- outcome.value->accept(&materialization_visitor);
+ tree->accept(&materialization_visitor);
if (materialization_visitor.has_errors())
{
- std::swap(outcome.errors, materialization_visitor.errors());
- outcome.value.reset();
+ diagnostic_list errors;
+ std::swap(errors, materialization_visitor.errors());
+ return read_result{ std::in_place_type<diagnostic_list>, std::move(errors) };
}
- return outcome;
+ return read_result{ std::in_place_type<std::unique_ptr<unit>>, std::move(tree) };
}
analysis_result analyze_semantics(std::unique_ptr<unit>& tree,
const std::vector<std::shared_ptr<symbol_table>>& imports,
- const std::shared_ptr<symbol_table>& globals, const target_info& target)
+ const std::shared_ptr<symbol_table>& globals, const target_info& target,
+ const std::filesystem::path& module_path)
{
declaration_visitor declarations{};
tree->accept(&declarations);
@@ -81,7 +81,7 @@ namespace elna::boot
{
result.value.add_import(import);
}
- name_analysis_visitor name_analyser(result.value, target);
+ name_analysis_visitor name_analyser(result.value, target, module_path);
tree->accept(&name_analyser);
if (name_analyser.has_errors())