diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-07-12 13:23:54 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-07-12 13:23:54 +0200 |
| commit | 768537d6e4b82a19e77b7e44234309ecaf4d65d2 (patch) | |
| tree | ab22613a16c3a914b16d00a5f988f51d1eadac0d /boot | |
| parent | 14d4977e2ab2409bb7344395ca01d19e49f130f1 (diff) | |
| download | elna-768537d6e4b82a19e77b7e44234309ecaf4d65d2.tar.gz | |
Remove unions
Diffstat (limited to 'boot')
| -rw-r--r-- | boot/ast.cc | 34 | ||||
| -rw-r--r-- | boot/lexer.ll | 3 | ||||
| -rw-r--r-- | boot/parser.yy | 5 | ||||
| -rw-r--r-- | boot/semantic.cc | 20 | ||||
| -rw-r--r-- | boot/symbol.cc | 24 |
5 files changed, 0 insertions, 86 deletions
diff --git a/boot/ast.cc b/boot/ast.cc index d0d19b7..fbecf11 100644 --- a/boot/ast.cc +++ b/boot/ast.cc @@ -39,11 +39,6 @@ namespace elna::boot __builtin_unreachable(); } - void empty_visitor::visit(union_type_expression *) - { - __builtin_unreachable(); - } - void empty_visitor::visit(procedure_type_expression *) { __builtin_unreachable(); @@ -391,14 +386,6 @@ namespace elna::boot } } - void walking_visitor::visit(union_type_expression *expression) - { - for (const field_declaration& field : expression->fields) - { - field.second->accept(this); - } - } - void walking_visitor::visit(procedure_type_expression *expression) { for (const field_declaration& field : expression->parameters) @@ -557,11 +544,6 @@ namespace elna::boot return nullptr; } - union_type_expression *type_expression::is_union() - { - return nullptr; - } - procedure_type_expression *type_expression::is_procedure() { return nullptr; @@ -646,22 +628,6 @@ namespace elna::boot return this; } - union_type_expression::union_type_expression(const struct position position, - std::vector<field_declaration>&& fields) - : node(position), fields(std::move(fields)) - { - } - - void union_type_expression::accept(parser_visitor *visitor) - { - visitor->visit(this); - } - - union_type_expression *union_type_expression::is_union() - { - return this; - } - variable_declaration::variable_declaration(const struct position position, std::vector<identifier_definition>&& identifier, std::shared_ptr<type_expression> variable_type, expression *initializer) diff --git a/boot/lexer.ll b/boot/lexer.ll index f914d75..05015f6 100644 --- a/boot/lexer.ll +++ b/boot/lexer.ll @@ -100,9 +100,6 @@ type { record { return yy::parser::make_RECORD(this->location); } -union { - return yy::parser::make_UNION(this->location); -} true { return yy::parser::make_BOOLEAN(true, this->location); } diff --git a/boot/parser.yy b/boot/parser.yy index 6ada702..aace9a1 100644 --- a/boot/parser.yy +++ b/boot/parser.yy @@ -93,7 +93,6 @@ along with GCC; see the file COPYING3. If not see PROCEDURE "proc" TYPE "type" RECORD "record" - UNION "union" EXTERN "extern" IF "if" WHILE "while" @@ -467,10 +466,6 @@ type_expression: { $$ = new boot::record_type_expression(boot::make_position(@1), std::move($5), std::move($3)); } - | "union" required_fields "end" - { - $$ = new boot::union_type_expression(boot::make_position(@1), std::move($2)); - } | "proc" procedure_heading { $$ = $2; diff --git a/boot/semantic.cc b/boot/semantic.cc index df6e70e..29925c2 100644 --- a/boot/semantic.cc +++ b/boot/semantic.cc @@ -459,16 +459,6 @@ namespace elna::boot return type(std::make_shared<pointer_type>(lookup_primitive_type("Char"))); } } - else if (auto composite = resolved_type.get<union_type>()) - { - for (auto& field : composite->fields) - { - if (field.first == field_name) - { - return field.second; - } - } - } return type(); } @@ -581,16 +571,6 @@ namespace elna::boot this->current_type = type(result_type); } - void name_analysis_visitor::visit(union_type_expression *expression) - { - auto result_type = std::make_shared<union_type>(); - - std::set<std::string> field_names; - result_type->fields = build_composite_type(expression->fields, field_names); - - this->current_type = type(result_type); - } - void name_analysis_visitor::visit(procedure_type_expression *expression) { std::shared_ptr<procedure_type> result_type = diff --git a/boot/symbol.cc b/boot/symbol.cc index b75cdc1..9052b23 100644 --- a/boot/symbol.cc +++ b/boot/symbol.cc @@ -38,11 +38,6 @@ namespace elna::boot { } - type::type(std::shared_ptr<union_type> _union) - : tag(type_tag::_union), _union(_union) - { - } - type::type(std::shared_ptr<pointer_type> pointer) : tag(type_tag::pointer), pointer(pointer) { @@ -78,9 +73,6 @@ namespace elna::boot case type_tag::record: new (&record) std::shared_ptr<record_type>(other.record); break; - case type_tag::_union: - new (&_union) std::shared_ptr<union_type>(other._union); - break; case type_tag::pointer: new (&pointer) std::shared_ptr<pointer_type>(other.pointer); break; @@ -117,9 +109,6 @@ namespace elna::boot case type_tag::record: new (&record) std::shared_ptr<record_type>(std::move(other.record)); break; - case type_tag::_union: - new (&_union) std::shared_ptr<union_type>(std::move(other._union)); - break; case type_tag::pointer: new (&pointer) std::shared_ptr<pointer_type>(std::move(other.pointer)); break; @@ -172,9 +161,6 @@ namespace elna::boot case type_tag::record: this->record.~shared_ptr<record_type>(); break; - case type_tag::_union: - this->_union.~shared_ptr<union_type>(); - break; case type_tag::pointer: this->pointer.~shared_ptr<pointer_type>(); break; @@ -209,12 +195,6 @@ namespace elna::boot } template<> - std::shared_ptr<union_type> type::get<union_type>() const - { - return tag == type_tag::_union ? this->_union : nullptr; - } - - template<> std::shared_ptr<pointer_type> type::get<pointer_type>() const { return tag == type_tag::pointer ? this->pointer : nullptr; @@ -258,10 +238,6 @@ namespace elna::boot return right_primitive != nullptr && left_primitive->identifier == right_primitive->identifier; } - if (auto left_union = resolved_this.get<union_type>()) - { - return left_union == resolved_that.get<union_type>(); - } if (auto left_enumeration = resolved_this.get<enumeration_type>()) { return left_enumeration == resolved_that.get<enumeration_type>(); |
