* go-gcc.cc (Gcc_backend::expression_statement): New function.
From-SVN: r172051
+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.
// Statements.
+ Bstatement*
+ expression_statement(Bexpression*);
+
Bstatement*
assignment_statement(Bexpression* lhs, Bexpression* rhs, source_location);
{
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*
// Statements.
+ // Create an expression statement.
+ virtual Bstatement*
+ expression_statement(Bexpression*) = 0;
+
// Create an assignment statement.
virtual Bstatement*
assignment_statement(Bexpression* lhs, Bexpression* rhs,
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_;
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*