public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-7970] gccrs: Move statement-related methods into base class Backend
Date: Tue, 16 Jan 2024 18:09:48 +0000 (GMT)	[thread overview]
Message-ID: <20240116180948.3DBDC3857713@sourceware.org> (raw)

https://gcc.gnu.org/g:b7809f89fb89aa0bef43790c9140cfd4aa8da02f

commit r14-7970-gb7809f89fb89aa0bef43790c9140cfd4aa8da02f
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Thu Aug 31 14:53:50 2023 -0400

    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>

Diff:
---
 gcc/rust/rust-backend.h | 46 +++++++++++-----------------------------------
 gcc/rust/rust-gcc.cc    | 23 +++++++++++------------
 2 files changed, 22 insertions(+), 47 deletions(-)

diff --git a/gcc/rust/rust-backend.h b/gcc/rust/rust-backend.h
index 81fd1304dba..6b265cccde1 100644
--- a/gcc/rust/rust-backend.h
+++ b/gcc/rust/rust-backend.h
@@ -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,
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 23c2f215771..7ef442b91ed 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -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 ();

                 reply	other threads:[~2024-01-16 18:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240116180948.3DBDC3857713@sourceware.org \
    --to=cohenarthur@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).