Allow only one return
This commit is contained in:
@ -63,7 +63,6 @@ namespace boot
|
||||
class assign_statement;
|
||||
class if_statement;
|
||||
class while_statement;
|
||||
class return_statement;
|
||||
class traits_expression;
|
||||
class block;
|
||||
class program;
|
||||
@ -81,7 +80,6 @@ namespace boot
|
||||
class dereference_expression;
|
||||
template<typename T>
|
||||
class number_literal;
|
||||
class defer_statement;
|
||||
|
||||
/**
|
||||
* Interface for AST visitors.
|
||||
@ -98,8 +96,6 @@ namespace boot
|
||||
virtual void visit(assign_statement *) = 0;
|
||||
virtual void visit(if_statement *) = 0;
|
||||
virtual void visit(while_statement *) = 0;
|
||||
virtual void visit(return_statement *) = 0;
|
||||
virtual void visit(defer_statement *) = 0;
|
||||
virtual void visit(block *) = 0;
|
||||
virtual void visit(program *) = 0;
|
||||
virtual void visit(binary_expression *) = 0;
|
||||
@ -138,8 +134,6 @@ namespace boot
|
||||
virtual void visit(assign_statement *statement) override;
|
||||
virtual void visit(if_statement *) override;
|
||||
virtual void visit(while_statement *) override;
|
||||
virtual void visit(return_statement *) override;
|
||||
virtual void visit(defer_statement *defer) override;
|
||||
virtual void visit(block *block) override;
|
||||
virtual void visit(program *program) override;
|
||||
virtual void visit(binary_expression *expression) override;
|
||||
@ -383,9 +377,11 @@ namespace boot
|
||||
|
||||
public:
|
||||
block *const body;
|
||||
expression *const returning;
|
||||
|
||||
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> heading,
|
||||
block *const body = nullptr, expression *const returning = nullptr);
|
||||
virtual void accept(parser_visitor *visitor) override;
|
||||
|
||||
procedure_type& heading();
|
||||
@ -456,19 +452,6 @@ namespace boot
|
||||
virtual ~conditional_statements();
|
||||
};
|
||||
|
||||
class return_statement : public statement
|
||||
{
|
||||
expression *m_return_expression{ nullptr };
|
||||
|
||||
public:
|
||||
return_statement(const struct position position, expression *return_expression);
|
||||
virtual void accept(parser_visitor *visitor) override;
|
||||
|
||||
expression *return_expression();
|
||||
|
||||
virtual ~return_statement() override;
|
||||
};
|
||||
|
||||
class designator_expression : public expression
|
||||
{
|
||||
public:
|
||||
@ -661,17 +644,6 @@ namespace boot
|
||||
}
|
||||
};
|
||||
|
||||
class defer_statement : public statement
|
||||
{
|
||||
public:
|
||||
std::vector<statement *> statements;
|
||||
|
||||
defer_statement(const struct position position);
|
||||
virtual void accept(parser_visitor *visitor) override;
|
||||
|
||||
virtual ~defer_statement() override;
|
||||
};
|
||||
|
||||
class binary_expression : public expression
|
||||
{
|
||||
expression *m_lhs;
|
||||
|
@ -61,6 +61,7 @@ namespace gcc
|
||||
void build_record_call(location_t call_location,
|
||||
tree symbol, const std::vector<boot::expression *>& arguments);
|
||||
void visit_statements(const std::vector<boot::statement *>& statements);
|
||||
void visit_return(boot::expression *const return_expression);
|
||||
|
||||
public:
|
||||
generic_visitor(std::shared_ptr<symbol_table> symbol_table);
|
||||
@ -90,8 +91,6 @@ namespace gcc
|
||||
void visit(boot::assign_statement *statement) override;
|
||||
void visit(boot::if_statement *statement) override;
|
||||
void visit(boot::while_statement *statement) override;
|
||||
void visit(boot::return_statement *statement) override;
|
||||
void visit(boot::defer_statement *statement) override;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -72,8 +72,6 @@ namespace gcc
|
||||
bool is_assignable_from(tree assignee, tree assignment);
|
||||
|
||||
void append_statement(tree statement_tree);
|
||||
void defer(tree statement_tree);
|
||||
tree chain_defer();
|
||||
|
||||
tree do_pointer_arithmetic(boot::binary_operator binary_operator, tree left, tree right);
|
||||
tree build_binary_operation(bool condition, boot::binary_expression *expression,
|
||||
|
@ -58,12 +58,6 @@ struct GTY (()) lang_decl
|
||||
{
|
||||
};
|
||||
|
||||
struct GTY (()) defer_scope
|
||||
{
|
||||
tree defer_block;
|
||||
tree try_statements;
|
||||
};
|
||||
|
||||
struct GTY ((chain_next ("%h.level_chain"))) binding_level
|
||||
{
|
||||
// A block chain is needed to call defer statements beloning to each block.
|
||||
@ -74,9 +68,6 @@ struct GTY ((chain_next ("%h.level_chain"))) binding_level
|
||||
|
||||
// Statements before the first defer has been seen.
|
||||
tree statement_list;
|
||||
|
||||
// Defer statement coupled with statements following it.
|
||||
vec<defer_scope, va_gc> *defers;
|
||||
};
|
||||
|
||||
struct GTY (()) language_function
|
||||
|
Reference in New Issue
Block a user