From a5d033df465ca8de8457926cc64aacf38c6ae848 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 13 Sep 2026 16:07:11 +0200 Subject: Visit nested statements in validation visitor --- boot/ast.cc | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) (limited to 'boot/ast.cc') diff --git a/boot/ast.cc b/boot/ast.cc index 08d3a78..04e9230 100644 --- a/boot/ast.cc +++ b/boot/ast.cc @@ -354,17 +354,9 @@ namespace elna::boot { _import->accept(this); } - for (type_declaration *type : unit->types) + for (declaration *const unit_declaration : unit->declarations) { - type->accept(this); - } - for (variable_declaration *variable : unit->variables) - { - variable->accept(this); - } - for (procedure_declaration *procedure : unit->procedures) - { - procedure->accept(this); + unit_declaration->accept(this); } if (unit->entry_point.has_value()) { @@ -991,11 +983,6 @@ namespace elna::boot return *m_variable_type; } - declaration::declaration(const source_position position, identifier_definition identifier) - : node(position), identifier(std::move(identifier)) - { - } - procedure_type_expression::procedure_type_expression(const source_position position, std::vector&& parameters, return_t return_type) : node(position), return_type(return_type), parameters(std::move(parameters)) @@ -1035,14 +1022,14 @@ namespace elna::boot procedure_declaration::procedure_declaration(const source_position position, identifier_definition identifier, procedure_type_expression *heading, procedure_body&& body) - : declaration(position, std::move(identifier)), m_heading(heading), + : node(position), m_heading(heading), identifier(std::move(identifier)), body(std::make_optional(std::move(body))) { } procedure_declaration::procedure_declaration(const source_position position, identifier_definition identifier, procedure_type_expression *heading) - : declaration(position, std::move(identifier)), m_heading(heading) + : node(position), m_heading(heading), identifier(std::move(identifier)) { } @@ -1063,7 +1050,7 @@ namespace elna::boot type_declaration::type_declaration(const source_position position, identifier_definition identifier, type_expression *underlying_type) - : declaration(position, std::move(identifier)), m_underlying_type(underlying_type) + : node(position), m_underlying_type(underlying_type), identifier(std::move(identifier)) { } @@ -1126,26 +1113,20 @@ namespace elna::boot unit::unit(const source_position position, std::vector&& imports, - std::vector&& types, - std::vector&& variables, - std::vector&& procedures) + std::vector&& declarations) : node(position), - imports(std::move(imports)), types(std::move(types)), procedures(std::move(procedures)), - variables(std::move(variables)) + imports(std::move(imports)), declarations(std::move(declarations)) { } unit::unit(const source_position position, std::vector&& imports, - std::vector&& types, - std::vector&& variables, - std::vector&& procedures, + std::vector&& declarations, std::vector&& parameters, const source_position entry_position, std::optional&& body) : node(position), - imports(std::move(imports)), types(std::move(types)), procedures(std::move(procedures)), - variables(std::move(variables)), entry_point(std::move(body)), + imports(std::move(imports)), declarations(std::move(declarations)), entry_point(std::move(body)), parameters(std::move(parameters)), entry_position(entry_position) { } @@ -1157,13 +1138,9 @@ namespace elna::boot unit::~unit() { - for (const procedure_declaration *procedure : this->procedures) - { - delete procedure; - } - for (const type_declaration *type : this->types) + for (const declaration *unit_declaration : this->declarations) { - delete type; + delete unit_declaration; } for (const import_declaration *declaration : this->imports) { -- cgit v1.2.3