Rename AST types to type expressions
This commit is contained in:
		
							
								
								
									
										235
									
								
								boot/ast.cc
									
									
									
									
									
								
							
							
						
						
									
										235
									
								
								boot/ast.cc
									
									
									
									
									
								
							@@ -23,215 +23,167 @@ namespace boot
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    void empty_visitor::visit(variable_declaration *)
 | 
					    void empty_visitor::visit(variable_declaration *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(constant_definition *definition)
 | 
					    void empty_visitor::visit(constant_definition *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        definition->body().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(procedure_definition *definition)
 | 
					    void empty_visitor::visit(procedure_definition *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        definition->heading().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        if (definition->body != nullptr)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            definition->body->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(type_definition *definition)
 | 
					    void empty_visitor::visit(type_definition *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        definition->body().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(procedure_call *call)
 | 
					    void empty_visitor::visit(procedure_call *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        for (expression *const argument : call->arguments)
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            argument->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(traits_expression *trait)
 | 
					    void empty_visitor::visit(traits_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        trait->type().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(cast_expression *expression)
 | 
					    void empty_visitor::visit(cast_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression->target().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        expression->value().accept(this);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(assign_statement *statement)
 | 
					    void empty_visitor::visit(assign_statement *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        statement->rvalue().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(if_statement *statement)
 | 
					    void empty_visitor::visit(if_statement *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        statement->body().prerequisite().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        for (const auto body_statement : statement->body().statements)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            body_statement->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(while_statement *statement)
 | 
					    void empty_visitor::visit(while_statement *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        statement->body().prerequisite().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        for (const auto body_statement : statement->body().statements)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            body_statement->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(return_statement *statement)
 | 
					    void empty_visitor::visit(return_statement *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression *return_expression = statement->return_expression();
 | 
					        __builtin_unreachable();
 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (return_expression != nullptr)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            return_expression->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(defer_statement *defer)
 | 
					    void empty_visitor::visit(defer_statement *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        for (statement *const body_statement : defer->statements)
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            body_statement->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(block *block)
 | 
					    void empty_visitor::visit(block *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        for (constant_definition *const constant : block->constants)
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            constant->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        for (variable_declaration *const variable : block->variables)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            variable->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        for (statement *const body_statement : block->body)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            body_statement->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(program *program)
 | 
					    void empty_visitor::visit(program *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        visit(reinterpret_cast<block *>(program));
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        for (type_definition *const type : program->types)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            type->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        for (procedure_definition *const procedure : program->procedures)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            procedure->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(binary_expression *expression)
 | 
					    void empty_visitor::visit(binary_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression->lhs().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        expression->rhs().accept(this);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(unary_expression *expression)
 | 
					    void empty_visitor::visit(unary_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression->operand().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(basic_type *)
 | 
					    void empty_visitor::visit(primitive_type_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(array_type *expression)
 | 
					    void empty_visitor::visit(array_type_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression->base().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(pointer_type *expression)
 | 
					    void empty_visitor::visit(pointer_type_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression->base().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(record_type *expression)
 | 
					    void empty_visitor::visit(record_type_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        for (auto& field : expression->fields)
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            field.second->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(union_type *expression)
 | 
					    void empty_visitor::visit(union_type_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        for (auto& field : expression->fields)
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            field.second->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(procedure_type *expression)
 | 
					    void empty_visitor::visit(procedure_type_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        for (auto parameter : expression->parameters)
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            parameter->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if (expression->return_type != nullptr)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            expression->return_type->accept(this);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(variable_expression *)
 | 
					    void empty_visitor::visit(variable_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(array_access_expression *expression)
 | 
					    void empty_visitor::visit(array_access_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression->base().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
        expression->index().accept(this);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(field_access_expression *expression)
 | 
					    void empty_visitor::visit(field_access_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression->base().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(dereference_expression *expression)
 | 
					    void empty_visitor::visit(dereference_expression *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        expression->base().accept(this);
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(number_literal<std::int32_t> *)
 | 
					    void empty_visitor::visit(number_literal<std::int32_t> *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(number_literal<std::uint32_t> *)
 | 
					    void empty_visitor::visit(number_literal<std::uint32_t> *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(number_literal<double> *)
 | 
					    void empty_visitor::visit(number_literal<double> *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(number_literal<bool> *)
 | 
					    void empty_visitor::visit(number_literal<bool> *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(number_literal<unsigned char> *)
 | 
					    void empty_visitor::visit(number_literal<unsigned char> *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(number_literal<std::nullptr_t> *)
 | 
					    void empty_visitor::visit(number_literal<std::nullptr_t> *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void empty_visitor::visit(number_literal<std::string> *)
 | 
					    void empty_visitor::visit(number_literal<std::string> *)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        __builtin_unreachable();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    node::node(const struct position position)
 | 
					    node::node(const struct position position)
 | 
				
			||||||
@@ -252,78 +204,80 @@ namespace boot
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    top_type::top_type(const struct position position)
 | 
					    type_expression::type_expression(const struct position position)
 | 
				
			||||||
        : node(position)
 | 
					        : node(position)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    basic_type::basic_type(const struct position position, const std::string& name)
 | 
					    primitive_type_expression::primitive_type_expression(const struct position position, const std::string& name)
 | 
				
			||||||
        : top_type(position), m_name(name)
 | 
					        : type_expression(position), m_name(name)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void basic_type::accept(parser_visitor *visitor)
 | 
					    void primitive_type_expression::accept(parser_visitor *visitor)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const std::string& basic_type::base_name()
 | 
					    const std::string& primitive_type_expression::base_name()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return m_name;
 | 
					        return m_name;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    array_type::array_type(const struct position position, std::shared_ptr<top_type> base, const std::uint32_t size)
 | 
					    array_type_expression::array_type_expression(const struct position position,
 | 
				
			||||||
        : top_type(position), m_base(base), size(size)
 | 
					            std::shared_ptr<type_expression> base, const std::uint32_t size)
 | 
				
			||||||
 | 
					        : type_expression(position), m_base(base), size(size)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void array_type::accept(parser_visitor *visitor)
 | 
					    void array_type_expression::accept(parser_visitor *visitor)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    top_type& array_type::base()
 | 
					    type_expression& array_type_expression::base()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return *m_base;
 | 
					        return *m_base;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pointer_type::pointer_type(const struct position position, std::shared_ptr<top_type> base)
 | 
					    pointer_type_expression::pointer_type_expression(const struct position position,
 | 
				
			||||||
        : top_type(position), m_base(base)
 | 
					            std::shared_ptr<type_expression> base)
 | 
				
			||||||
 | 
					        : type_expression(position), m_base(base)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void pointer_type::accept(parser_visitor *visitor)
 | 
					    void pointer_type_expression::accept(parser_visitor *visitor)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    top_type& pointer_type::base()
 | 
					    type_expression& pointer_type_expression::base()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return *m_base;
 | 
					        return *m_base;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    record_type::record_type(const struct position position, fields_t&& fields)
 | 
					    record_type_expression::record_type_expression(const struct position position, fields_t&& fields)
 | 
				
			||||||
        : top_type(position), fields(std::move(fields))
 | 
					        : type_expression(position), fields(std::move(fields))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void record_type::accept(parser_visitor *visitor)
 | 
					    void record_type_expression::accept(parser_visitor *visitor)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    union_type::union_type(const struct position position, fields_t&& fields)
 | 
					    union_type_expression::union_type_expression(const struct position position, fields_t&& fields)
 | 
				
			||||||
        : top_type(position), fields(std::move(fields))
 | 
					        : type_expression(position), fields(std::move(fields))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void union_type::accept(parser_visitor *visitor)
 | 
					    void union_type_expression::accept(parser_visitor *visitor)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    variable_declaration::variable_declaration(const struct position position, const std::string& identifier,
 | 
					    variable_declaration::variable_declaration(const struct position position, const std::string& identifier,
 | 
				
			||||||
            std::shared_ptr<top_type> type, const bool exported)
 | 
					            std::shared_ptr<type_expression> type, const bool exported)
 | 
				
			||||||
        : definition(position, identifier, exported), m_type(type)
 | 
					        : definition(position, identifier, exported), m_type(type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -333,7 +287,7 @@ namespace boot
 | 
				
			|||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    top_type& variable_declaration::variable_type()
 | 
					    type_expression& variable_declaration::variable_type()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return *m_type;
 | 
					        return *m_type;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -364,22 +318,23 @@ namespace boot
 | 
				
			|||||||
        delete m_body;
 | 
					        delete m_body;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure_type::procedure_type(const struct position position, std::shared_ptr<top_type> return_type)
 | 
					    procedure_type_expression::procedure_type_expression(const struct position position,
 | 
				
			||||||
        : top_type(position), return_type(return_type), no_return(false)
 | 
					            std::shared_ptr<type_expression> return_type)
 | 
				
			||||||
 | 
					        : type_expression(position), return_type(return_type), no_return(false)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure_type::procedure_type(const struct position position, no_return_t)
 | 
					    procedure_type_expression::procedure_type_expression(const struct position position, no_return_t)
 | 
				
			||||||
        : top_type(position), return_type(nullptr), no_return(true)
 | 
					        : type_expression(position), return_type(nullptr), no_return(true)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void procedure_type::accept(parser_visitor *visitor)
 | 
					    void procedure_type_expression::accept(parser_visitor *visitor)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure_type::~procedure_type()
 | 
					    procedure_type_expression::~procedure_type_expression()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        for (auto parameter : this->parameters)
 | 
					        for (auto parameter : this->parameters)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -388,7 +343,7 @@ namespace boot
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure_definition::procedure_definition(const struct position position, const std::string& identifier,
 | 
					    procedure_definition::procedure_definition(const struct position position, const std::string& identifier,
 | 
				
			||||||
            const bool exported, std::shared_ptr<procedure_type> heading, block *body)
 | 
					            const bool exported, std::shared_ptr<procedure_type_expression> heading, block *body)
 | 
				
			||||||
        : definition(position, identifier, exported), m_heading(heading), body(body)
 | 
					        : definition(position, identifier, exported), m_heading(heading), body(body)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -398,7 +353,7 @@ namespace boot
 | 
				
			|||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    procedure_type& procedure_definition::heading()
 | 
					    procedure_type_expression& procedure_definition::heading()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return *m_heading;
 | 
					        return *m_heading;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -409,7 +364,7 @@ namespace boot
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    type_definition::type_definition(const struct position position, const std::string& identifier,
 | 
					    type_definition::type_definition(const struct position position, const std::string& identifier,
 | 
				
			||||||
            const bool exported, std::shared_ptr<top_type> body)
 | 
					            const bool exported, std::shared_ptr<type_expression> body)
 | 
				
			||||||
        : definition(position, identifier, exported), m_body(body)
 | 
					        : definition(position, identifier, exported), m_body(body)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -419,7 +374,7 @@ namespace boot
 | 
				
			|||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    top_type& type_definition::body()
 | 
					    type_expression& type_definition::body()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return *m_body;
 | 
					        return *m_body;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -685,7 +640,7 @@ namespace boot
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    cast_expression::cast_expression(const struct position position,
 | 
					    cast_expression::cast_expression(const struct position position,
 | 
				
			||||||
            std::shared_ptr<top_type> target, expression *value)
 | 
					            std::shared_ptr<type_expression> target, expression *value)
 | 
				
			||||||
        : node(position), m_target(target), m_value(value)
 | 
					        : node(position), m_target(target), m_value(value)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -695,7 +650,7 @@ namespace boot
 | 
				
			|||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    top_type& cast_expression::target()
 | 
					    type_expression& cast_expression::target()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return *m_target;
 | 
					        return *m_target;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -711,7 +666,7 @@ namespace boot
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    traits_expression::traits_expression(const struct position position,
 | 
					    traits_expression::traits_expression(const struct position position,
 | 
				
			||||||
            const std::string& name, std::shared_ptr<top_type> type)
 | 
					            const std::string& name, std::shared_ptr<type_expression> type)
 | 
				
			||||||
        : node(position), m_type(type), name(name)
 | 
					        : node(position), m_type(type), name(name)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -721,7 +676,7 @@ namespace boot
 | 
				
			|||||||
        visitor->visit(this);
 | 
					        visitor->visit(this);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    top_type& traits_expression::type()
 | 
					    type_expression& traits_expression::type()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        return *m_type;
 | 
					        return *m_type;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -125,7 +125,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
				
			|||||||
%type <std::vector<elna::boot::variable_declaration *>> variable_declarations variable_part variable_declaration
 | 
					%type <std::vector<elna::boot::variable_declaration *>> variable_declarations variable_part variable_declaration
 | 
				
			||||||
    formal_parameters formal_parameter_list;
 | 
					    formal_parameters formal_parameter_list;
 | 
				
			||||||
%type <elna::boot::variable_declaration *> formal_parameter
 | 
					%type <elna::boot::variable_declaration *> formal_parameter
 | 
				
			||||||
%type <std::shared_ptr<elna::boot::top_type>> type_expression;
 | 
					%type <std::shared_ptr<elna::boot::type_expression>> type_expression;
 | 
				
			||||||
%type <elna::boot::traits_expression *> traits_expression;
 | 
					%type <elna::boot::traits_expression *> traits_expression;
 | 
				
			||||||
%type <elna::boot::expression *> expression operand;
 | 
					%type <elna::boot::expression *> expression operand;
 | 
				
			||||||
%type <elna::boot::unary_expression *> unary_expression;
 | 
					%type <elna::boot::unary_expression *> unary_expression;
 | 
				
			||||||
@@ -140,13 +140,14 @@ along with GCC; see the file COPYING3.  If not see
 | 
				
			|||||||
%type <elna::boot::statement *> statement;
 | 
					%type <elna::boot::statement *> statement;
 | 
				
			||||||
%type <std::vector<elna::boot::statement *>> statements;
 | 
					%type <std::vector<elna::boot::statement *>> statements;
 | 
				
			||||||
%type <elna::boot::procedure_definition *> procedure_definition;
 | 
					%type <elna::boot::procedure_definition *> procedure_definition;
 | 
				
			||||||
%type <std::shared_ptr<elna::boot::procedure_type>> procedure_heading;
 | 
					%type <std::shared_ptr<elna::boot::procedure_type_expression>> procedure_heading;
 | 
				
			||||||
%type <std::vector<elna::boot::procedure_definition *>> procedure_definitions procedure_part;
 | 
					%type <std::vector<elna::boot::procedure_definition *>> procedure_definitions procedure_part;
 | 
				
			||||||
%type <elna::boot::type_definition *> type_definition;
 | 
					%type <elna::boot::type_definition *> type_definition;
 | 
				
			||||||
%type <std::vector<elna::boot::type_definition *>> type_definitions type_part;
 | 
					%type <std::vector<elna::boot::type_definition *>> type_definitions type_part;
 | 
				
			||||||
%type <elna::boot::block *> block;
 | 
					%type <elna::boot::block *> block;
 | 
				
			||||||
%type <elna::boot::field_t> field_declaration;
 | 
					%type <elna::boot::field_t> field_declaration;
 | 
				
			||||||
%type <std::vector<std::pair<std::string, std::shared_ptr<elna::boot::top_type>>>> optional_fields required_fields;
 | 
					%type <std::vector<std::pair<std::string, std::shared_ptr<elna::boot::type_expression>>>>
 | 
				
			||||||
 | 
					    optional_fields required_fields;
 | 
				
			||||||
%type <std::vector<elna::boot::conditional_statements *>> elsif_then_statements elsif_do_statements;
 | 
					%type <std::vector<elna::boot::conditional_statements *>> elsif_then_statements elsif_do_statements;
 | 
				
			||||||
%type <elna::boot::cast_expression *> cast_expression;
 | 
					%type <elna::boot::cast_expression *> cast_expression;
 | 
				
			||||||
%type <elna::boot::defer_statement *> defer_statement;
 | 
					%type <elna::boot::defer_statement *> defer_statement;
 | 
				
			||||||
@@ -193,17 +194,18 @@ identifier_definitions:
 | 
				
			|||||||
procedure_heading:
 | 
					procedure_heading:
 | 
				
			||||||
    formal_parameter_list
 | 
					    formal_parameter_list
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $$ = std::make_shared<elna::boot::procedure_type>(elna::boot::make_position(@1));
 | 
					            $$ = std::make_shared<elna::boot::procedure_type_expression>(elna::boot::make_position(@1));
 | 
				
			||||||
            std::swap($1, $$->parameters);
 | 
					            std::swap($1, $$->parameters);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    | formal_parameter_list "->" "!"
 | 
					    | formal_parameter_list "->" "!"
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $$ = std::make_shared<elna::boot::procedure_type>(elna::boot::make_position(@1), elna::boot::no_return);
 | 
					            $$ = std::make_shared<elna::boot::procedure_type_expression>(elna::boot::make_position(@1),
 | 
				
			||||||
 | 
					                elna::boot::no_return);
 | 
				
			||||||
            std::swap($1, $$->parameters);
 | 
					            std::swap($1, $$->parameters);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    | formal_parameter_list "->" type_expression
 | 
					    | formal_parameter_list "->" type_expression
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $$ = std::make_shared<elna::boot::procedure_type>(elna::boot::make_position(@1), $3);
 | 
					            $$ = std::make_shared<elna::boot::procedure_type_expression>(elna::boot::make_position(@1), $3);
 | 
				
			||||||
            std::swap($1, $$->parameters);
 | 
					            std::swap($1, $$->parameters);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
procedure_definition:
 | 
					procedure_definition:
 | 
				
			||||||
@@ -484,19 +486,19 @@ optional_fields:
 | 
				
			|||||||
type_expression:
 | 
					type_expression:
 | 
				
			||||||
    "[" INTEGER "]" type_expression
 | 
					    "[" INTEGER "]" type_expression
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $$ = std::make_shared<elna::boot::array_type>(elna::boot::make_position(@1), $4, $2);
 | 
					            $$ = std::make_shared<elna::boot::array_type_expression>(elna::boot::make_position(@1), $4, $2);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    | "^" type_expression
 | 
					    | "^" type_expression
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $$ = std::make_shared<elna::boot::pointer_type>(elna::boot::make_position(@1), $2);
 | 
					            $$ = std::make_shared<elna::boot::pointer_type_expression>(elna::boot::make_position(@1), $2);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    | "record" optional_fields "end"
 | 
					    | "record" optional_fields "end"
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $$ = std::make_shared<elna::boot::record_type>(elna::boot::make_position(@1), std::move($2));
 | 
					            $$ = std::make_shared<elna::boot::record_type_expression>(elna::boot::make_position(@1), std::move($2));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    | "union" required_fields "end"
 | 
					    | "union" required_fields "end"
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $$ = std::make_shared<elna::boot::union_type>(elna::boot::make_position(@1), std::move($2));
 | 
					            $$ = std::make_shared<elna::boot::union_type_expression>(elna::boot::make_position(@1), std::move($2));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    | "proc" procedure_heading
 | 
					    | "proc" procedure_heading
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
@@ -504,7 +506,7 @@ type_expression:
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    | IDENTIFIER
 | 
					    | IDENTIFIER
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            $$ = std::make_shared<elna::boot::basic_type>(elna::boot::make_position(@1), $1);
 | 
					            $$ = std::make_shared<elna::boot::primitive_type_expression>(elna::boot::make_position(@1), $1);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
variable_declaration: identifier_definitions ":" type_expression
 | 
					variable_declaration: identifier_definitions ":" type_expression
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										33
									
								
								boot/semantic.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								boot/semantic.cc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					/* Semantic analysis visitors.
 | 
				
			||||||
 | 
					   Copyright (C) 2025 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GCC is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					the Free Software Foundation; either version 3, or (at your option)
 | 
				
			||||||
 | 
					any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GCC is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					along with GCC; see the file COPYING3.  If not see
 | 
				
			||||||
 | 
					<http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "elna/boot/semantic.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace elna
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					namespace boot
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    name_analysis_visitor::name_analysis_visitor(std::shared_ptr<symbol_table<>> table)
 | 
				
			||||||
 | 
					        : table(table)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void name_analysis_visitor::visit(program *program)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										32
									
								
								boot/symbol.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								boot/symbol.cc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					/* Symbol definitions.
 | 
				
			||||||
 | 
					   Copyright (C) 2025 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GCC is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					the Free Software Foundation; either version 3, or (at your option)
 | 
				
			||||||
 | 
					any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GCC is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					along with GCC; see the file COPYING3.  If not see
 | 
				
			||||||
 | 
					<http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "elna/boot/symbol.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace elna
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					namespace boot
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    type::~type()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    info::~info()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -46,6 +46,8 @@ elna_OBJS = \
 | 
				
			|||||||
	elna/driver.o \
 | 
						elna/driver.o \
 | 
				
			||||||
	elna/lexer.o \
 | 
						elna/lexer.o \
 | 
				
			||||||
	elna/parser.o \
 | 
						elna/parser.o \
 | 
				
			||||||
 | 
						elna/semantic.o \
 | 
				
			||||||
 | 
						elna/symbol.o \
 | 
				
			||||||
	elna/result.o \
 | 
						elna/result.o \
 | 
				
			||||||
	$(END)
 | 
						$(END)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -134,7 +136,7 @@ elna.stagefeedback: stagefeedback-start
 | 
				
			|||||||
	-mv elna/*$(objext) stagefeedback/elna
 | 
						-mv elna/*$(objext) stagefeedback/elna
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ELNA_INCLUDES = -I $(srcdir)/elna/include -I elna/generated
 | 
					ELNA_INCLUDES = -I $(srcdir)/elna/include -I elna/generated
 | 
				
			||||||
ELNA_CXXFLAGS = -std=c++11
 | 
					ELNA_CXXFLAGS = -std=c++14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
elna/%.o: elna/boot/%.cc elna/generated/parser.hh elna/generated/location.hh
 | 
					elna/%.o: elna/boot/%.cc elna/generated/parser.hh elna/generated/location.hh
 | 
				
			||||||
	$(COMPILE) $(ELNA_CXXFLAGS) $(ELNA_INCLUDES) $<
 | 
						$(COMPILE) $(ELNA_CXXFLAGS) $(ELNA_INCLUDES) $<
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -751,13 +751,13 @@ namespace gcc
 | 
				
			|||||||
        this->current_expression = NULL_TREE;
 | 
					        this->current_expression = NULL_TREE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tree generic_visitor::build_procedure_type(boot::procedure_type& type)
 | 
					    tree generic_visitor::build_procedure_type(boot::procedure_type_expression& type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::vector<tree> parameter_types(type.parameters.size());
 | 
					        std::vector<tree> parameter_types(type.parameters.size());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        for (std::size_t i = 0; i < type.parameters.size(); ++i)
 | 
					        for (std::size_t i = 0; i < type.parameters.size(); ++i)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            boot::top_type& parameter_type = type.parameters.at(i)->variable_type();
 | 
					            boot::type_expression& parameter_type = type.parameters.at(i)->variable_type();
 | 
				
			||||||
            parameter_type.accept(this);
 | 
					            parameter_type.accept(this);
 | 
				
			||||||
            parameter_types[i] = this->current_expression;
 | 
					            parameter_types[i] = this->current_expression;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -1102,7 +1102,7 @@ namespace gcc
 | 
				
			|||||||
        this->current_expression = NULL_TREE;
 | 
					        this->current_expression = NULL_TREE;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void generic_visitor::visit(boot::basic_type *type)
 | 
					    void generic_visitor::visit(boot::primitive_type_expression *type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        tree symbol = this->lookup(type->base_name());
 | 
					        tree symbol = this->lookup(type->base_name());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1119,7 +1119,7 @@ namespace gcc
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void generic_visitor::visit(boot::array_type *type)
 | 
					    void generic_visitor::visit(boot::array_type_expression *type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        tree lower_bound = build_int_cst_type(integer_type_node, 0);
 | 
					        tree lower_bound = build_int_cst_type(integer_type_node, 0);
 | 
				
			||||||
        tree upper_bound = build_int_cst_type(integer_type_node, type->size);
 | 
					        tree upper_bound = build_int_cst_type(integer_type_node, type->size);
 | 
				
			||||||
@@ -1133,7 +1133,7 @@ namespace gcc
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void generic_visitor::visit(boot::pointer_type *type)
 | 
					    void generic_visitor::visit(boot::pointer_type_expression *type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        type->base().accept(this);
 | 
					        type->base().accept(this);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1143,7 +1143,7 @@ namespace gcc
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void generic_visitor::visit(boot::record_type *type)
 | 
					    void generic_visitor::visit(boot::record_type_expression *type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::set<std::string> field_names;
 | 
					        std::set<std::string> field_names;
 | 
				
			||||||
        tree record_type_node = make_node(RECORD_TYPE);
 | 
					        tree record_type_node = make_node(RECORD_TYPE);
 | 
				
			||||||
@@ -1172,7 +1172,7 @@ namespace gcc
 | 
				
			|||||||
        this->current_expression = record_type_node;
 | 
					        this->current_expression = record_type_node;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void generic_visitor::visit(boot::union_type *type)
 | 
					    void generic_visitor::visit(boot::union_type_expression *type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::set<std::string> field_names;
 | 
					        std::set<std::string> field_names;
 | 
				
			||||||
        tree union_type_node = make_node(UNION_TYPE);
 | 
					        tree union_type_node = make_node(UNION_TYPE);
 | 
				
			||||||
@@ -1201,7 +1201,7 @@ namespace gcc
 | 
				
			|||||||
        this->current_expression = union_type_node;
 | 
					        this->current_expression = union_type_node;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void generic_visitor::visit(boot::procedure_type *type)
 | 
					    void generic_visitor::visit(boot::procedure_type_expression *type)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        tree procedure_type_node = build_procedure_type(*type);
 | 
					        tree procedure_type_node = build_procedure_type(*type);
 | 
				
			||||||
        this->current_expression = build_pointer_type_for_mode(procedure_type_node, VOIDmode, true);
 | 
					        this->current_expression = build_pointer_type_for_mode(procedure_type_node, VOIDmode, true);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <fstream>
 | 
					#include <fstream>
 | 
				
			||||||
#include "elna/boot/driver.h"
 | 
					#include "elna/boot/driver.h"
 | 
				
			||||||
 | 
					#include "elna/boot/semantic.h"
 | 
				
			||||||
#include "elna/gcc/elna-tree.h"
 | 
					#include "elna/gcc/elna-tree.h"
 | 
				
			||||||
#include "elna/gcc/elna-generic.h"
 | 
					#include "elna/gcc/elna-generic.h"
 | 
				
			||||||
#include "elna/gcc/elna-diagnostic.h"
 | 
					#include "elna/gcc/elna-diagnostic.h"
 | 
				
			||||||
@@ -88,8 +89,10 @@ static void elna_parse_file(const char *filename)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        elna::boot::name_analysis_visitor name_analysis_visitor{ std::make_shared<elna::boot::symbol_table<>>() };
 | 
				
			||||||
        elna::gcc::generic_visitor generic_visitor{ std::make_shared<elna::gcc::symbol_table>() };
 | 
					        elna::gcc::generic_visitor generic_visitor{ std::make_shared<elna::gcc::symbol_table>() };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        name_analysis_visitor.visit(driver.tree.get());
 | 
				
			||||||
        generic_visitor.visit(driver.tree.get());
 | 
					        generic_visitor.visit(driver.tree.get());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
 | 
					    linemap_add(line_table, LC_LEAVE, 0, NULL, 0);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,12 +69,12 @@ namespace boot
 | 
				
			|||||||
    class program;
 | 
					    class program;
 | 
				
			||||||
    class binary_expression;
 | 
					    class binary_expression;
 | 
				
			||||||
    class unary_expression;
 | 
					    class unary_expression;
 | 
				
			||||||
    class basic_type;
 | 
					    class primitive_type_expression;
 | 
				
			||||||
    class array_type;
 | 
					    class array_type_expression;
 | 
				
			||||||
    class pointer_type;
 | 
					    class pointer_type_expression;
 | 
				
			||||||
    class record_type;
 | 
					    class record_type_expression;
 | 
				
			||||||
    class union_type;
 | 
					    class union_type_expression;
 | 
				
			||||||
    class procedure_type;
 | 
					    class procedure_type_expression;
 | 
				
			||||||
    class variable_expression;
 | 
					    class variable_expression;
 | 
				
			||||||
    class array_access_expression;
 | 
					    class array_access_expression;
 | 
				
			||||||
    class field_access_expression;
 | 
					    class field_access_expression;
 | 
				
			||||||
@@ -104,16 +104,16 @@ namespace boot
 | 
				
			|||||||
        virtual void visit(program *) = 0;
 | 
					        virtual void visit(program *) = 0;
 | 
				
			||||||
        virtual void visit(binary_expression *) = 0;
 | 
					        virtual void visit(binary_expression *) = 0;
 | 
				
			||||||
        virtual void visit(unary_expression *) = 0;
 | 
					        virtual void visit(unary_expression *) = 0;
 | 
				
			||||||
        virtual void visit(basic_type *) = 0;
 | 
					        virtual void visit(primitive_type_expression *) = 0;
 | 
				
			||||||
        virtual void visit(array_type *) = 0;
 | 
					        virtual void visit(array_type_expression *) = 0;
 | 
				
			||||||
        virtual void visit(pointer_type *) = 0;
 | 
					        virtual void visit(pointer_type_expression *) = 0;
 | 
				
			||||||
        virtual void visit(record_type *) = 0;
 | 
					        virtual void visit(record_type_expression *) = 0;
 | 
				
			||||||
        virtual void visit(union_type *) = 0;
 | 
					        virtual void visit(union_type_expression *) = 0;
 | 
				
			||||||
        virtual void visit(procedure_type *) = 0;
 | 
					        virtual void visit(procedure_type_expression *) = 0;
 | 
				
			||||||
        virtual void visit(variable_expression *) = 0;
 | 
					        virtual void visit(variable_expression *) = 0;
 | 
				
			||||||
        virtual void visit(array_access_expression *) = 0;
 | 
					        virtual void visit(array_access_expression *) = 0;
 | 
				
			||||||
        virtual void visit(field_access_expression *is_field_access) = 0;
 | 
					        virtual void visit(field_access_expression *) = 0;
 | 
				
			||||||
        virtual void visit(dereference_expression *is_dereference) = 0;
 | 
					        virtual void visit(dereference_expression *) = 0;
 | 
				
			||||||
        virtual void visit(number_literal<std::int32_t> *) = 0;
 | 
					        virtual void visit(number_literal<std::int32_t> *) = 0;
 | 
				
			||||||
        virtual void visit(number_literal<std::uint32_t> *) = 0;
 | 
					        virtual void visit(number_literal<std::uint32_t> *) = 0;
 | 
				
			||||||
        virtual void visit(number_literal<double> *) = 0;
 | 
					        virtual void visit(number_literal<double> *) = 0;
 | 
				
			||||||
@@ -129,31 +129,31 @@ namespace boot
 | 
				
			|||||||
    struct empty_visitor : parser_visitor
 | 
					    struct empty_visitor : parser_visitor
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        virtual void visit(variable_declaration *) override;
 | 
					        virtual void visit(variable_declaration *) override;
 | 
				
			||||||
        virtual void visit(constant_definition *definition) override;
 | 
					        virtual void visit(constant_definition *) override;
 | 
				
			||||||
        virtual void visit(procedure_definition *definition) override;
 | 
					        virtual void visit(procedure_definition *) override;
 | 
				
			||||||
        virtual void visit(type_definition *definition) override;
 | 
					        virtual void visit(type_definition *) override;
 | 
				
			||||||
        virtual void visit(traits_expression *trait) override;
 | 
					        virtual void visit(traits_expression *) override;
 | 
				
			||||||
        virtual void visit(procedure_call *call) override;
 | 
					        virtual void visit(procedure_call *) override;
 | 
				
			||||||
        virtual void visit(cast_expression *expression) override;
 | 
					        virtual void visit(cast_expression *) override;
 | 
				
			||||||
        virtual void visit(assign_statement *statement) override;
 | 
					        virtual void visit(assign_statement *) override;
 | 
				
			||||||
        virtual void visit(if_statement *) override;
 | 
					        virtual void visit(if_statement *) override;
 | 
				
			||||||
        virtual void visit(while_statement *) override;
 | 
					        virtual void visit(while_statement *) override;
 | 
				
			||||||
        virtual void visit(return_statement *) override;
 | 
					        virtual void visit(return_statement *) override;
 | 
				
			||||||
        virtual void visit(defer_statement *defer) override;
 | 
					        virtual void visit(defer_statement *) override;
 | 
				
			||||||
        virtual void visit(block *block) override;
 | 
					        virtual void visit(block *) override;
 | 
				
			||||||
        virtual void visit(program *program) override;
 | 
					        virtual void visit(program *) override;
 | 
				
			||||||
        virtual void visit(binary_expression *expression) override;
 | 
					        virtual void visit(binary_expression *) override;
 | 
				
			||||||
        virtual void visit(unary_expression *expression) override;
 | 
					        virtual void visit(unary_expression *) override;
 | 
				
			||||||
        virtual void visit(basic_type *) override;
 | 
					        virtual void visit(primitive_type_expression *) override;
 | 
				
			||||||
        virtual void visit(array_type *expression) override;
 | 
					        virtual void visit(array_type_expression *) override;
 | 
				
			||||||
        virtual void visit(pointer_type *) override;
 | 
					        virtual void visit(pointer_type_expression *) override;
 | 
				
			||||||
        virtual void visit(record_type *expression) override;
 | 
					        virtual void visit(record_type_expression *) override;
 | 
				
			||||||
        virtual void visit(union_type *expression) override;
 | 
					        virtual void visit(union_type_expression *) override;
 | 
				
			||||||
        virtual void visit(procedure_type *expression) override;
 | 
					        virtual void visit(procedure_type_expression *) override;
 | 
				
			||||||
        virtual void visit(variable_expression *) override;
 | 
					        virtual void visit(variable_expression *) override;
 | 
				
			||||||
        virtual void visit(array_access_expression *expression) override;
 | 
					        virtual void visit(array_access_expression *) override;
 | 
				
			||||||
        virtual void visit(field_access_expression *expression) override;
 | 
					        virtual void visit(field_access_expression *) override;
 | 
				
			||||||
        virtual void visit(dereference_expression *expression) override;
 | 
					        virtual void visit(dereference_expression *) override;
 | 
				
			||||||
        virtual void visit(number_literal<std::int32_t> *) override;
 | 
					        virtual void visit(number_literal<std::int32_t> *) override;
 | 
				
			||||||
        virtual void visit(number_literal<std::uint32_t> *) override;
 | 
					        virtual void visit(number_literal<std::uint32_t> *) override;
 | 
				
			||||||
        virtual void visit(number_literal<double> *) override;
 | 
					        virtual void visit(number_literal<double> *) override;
 | 
				
			||||||
@@ -214,16 +214,16 @@ namespace boot
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Some type expression.
 | 
					     * Some type expression.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    class top_type : public node, public std::enable_shared_from_this<top_type>
 | 
					    class type_expression : public node, public std::enable_shared_from_this<type_expression>
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    protected:
 | 
					    protected:
 | 
				
			||||||
        top_type(const struct position position);
 | 
					        type_expression(const struct position position);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Expression defining a basic type.
 | 
					     * Expression defining a basic type.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    class basic_type : public top_type
 | 
					    class primitive_type_expression : public type_expression
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        const std::string m_name;
 | 
					        const std::string m_name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -232,55 +232,56 @@ namespace boot
 | 
				
			|||||||
         * \param position Source code position.
 | 
					         * \param position Source code position.
 | 
				
			||||||
         * \param name Type name.
 | 
					         * \param name Type name.
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        basic_type(const struct position position, const std::string& name);
 | 
					        primitive_type_expression(const struct position position, const std::string& name);
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const std::string& base_name();
 | 
					        const std::string& base_name();
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class array_type : public top_type
 | 
					    class array_type_expression : public type_expression
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::shared_ptr<top_type> m_base;
 | 
					        std::shared_ptr<type_expression> m_base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        const std::uint32_t size;
 | 
					        const std::uint32_t size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        array_type(const struct position position, std::shared_ptr<top_type> base, const std::uint32_t size);
 | 
					        array_type_expression(const struct position position,
 | 
				
			||||||
 | 
					                std::shared_ptr<type_expression> base, const std::uint32_t size);
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        top_type& base();
 | 
					        type_expression& base();
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class pointer_type : public top_type
 | 
					    class pointer_type_expression : public type_expression
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::shared_ptr<top_type> m_base;
 | 
					        std::shared_ptr<type_expression> m_base;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        pointer_type(const struct position position, std::shared_ptr<top_type> base);
 | 
					        pointer_type_expression(const struct position position, std::shared_ptr<type_expression> base);
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        top_type& base();
 | 
					        type_expression& base();
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    using field_t = std::pair<std::string, std::shared_ptr<top_type>>;
 | 
					    using field_t = std::pair<std::string, std::shared_ptr<type_expression>>;
 | 
				
			||||||
    using fields_t = std::vector<field_t>;
 | 
					    using fields_t = std::vector<field_t>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class record_type : public top_type
 | 
					    class record_type_expression : public type_expression
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        fields_t fields;
 | 
					        fields_t fields;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        record_type(const struct position position, fields_t&& fields);
 | 
					        record_type_expression(const struct position position, fields_t&& fields);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    class union_type : public top_type
 | 
					    class union_type_expression : public type_expression
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        fields_t fields;
 | 
					        fields_t fields;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        union_type(const struct position position, fields_t&& fields);
 | 
					        union_type_expression(const struct position position, fields_t&& fields);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@@ -290,14 +291,14 @@ namespace boot
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    class variable_declaration : public definition
 | 
					    class variable_declaration : public definition
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::shared_ptr<top_type> m_type;
 | 
					        std::shared_ptr<type_expression> m_type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        variable_declaration(const struct position position, const std::string& identifier,
 | 
					        variable_declaration(const struct position position, const std::string& identifier,
 | 
				
			||||||
                std::shared_ptr<top_type> type, const bool exported = false);
 | 
					                std::shared_ptr<type_expression> type, const bool exported = false);
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        top_type& variable_type();
 | 
					        type_expression& variable_type();
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -342,19 +343,20 @@ namespace boot
 | 
				
			|||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Procedure type.
 | 
					     * Procedure type.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    class procedure_type : public top_type
 | 
					    class procedure_type_expression : public type_expression
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        const std::shared_ptr<top_type> return_type;
 | 
					        const std::shared_ptr<type_expression> return_type;
 | 
				
			||||||
        const bool no_return;
 | 
					        const bool no_return;
 | 
				
			||||||
        std::vector<variable_declaration *> parameters;
 | 
					        std::vector<variable_declaration *> parameters;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        procedure_type(const struct position position, std::shared_ptr<top_type> return_type = nullptr);
 | 
					        procedure_type_expression(const struct position position,
 | 
				
			||||||
        procedure_type(const struct position position, no_return_t);
 | 
					                std::shared_ptr<type_expression> return_type = nullptr);
 | 
				
			||||||
 | 
					        procedure_type_expression(const struct position position, no_return_t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        virtual ~procedure_type() override;
 | 
					        virtual ~procedure_type_expression() override;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -362,16 +364,16 @@ namespace boot
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    class procedure_definition : public definition
 | 
					    class procedure_definition : public definition
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::shared_ptr<procedure_type> m_heading;
 | 
					        std::shared_ptr<procedure_type_expression> m_heading;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        block *const body;
 | 
					        block *const body;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        procedure_definition(const struct position position, const std::string& identifier,
 | 
					        procedure_definition(const struct position position, const std::string& identifier,
 | 
				
			||||||
                const bool exported, std::shared_ptr<procedure_type> heading, block *body = nullptr);
 | 
					                const bool exported, std::shared_ptr<procedure_type_expression> heading, block *body = nullptr);
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        procedure_type& heading();
 | 
					        procedure_type_expression& heading();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        virtual ~procedure_definition() override;
 | 
					        virtual ~procedure_definition() override;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@@ -381,14 +383,14 @@ namespace boot
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    class type_definition : public definition
 | 
					    class type_definition : public definition
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::shared_ptr<top_type> m_body;
 | 
					        std::shared_ptr<type_expression> m_body;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        type_definition(const struct position position, const std::string& identifier,
 | 
					        type_definition(const struct position position, const std::string& identifier,
 | 
				
			||||||
                const bool exported, std::shared_ptr<top_type> expression);
 | 
					                const bool exported, std::shared_ptr<type_expression> expression);
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        top_type& body();
 | 
					        type_expression& body();
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -396,14 +398,14 @@ namespace boot
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    class cast_expression : public expression
 | 
					    class cast_expression : public expression
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::shared_ptr<top_type> m_target;
 | 
					        std::shared_ptr<type_expression> m_target;
 | 
				
			||||||
        expression *m_value;
 | 
					        expression *m_value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        cast_expression(const struct position position, std::shared_ptr<top_type> target, expression *value);
 | 
					        cast_expression(const struct position position, std::shared_ptr<type_expression> target, expression *value);
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        top_type& target();
 | 
					        type_expression& target();
 | 
				
			||||||
        expression& value();
 | 
					        expression& value();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        virtual ~cast_expression() override;
 | 
					        virtual ~cast_expression() override;
 | 
				
			||||||
@@ -411,15 +413,16 @@ namespace boot
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    class traits_expression : public expression
 | 
					    class traits_expression : public expression
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        std::shared_ptr<top_type> m_type;
 | 
					        std::shared_ptr<type_expression> m_type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
        const std::string name;
 | 
					        const std::string name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        traits_expression(const struct position position, const std::string& name, std::shared_ptr<top_type> type);
 | 
					        traits_expression(const struct position position, const std::string& name,
 | 
				
			||||||
 | 
					                std::shared_ptr<type_expression> type);
 | 
				
			||||||
        virtual void accept(parser_visitor *visitor) override;
 | 
					        virtual void accept(parser_visitor *visitor) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        top_type& type();
 | 
					        type_expression& type();
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										37
									
								
								include/elna/boot/semantic.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								include/elna/boot/semantic.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					/* Semantic analysis visitors.
 | 
				
			||||||
 | 
					   Copyright (C) 2025 Free Software Foundation, Inc.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GCC is free software; you can redistribute it and/or modify
 | 
				
			||||||
 | 
					it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					the Free Software Foundation; either version 3, or (at your option)
 | 
				
			||||||
 | 
					any later version.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					GCC is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					GNU General Public License for more details.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					along with GCC; see the file COPYING3.  If not see
 | 
				
			||||||
 | 
					<http://www.gnu.org/licenses/>.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "elna/boot/ast.h"
 | 
				
			||||||
 | 
					#include "elna/boot/symbol.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace elna
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					namespace boot
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    class name_analysis_visitor : public empty_visitor
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        std::shared_ptr<symbol_table<>> table;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        name_analysis_visitor(std::shared_ptr<symbol_table<>> table);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        void visit(program *program) override;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -26,10 +26,27 @@ namespace elna
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
namespace boot
 | 
					namespace boot
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    class type
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        virtual ~type() = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected:
 | 
				
			||||||
 | 
					        type() = default;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class info
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					    public:
 | 
				
			||||||
 | 
					        virtual ~info() = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected:
 | 
				
			||||||
 | 
					        info() = default;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Symbol table.
 | 
					     * Symbol table.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    template<typename T, T nothing>
 | 
					    template<typename T = std::shared_ptr<info>, typename U = std::nullptr_t, U nothing = nullptr>
 | 
				
			||||||
    class symbol_table
 | 
					    class symbol_table
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
    public:
 | 
					    public:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,7 @@ namespace gcc
 | 
				
			|||||||
        std::shared_ptr<symbol_table> symbol_map;
 | 
					        std::shared_ptr<symbol_table> symbol_map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        tree build_label_decl(const char *name, location_t loc);
 | 
					        tree build_label_decl(const char *name, location_t loc);
 | 
				
			||||||
        tree build_procedure_type(boot::procedure_type& type);
 | 
					        tree build_procedure_type(boot::procedure_type_expression& type);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        void enter_scope();
 | 
					        void enter_scope();
 | 
				
			||||||
        tree leave_scope();
 | 
					        tree leave_scope();
 | 
				
			||||||
@@ -89,12 +89,12 @@ namespace gcc
 | 
				
			|||||||
        void visit(boot::assign_statement *statement) override;
 | 
					        void visit(boot::assign_statement *statement) override;
 | 
				
			||||||
        void visit(boot::if_statement *statement) override;
 | 
					        void visit(boot::if_statement *statement) override;
 | 
				
			||||||
        void visit(boot::while_statement *statement) override;
 | 
					        void visit(boot::while_statement *statement) override;
 | 
				
			||||||
        void visit(boot::basic_type *type) override;
 | 
					        void visit(boot::primitive_type_expression *type) override;
 | 
				
			||||||
        void visit(boot::array_type *type) override;
 | 
					        void visit(boot::array_type_expression *type) override;
 | 
				
			||||||
        void visit(boot::pointer_type *type) override;
 | 
					        void visit(boot::pointer_type_expression *type) override;
 | 
				
			||||||
        void visit(boot::record_type *type) override;
 | 
					        void visit(boot::record_type_expression *type) override;
 | 
				
			||||||
        void visit(boot::union_type *type) override;
 | 
					        void visit(boot::union_type_expression *type) override;
 | 
				
			||||||
        void visit(boot::procedure_type *type) override;
 | 
					        void visit(boot::procedure_type_expression *type) override;
 | 
				
			||||||
        void visit(boot::return_statement *statement) override;
 | 
					        void visit(boot::return_statement *statement) override;
 | 
				
			||||||
        void visit(boot::defer_statement *statement) override;
 | 
					        void visit(boot::defer_statement *statement) override;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,7 +33,7 @@ namespace elna
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
namespace gcc
 | 
					namespace gcc
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    using symbol_table = boot::symbol_table<tree, NULL_TREE>;
 | 
					    using symbol_table = boot::symbol_table<tree, tree, NULL_TREE>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool is_pointer_type(tree type);
 | 
					    bool is_pointer_type(tree type);
 | 
				
			||||||
    bool is_integral_type(tree type);
 | 
					    bool is_integral_type(tree type);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user