Revert "Allow only one return"

This reverts commit 18602d00a1.
This commit is contained in:
2025-03-02 10:45:54 +01:00
parent 75561fd18a
commit 09f204bd16
10 changed files with 231 additions and 79 deletions

View File

@ -86,6 +86,24 @@ namespace boot
}
}
void empty_visitor::visit(return_statement *statement)
{
expression *return_expression = statement->return_expression();
if (return_expression != nullptr)
{
return_expression->accept(this);
}
}
void empty_visitor::visit(defer_statement *defer)
{
for (statement *const body_statement : defer->statements)
{
body_statement->accept(this);
}
}
void empty_visitor::visit(block *block)
{
for (constant_definition *const constant : block->constants)
@ -370,9 +388,8 @@ namespace boot
}
procedure_definition::procedure_definition(const struct position position, const std::string& identifier,
const bool exported, std::shared_ptr<procedure_type> heading,
block *const body, expression *const returning)
: definition(position, identifier, exported), m_heading(heading), body(body), returning(returning)
const bool exported, std::shared_ptr<procedure_type> heading, block *body)
: definition(position, identifier, exported), m_heading(heading), body(body)
{
}
@ -389,7 +406,6 @@ namespace boot
procedure_definition::~procedure_definition()
{
delete body;
delete returning;
}
type_definition::type_definition(const struct position position, const std::string& identifier,
@ -460,6 +476,24 @@ namespace boot
{
}
defer_statement::defer_statement(const struct position position)
: node(position)
{
}
void defer_statement::accept(parser_visitor *visitor)
{
visitor->visit(this);
}
defer_statement::~defer_statement()
{
for (statement *body_statement : statements)
{
delete body_statement;
}
}
designator_expression::designator_expression()
{
}
@ -711,6 +745,26 @@ namespace boot
}
}
return_statement::return_statement(const struct position position, expression *return_expression)
: node(position), m_return_expression(return_expression)
{
}
void return_statement::accept(parser_visitor *visitor)
{
visitor->visit(this);
}
expression *return_statement::return_expression()
{
return m_return_expression;
}
return_statement::~return_statement()
{
delete m_return_expression;
}
void assign_statement::accept(parser_visitor *visitor)
{
visitor->visit(this);