diff options
Diffstat (limited to 'boot/ast.cc')
| -rw-r--r-- | boot/ast.cc | 45 |
1 files changed, 11 insertions, 34 deletions
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<field_declaration>&& 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<procedure_body>(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<import_declaration *>&& imports, - std::vector<type_declaration *>&& types, - std::vector<variable_declaration *>&& variables, - std::vector<procedure_declaration *>&& procedures) + std::vector<declaration *>&& 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<import_declaration *>&& imports, - std::vector<type_declaration *>&& types, - std::vector<variable_declaration *>&& variables, - std::vector<procedure_declaration *>&& procedures, + std::vector<declaration *>&& declarations, std::vector<identifier>&& parameters, const source_position entry_position, std::optional<procedure_body>&& 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) { |
