Allow only one return

This commit is contained in:
2025-03-01 00:00:36 +01:00
parent f091344cce
commit 18602d00a1
10 changed files with 39 additions and 198 deletions

View File

@ -86,24 +86,6 @@ 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)
@ -448,8 +430,9 @@ namespace boot
}
procedure_definition::procedure_definition(const struct position position, const std::string& identifier,
const bool exported, std::shared_ptr<procedure_type> heading, block *body)
: definition(position, identifier, exported), m_heading(heading), body(body)
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)
{
}
@ -466,6 +449,7 @@ namespace boot
procedure_definition::~procedure_definition()
{
delete body;
delete returning;
}
type_definition::type_definition(const struct position position, const std::string& identifier,
@ -536,24 +520,6 @@ 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()
{
}
@ -805,26 +771,6 @@ 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);