gccrs: Move statement-related methods into base class Backend

gcc/rust/ChangeLog:

	* rust-backend.h
	(Backend::init_statement): Make non-virtual.
	(Backend::assignment_statement): Likewise.
	(Backend::return_statement): Likewise.
	(Backend::if_statement): Likewise.
	(Backend::loop_expression): Likewise.
	(Backend::exit_expression): Likewise.
	(Backend::compound_statement): Likewise.
	(Backend::statement_list): Likewise.
	(Backend::exception_handler_statement): Likewise.

	(Gcc_backend::init_statement): Remove.
	(Gcc_backend::assignment_statement): Remove.
	(Gcc_backend::return_statement): Remove.
	(Gcc_backend::if_statement): Remove.
	(Gcc_backend::compound_statement): Remove.
	(Gcc_backend::statement_list): Remove.
	(Gcc_backend::exception_handler_statement): Remove.
	(Gcc_backend::loop_expression): Remove.
	(Gcc_backend::exit_expression): Remove.
	* rust-gcc.cc
	(Gcc_backend::init_statement): Rename to ...
	(Backend::init_statement): ... here.
	(Gcc_backend::assignment_statement): Rename to ...
	(Backend::assignment_statement): ... here.
	(Gcc_backend::return_statement): Rename to ...
	(Backend::return_statement): ... here.
	(Gcc_backend::exception_handler_statement): Rename to ...
	(Backend::exception_handler_statement): ... here.
	(Gcc_backend::if_statement): Rename to ...
	(Backend::if_statement): ... here.
	(Gcc_backend::loop_expression): Rename to ...
	(Backend::loop_expression): ... here.
	(Gcc_backend::exit_expression): Rename to ...
	(Backend::exit_expression): ... here.
	(Gcc_backend::compound_statement): Rename to ...
	(Backend::compound_statement): ... here.
	(Gcc_backend::statement_list): Rename to ...
	(Backend::statement_list): ... here.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
This commit is contained in:
Owen Avery
2023-08-31 14:53:50 -04:00
committed by Arthur Cohen
parent 5728f2bf0a
commit b7809f89fb
2 changed files with 22 additions and 47 deletions

View File

