From: Ian Lance Taylor Date: Wed, 6 Apr 2011 15:30:20 +0000 (+0000) Subject: Use backend interface for expression statements. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cfebcf30eae6e2f41e61d600f129872aaa286fb3;p=gcc.git Use backend interface for expression statements. * go-gcc.cc (Gcc_backend::expression_statement): New function. From-SVN: r172051 --- diff --git a/gcc/go/ChangeLog b/gcc/go/ChangeLog index 657091a2449..b83eae8cb26 100644 --- a/gcc/go/ChangeLog +++ b/gcc/go/ChangeLog @@ -1,3 +1,7 @@ +2011-04-06 Ian Lance Taylor + + * go-gcc.cc (Gcc_backend::expression_statement): New function. + 2011-04-04 Ian Lance Taylor * go-gcc.c (class Blabel): Define. diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index ee100c6e915..ce26d4d844e 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -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* diff --git a/gcc/go/gofrontend/backend.h b/gcc/go/gofrontend/backend.h index 814263edc22..a84b9e84c69 100644 --- a/gcc/go/gofrontend/backend.h +++ b/gcc/go/gofrontend/backend.h @@ -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, diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc index 854b329d9ec..da29a35d00d 100644 --- a/gcc/go/gofrontend/statements.cc +++ b/gcc/go/gofrontend/statements.cc @@ -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*