diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-27 11:23:17 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-27 11:23:17 +0200 |
| commit | c57a24b9fe37e233e7ec0e2e65405738d9c09c6e (patch) | |
| tree | 99b5f4dc22d27d8159c3ba76f2cf3a455ed37fb6 /boot/validation.cc | |
| parent | d048b633dd02014f8bff1b512ce4d5ae2b8b7903 (diff) | |
| download | elna-c57a24b9fe37e233e7ec0e2e65405738d9c09c6e.tar.gz | |
Reuse container visiting logic
Diffstat (limited to 'boot/validation.cc')
| -rw-r--r-- | boot/validation.cc | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/boot/validation.cc b/boot/validation.cc index 0c9259e..4539633 100644 --- a/boot/validation.cc +++ b/boot/validation.cc @@ -41,34 +41,27 @@ namespace elna::boot { } - void validation_visitor::visit_statements(const std::vector<statement *>& statements) + void validation_visitor::visit_statements(const std::vector<statement *>& statements, + const std::shared_ptr<symbol_table>& scope) { - for (statement *const body_statement : statements) - { - body_statement->accept(this); - } + this->bag.enter(scope); + visit_all(this, statements); + this->bag.leave(); } void validation_visitor::visit_block(const block& body) { - this->bag.enter(body.symbols); - visit_statements(body.statements); - this->bag.leave(); + visit_statements(body.statements, body.symbols); } void validation_visitor::visit(unit *unit) { - for (declaration *unit_declaration : unit->declarations) - { - unit_declaration->accept(this); - } + visit_all(this, unit->declarations); if (unit->entry_point.has_value()) { const std::shared_ptr<procedure_info> entry_point = this->bag.lookup("")->is_procedure(); - this->bag.enter(entry_point->scope); - visit_statements(unit->entry_point.value()); - this->bag.leave(); + visit_statements(unit->entry_point.value(), entry_point->scope); } } @@ -87,9 +80,7 @@ namespace elna::boot const std::shared_ptr<procedure_info> procedure = this->bag.lookup(declaration->identifier.name())->is_procedure(); - this->bag.enter(procedure->scope); - visit_statements(declaration->body.value().statements); - this->bag.leave(); + visit_statements(declaration->body.value().statements, procedure->scope); } } |