@@ -281,40 +281,38 @@ public:
// Create a variable initialization statement in the specified
// function. This initializes a local variable at the point in the
// program flow where it is declared.
virtual tree init_statement (tree, Bvariable *var, tree init) = 0;
tree init_statement (tree, Bvariable *var, tree init);
// Create an assignment statement within the specified function.
virtual tree assignment_statement (tree lhs, tree rhs, location_t) = 0;
tree assignment_statement (tree lhs, tree rhs, location_t);
// Create return statement for an decl for a value (can be NULL_TREE) at a
// location
virtual tree return_statement (tree fndecl, tree val, location_t) = 0;
tree return_statement (tree fndecl, tree val, location_t);
// Create an if statement within a function. ELSE_BLOCK may be NULL.
virtual tree if_statement (tree, tree condition, tree then_block,
tree else_block, location_t)
= 0;
tree if_statement (tree, tree condition, tree then_block, tree else_block,
location_t);
// infinite loop expressions
virtual tree loop_expression (tree body, location_t) = 0;
tree loop_expression (tree body, location_t);
// exit expressions
virtual tree exit_expression (tree condition, location_t) = 0;
tree exit_expression (tree condition, location_t);
// Create a single statement from two statements.
virtual tree compound_statement (tree, tree) = 0;
tree compound_statement (tree, tree);
// Create a single statement from a list of statements.
virtual tree statement_list (const std::vector<tree> &) = 0;
tree statement_list (const std::vector<tree> &);
// Create a statement that attempts to execute BSTAT and calls EXCEPT_STMT if
// an exception occurs. EXCEPT_STMT may be NULL. FINALLY_STMT may be NULL and
// if not NULL, it will always be executed. This is used for handling defers
// in Go functions. In C++, the resulting code is of this form:
// try { BSTAT; } catch { EXCEPT_STMT; } finally { FINALLY_STMT; }
virtual tree exception_handler_statement (tree bstat, tree except_stmt,
tree finally_stmt, location_t)
= 0;
tree exception_handler_statement (tree bstat, tree except_stmt,
tree finally_stmt, location_t);
// Blocks.
@@ -539,28 +537,6 @@ public:
tree call_expression (tree fn, const std::vector<tree> &args,
tree static_chain, location_t);
// Statements.
tree init_statement (tree, Bvariable *var, tree init);
tree assignment_statement (tree lhs, tree rhs, location_t);
tree return_statement (tree fndecl, tree val, location_t locus);
tree if_statement (tree, tree condition, tree then_block, tree else_block,
location_t);
tree compound_statement (tree, tree);
tree statement_list (const std::vector<tree> &);
tree exception_handler_statement (tree bstat, tree except_stmt,
tree finally_stmt, location_t);
tree loop_expression (tree body, location_t);
tree exit_expression (tree condition, location_t);
// Blocks.
tree block (tree, tree, const std::vector<Bvariable *> &, location_t,

View File

@@ -1695,7 +1695,7 @@ Gcc_backend::call_expression (tree fn, const std::vector<tree> &fn_args,
// Variable initialization.
tree
Gcc_backend::init_statement (tree, Bvariable *var, tree init_tree)
Backend::init_statement (tree, Bvariable *var, tree init_tree)
{
tree var_tree = var->get_decl ();
if (var_tree == error_mark_node || init_tree == error_mark_node)
@@ -1727,7 +1727,7 @@ Gcc_backend::init_statement (tree, Bvariable *var, tree init_tree)
// Assignment.
tree
Gcc_backend::assignment_statement (tree lhs, tree rhs, location_t location)
Backend::assignment_statement (tree lhs, tree rhs, location_t location)
{
if (lhs == error_mark_node || rhs == error_mark_node)
return error_mark_node;
@@ -1752,7 +1752,7 @@ Gcc_backend::assignment_statement (tree lhs, tree rhs, location_t location)
// Return.
tree
Gcc_backend::return_statement (tree fntree, tree val, location_t location)
Backend::return_statement (tree fntree, tree val, location_t location)
{
if (fntree == error_mark_node)
return error_mark_node;
@@ -1776,9 +1776,8 @@ Gcc_backend::return_statement (tree fntree, tree val, location_t location)
// try { BSTAT; } catch { EXCEPT_STMT; } finally { FINALLY_STMT; }
tree
Gcc_backend::exception_handler_statement (tree try_stmt, tree except_stmt,
tree finally_stmt,
location_t location)
Backend::exception_handler_statement (tree try_stmt, tree except_stmt,
tree finally_stmt, location_t location)
{
if (try_stmt == error_mark_node || except_stmt == error_mark_node
|| finally_stmt == error_mark_node)
@@ -1797,8 +1796,8 @@ Gcc_backend::exception_handler_statement (tree try_stmt, tree except_stmt,
// If.
tree
Gcc_backend::if_statement (tree, tree cond_tree, tree then_tree, tree else_tree,
location_t location)
Backend::if_statement (tree, tree cond_tree, tree then_tree, tree else_tree,
location_t location)
{
if (cond_tree == error_mark_node || then_tree == error_mark_node
|| else_tree == error_mark_node)
@@ -1811,13 +1810,13 @@ Gcc_backend::if_statement (tree, tree cond_tree, tree then_tree, tree else_tree,
// Loops
tree
Gcc_backend::loop_expression (tree body, location_t locus)
Backend::loop_expression (tree body, location_t locus)
{
return fold_build1_loc (locus, LOOP_EXPR, void_type_node, body);
}
tree
Gcc_backend::exit_expression (tree cond_tree, location_t locus)
Backend::exit_expression (tree cond_tree, location_t locus)
{
return fold_build1_loc (locus, EXIT_EXPR, void_type_node, cond_tree);
}
@@ -1825,7 +1824,7 @@ Gcc_backend::exit_expression (tree cond_tree, location_t locus)
// Pair of statements.
tree
Gcc_backend::compound_statement (tree s1, tree s2)
Backend::compound_statement (tree s1, tree s2)
{
tree stmt_list = NULL_TREE;
tree t = s1;
@@ -1848,7 +1847,7 @@ Gcc_backend::compound_statement (tree s1, tree s2)
// List of statements.
tree
Gcc_backend::statement_list (const std::vector<tree> &statements)
Backend::statement_list (const std::vector<tree> &statements)
{
tree stmt_list = NULL_TREE;
for (std::vector<tree>::const_iterator p = statements.begin ();