Use backend interface for expression statements.
authorIan Lance Taylor <iant@google.com>
Wed, 6 Apr 2011 15:30:20 +0000 (15:30 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Wed, 6 Apr 2011 15:30:20 +0000 (15:30 +0000)
* go-gcc.cc (Gcc_backend::expression_statement): New function.

From-SVN: r172051

gcc/go/ChangeLog
gcc/go/go-gcc.cc
gcc/go/gofrontend/backend.h
gcc/go/gofrontend/statements.cc

index 657091a24496323debe6be8a2ed4c1ec2884cffa..b83eae8cb26e76959cd46c843f785e0a43140079 100644 (file)
@@ -1,3 +1,7 @@
+2011-04-06  Ian Lance Taylor  <iant@google.com>
+
+       * go-gcc.cc (Gcc_backend::expression_statement): New function.
+
 2011-04-04  Ian Lance Taylor  <iant@google.com>
 
        * go-gcc.c (class Blabel): Define.
index ee100c6e9156492fb6430814f2f03f1f8fa52843..ce26d4d844e5654feb74173e0ba079a1b6e031a8 100644 (file)
@@ -166,6 +166,9 @@ class Gcc_backend : public Backend
 
   // Statements.
 
+  Bstatement*
+  expression_statement(Bexpression*);
+
   Bstatement*
   assignment_statement(Bexpression* lhs, Bexpression* rhs, source_location);
 
@@ -206,6 +209,15 @@ get_identifier_from_string(const std::string& str)
 {
   return get_identifier_with_length(str.data(), str.length());
 }
+
+// An expression as a statement.
+
+Bstatement*
+Gcc_backend::expression_statement(Bexpression* expr)
+{
+  return this->make_statement(expr->get_tree());
+}
+
 // Assignment.
 
 Bstatement*
index 814263edc22c95f5a2f97215ad39921f64ac3323..a84b9e84c69860a15acc965886e7f61066c1c056 100644 (file)
@@ -107,6 +107,10 @@ class Backend
 
   // Statements.
 
+  // Create an expression statement.
+  virtual Bstatement*
+  expression_statement(Bexpression*) = 0;
+
   // Create an assignment statement.
   virtual Bstatement*
   assignment_statement(Bexpression* lhs, Bexpression* rhs,
index 854b329d9ecc456147587fb48ea12067cebda398..da29a35d00dd6bdef25cbec1da25df693570a382 100644 (file)
@@ -1551,8 +1551,7 @@ class Expression_statement : public Statement
   do_may_fall_through() const;
 
   tree
-  do_get_tree(Translate_context* context)
-  { return this->expr_->get_tree(context); }
+  do_get_tree(Translate_context* context);
 
  private:
   Expression* expr_;
@@ -1589,6 +1588,17 @@ Expression_statement::do_may_fall_through() const
   return true;
 }
 
+// Convert to backend representation.
+
+tree
+Expression_statement::do_get_tree(Translate_context* context)
+{
+  tree expr_tree = this->expr_->get_tree(context);
+  Bexpression* bexpr = tree_to_expr(expr_tree);
+  Bstatement* ret = context->backend()->expression_statement(bexpr);
+  return statement_to_tree(ret);
+}
+
 // Make an expression statement from an Expression.
 
 Statement*