Commit 0c6caf5a by Ian Lance Taylor

Change general statement method to always use backend interface.

From-SVN: r172740
parent fee8b6da
...@@ -1481,7 +1481,8 @@ Function::build_tree(Gogo* gogo, Named_object* named_function) ...@@ -1481,7 +1481,8 @@ Function::build_tree(Gogo* gogo, Named_object* named_function)
{ {
Translate_context dcontext(gogo, named_function, this->block_, Translate_context dcontext(gogo, named_function, this->block_,
tree_to_block(bind)); tree_to_block(bind));
defer_init = this->defer_stack_->get_tree(&dcontext); Bstatement* bdi = this->defer_stack_->get_backend(&dcontext);
defer_init = stat_to_tree(bdi);
} }
} }
......
...@@ -3320,7 +3320,7 @@ Block::get_backend(Translate_context* context) ...@@ -3320,7 +3320,7 @@ Block::get_backend(Translate_context* context)
for (std::vector<Statement*>::const_iterator p = this->statements_.begin(); for (std::vector<Statement*>::const_iterator p = this->statements_.begin();
p != this->statements_.end(); p != this->statements_.end();
++p) ++p)
bstatements.push_back(tree_to_stat((*p)->get_tree(&subcontext))); bstatements.push_back((*p)->get_backend(&subcontext));
context->backend()->block_add_statements(ret, bstatements); context->backend()->block_add_statements(ret, bstatements);
......
...@@ -151,13 +151,12 @@ Statement::thunk_statement() ...@@ -151,13 +151,12 @@ Statement::thunk_statement()
// Get a tree for a Statement. This is really done by the child // Get a tree for a Statement. This is really done by the child
// class. // class.
tree Bstatement*
Statement::get_tree(Translate_context* context) Statement::get_backend(Translate_context* context)
{ {
if (this->classification_ == STATEMENT_ERROR) if (this->classification_ == STATEMENT_ERROR)
return error_mark_node; return context->backend()->error_statement();
return this->do_get_backend(context);
return this->do_get_tree(context);
} }
// Build tree nodes and set locations. // Build tree nodes and set locations.
...@@ -204,8 +203,8 @@ class Error_statement : public Statement ...@@ -204,8 +203,8 @@ class Error_statement : public Statement
do_traverse(Traverse*) do_traverse(Traverse*)
{ return TRAVERSE_CONTINUE; } { return TRAVERSE_CONTINUE; }
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
}; };
...@@ -248,19 +247,18 @@ Variable_declaration_statement::do_traverse_assignments( ...@@ -248,19 +247,18 @@ Variable_declaration_statement::do_traverse_assignments(
// Return the tree for a variable declaration. // Return the tree for a variable declaration.
tree Bstatement*
Variable_declaration_statement::do_get_tree(Translate_context* context) Variable_declaration_statement::do_get_backend(Translate_context* context)
{ {
Variable* var = this->var_->var_value(); Variable* var = this->var_->var_value();
Bvariable* bvar = this->var_->get_backend_variable(context->gogo(), Bvariable* bvar = this->var_->get_backend_variable(context->gogo(),
context->function()); context->function());
tree init = var->get_init_tree(context->gogo(), context->function()); tree init = var->get_init_tree(context->gogo(), context->function());
Bexpression* binit = init == NULL_TREE ? NULL : tree_to_expr(init); Bexpression* binit = init == NULL_TREE ? NULL : tree_to_expr(init);
Bstatement* ret;
if (!var->is_in_heap()) if (!var->is_in_heap())
{ {
gcc_assert(binit != NULL); gcc_assert(binit != NULL);
ret = context->backend()->init_statement(bvar, binit); return context->backend()->init_statement(bvar, binit);
} }
else else
{ {
...@@ -279,7 +277,7 @@ Variable_declaration_statement::do_get_tree(Translate_context* context) ...@@ -279,7 +277,7 @@ Variable_declaration_statement::do_get_tree(Translate_context* context)
Bstatement* s1 = context->backend()->init_statement(bvar, Bstatement* s1 = context->backend()->init_statement(bvar,
tree_to_expr(space)); tree_to_expr(space));
if (binit == NULL) if (binit == NULL)
ret = s1; return s1;
else else
{ {
tree indir = build_fold_indirect_ref_loc(loc, space); tree indir = build_fold_indirect_ref_loc(loc, space);
...@@ -287,10 +285,9 @@ Variable_declaration_statement::do_get_tree(Translate_context* context) ...@@ -287,10 +285,9 @@ Variable_declaration_statement::do_get_tree(Translate_context* context)
Bstatement* s2 = context->backend()->assignment_statement(bindir, Bstatement* s2 = context->backend()->assignment_statement(bindir,
binit, binit,
loc); loc);
ret = context->backend()->compound_statement(s1, s2); return context->backend()->compound_statement(s1, s2);
} }
} }
return stat_to_tree(ret);
} }
// Make a variable declaration. // Make a variable declaration.
...@@ -384,8 +381,8 @@ Temporary_statement::do_check_types(Gogo*) ...@@ -384,8 +381,8 @@ Temporary_statement::do_check_types(Gogo*)
// Return a tree. // Return a tree.
tree Bstatement*
Temporary_statement::do_get_tree(Translate_context* context) Temporary_statement::do_get_backend(Translate_context* context)
{ {
gcc_assert(this->bvariable_ == NULL); gcc_assert(this->bvariable_ == NULL);
...@@ -419,7 +416,7 @@ Temporary_statement::do_get_tree(Translate_context* context) ...@@ -419,7 +416,7 @@ Temporary_statement::do_get_tree(Translate_context* context)
btype, binit, btype, binit,
this->is_address_taken_, this->is_address_taken_,
this->location(), &statement); this->location(), &statement);
return stat_to_tree(statement); return statement;
} }
// Return the backend variable. // Return the backend variable.
...@@ -468,8 +465,8 @@ class Assignment_statement : public Statement ...@@ -468,8 +465,8 @@ class Assignment_statement : public Statement
void void
do_check_types(Gogo*); do_check_types(Gogo*);
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
// Left hand side--the lvalue. // Left hand side--the lvalue.
...@@ -540,30 +537,30 @@ Assignment_statement::do_check_types(Gogo*) ...@@ -540,30 +537,30 @@ Assignment_statement::do_check_types(Gogo*)
// Build a tree for an assignment statement. // Build a tree for an assignment statement.
tree Bstatement*
Assignment_statement::do_get_tree(Translate_context* context) Assignment_statement::do_get_backend(Translate_context* context)
{ {
tree rhs_tree = this->rhs_->get_tree(context); tree rhs_tree = this->rhs_->get_tree(context);
if (rhs_tree == error_mark_node)
return context->backend()->error_statement();
if (this->lhs_->is_sink_expression()) if (this->lhs_->is_sink_expression())
return rhs_tree; return context->backend()->expression_statement(tree_to_expr(rhs_tree));
tree lhs_tree = this->lhs_->get_tree(context); tree lhs_tree = this->lhs_->get_tree(context);
if (lhs_tree == error_mark_node || rhs_tree == error_mark_node) if (lhs_tree == error_mark_node)
return error_mark_node; return context->backend()->error_statement();
rhs_tree = Expression::convert_for_assignment(context, this->lhs_->type(), rhs_tree = Expression::convert_for_assignment(context, this->lhs_->type(),
this->rhs_->type(), rhs_tree, this->rhs_->type(), rhs_tree,
this->location()); this->location());
if (rhs_tree == error_mark_node) if (rhs_tree == error_mark_node)
return error_mark_node; return context->backend()->error_statement();
Bstatement* ret; return context->backend()->assignment_statement(tree_to_expr(lhs_tree),
ret = context->backend()->assignment_statement(tree_to_expr(lhs_tree),
tree_to_expr(rhs_tree), tree_to_expr(rhs_tree),
this->location()); this->location());
return stat_to_tree(ret);
} }
// Make an assignment statement. // Make an assignment statement.
...@@ -634,8 +631,8 @@ class Assignment_operation_statement : public Statement ...@@ -634,8 +631,8 @@ class Assignment_operation_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -761,8 +758,8 @@ class Tuple_assignment_statement : public Statement ...@@ -761,8 +758,8 @@ class Tuple_assignment_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -888,8 +885,8 @@ public: ...@@ -888,8 +885,8 @@ public:
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -1015,8 +1012,8 @@ class Map_assignment_statement : public Statement ...@@ -1015,8 +1012,8 @@ class Map_assignment_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -1129,8 +1126,8 @@ class Tuple_receive_assignment_statement : public Statement ...@@ -1129,8 +1126,8 @@ class Tuple_receive_assignment_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -1253,8 +1250,8 @@ class Tuple_type_guard_assignment_statement : public Statement ...@@ -1253,8 +1250,8 @@ class Tuple_type_guard_assignment_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -1424,8 +1421,8 @@ class Expression_statement : public Statement ...@@ -1424,8 +1421,8 @@ class Expression_statement : public Statement
bool bool
do_may_fall_through() const; do_may_fall_through() const;
tree Bstatement*
do_get_tree(Translate_context* context); do_get_backend(Translate_context* context);
private: private:
Expression* expr_; Expression* expr_;
...@@ -1464,13 +1461,11 @@ Expression_statement::do_may_fall_through() const ...@@ -1464,13 +1461,11 @@ Expression_statement::do_may_fall_through() const
// Convert to backend representation. // Convert to backend representation.
tree Bstatement*
Expression_statement::do_get_tree(Translate_context* context) Expression_statement::do_get_backend(Translate_context* context)
{ {
tree expr_tree = this->expr_->get_tree(context); tree expr_tree = this->expr_->get_tree(context);
Bexpression* bexpr = tree_to_expr(expr_tree); return context->backend()->expression_statement(tree_to_expr(expr_tree));
Bstatement* ret = context->backend()->expression_statement(bexpr);
return stat_to_tree(ret);
} }
// Make an expression statement from an Expression. // Make an expression statement from an Expression.
...@@ -1505,8 +1500,8 @@ class Block_statement : public Statement ...@@ -1505,8 +1500,8 @@ class Block_statement : public Statement
do_may_fall_through() const do_may_fall_through() const
{ return this->block_->may_fall_through(); } { return this->block_->may_fall_through(); }
tree Bstatement*
do_get_tree(Translate_context* context); do_get_backend(Translate_context* context);
private: private:
Block* block_; Block* block_;
...@@ -1514,12 +1509,11 @@ class Block_statement : public Statement ...@@ -1514,12 +1509,11 @@ class Block_statement : public Statement
// Convert a block to the backend representation of a statement. // Convert a block to the backend representation of a statement.
tree Bstatement*
Block_statement::do_get_tree(Translate_context* context) Block_statement::do_get_backend(Translate_context* context)
{ {
Bblock* bblock = this->block_->get_backend(context); Bblock* bblock = this->block_->get_backend(context);
Bstatement* ret = context->backend()->block_statement(bblock); return context->backend()->block_statement(bblock);
return stat_to_tree(ret);
} }
// Make a block statement. // Make a block statement.
...@@ -1552,8 +1546,8 @@ class Inc_dec_statement : public Statement ...@@ -1552,8 +1546,8 @@ class Inc_dec_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -2222,20 +2216,19 @@ Thunk_statement::get_fn_and_arg(Expression** pfn, Expression** parg) ...@@ -2222,20 +2216,19 @@ Thunk_statement::get_fn_and_arg(Expression** pfn, Expression** parg)
// Class Go_statement. // Class Go_statement.
tree Bstatement*
Go_statement::do_get_tree(Translate_context* context) Go_statement::do_get_backend(Translate_context* context)
{ {
Expression* fn; Expression* fn;
Expression* arg; Expression* arg;
if (!this->get_fn_and_arg(&fn, &arg)) if (!this->get_fn_and_arg(&fn, &arg))
return error_mark_node; return context->backend()->error_statement();
Expression* call = Runtime::make_call(Runtime::GO, this->location(), 2, Expression* call = Runtime::make_call(Runtime::GO, this->location(), 2,
fn, arg); fn, arg);
tree call_tree = call->get_tree(context); tree call_tree = call->get_tree(context);
Bexpression* call_bexpr = tree_to_expr(call_tree); Bexpression* call_bexpr = tree_to_expr(call_tree);
Bstatement* ret = context->backend()->expression_statement(call_bexpr); return context->backend()->expression_statement(call_bexpr);
return stat_to_tree(ret);
} }
// Make a go statement. // Make a go statement.
...@@ -2248,13 +2241,13 @@ Statement::make_go_statement(Call_expression* call, source_location location) ...@@ -2248,13 +2241,13 @@ Statement::make_go_statement(Call_expression* call, source_location location)
// Class Defer_statement. // Class Defer_statement.
tree Bstatement*
Defer_statement::do_get_tree(Translate_context* context) Defer_statement::do_get_backend(Translate_context* context)
{ {
Expression* fn; Expression* fn;
Expression* arg; Expression* arg;
if (!this->get_fn_and_arg(&fn, &arg)) if (!this->get_fn_and_arg(&fn, &arg))
return error_mark_node; return context->backend()->error_statement();
source_location loc = this->location(); source_location loc = this->location();
Expression* ds = context->function()->func_value()->defer_stack(loc); Expression* ds = context->function()->func_value()->defer_stack(loc);
...@@ -2263,8 +2256,7 @@ Defer_statement::do_get_tree(Translate_context* context) ...@@ -2263,8 +2256,7 @@ Defer_statement::do_get_tree(Translate_context* context)
ds, fn, arg); ds, fn, arg);
tree call_tree = call->get_tree(context); tree call_tree = call->get_tree(context);
Bexpression* call_bexpr = tree_to_expr(call_tree); Bexpression* call_bexpr = tree_to_expr(call_tree);
Bstatement* ret = context->backend()->expression_statement(call_bexpr); return context->backend()->expression_statement(call_bexpr);
return stat_to_tree(ret);
} }
// Make a defer statement. // Make a defer statement.
...@@ -2424,8 +2416,8 @@ Return_statement::do_lower(Gogo*, Named_object* function, Block* enclosing) ...@@ -2424,8 +2416,8 @@ Return_statement::do_lower(Gogo*, Named_object* function, Block* enclosing)
// Convert a return statement to the backend representation. // Convert a return statement to the backend representation.
tree Bstatement*
Return_statement::do_get_tree(Translate_context* context) Return_statement::do_get_backend(Translate_context* context)
{ {
source_location loc = this->location(); source_location loc = this->location();
...@@ -2446,10 +2438,8 @@ Return_statement::do_get_tree(Translate_context* context) ...@@ -2446,10 +2438,8 @@ Return_statement::do_get_tree(Translate_context* context)
} }
} }
Bstatement* ret; return context->backend()->return_statement(tree_to_function(fndecl),
ret = context->backend()->return_statement(tree_to_function(fndecl),
retvals, loc); retvals, loc);
return stat_to_tree(ret);
} }
// Make a return statement. // Make a return statement.
...@@ -2484,11 +2474,9 @@ class Bc_statement : public Statement ...@@ -2484,11 +2474,9 @@ class Bc_statement : public Statement
do_may_fall_through() const do_may_fall_through() const
{ return false; } { return false; }
tree Bstatement*
do_get_tree(Translate_context* context) do_get_backend(Translate_context* context)
{ { return this->label_->get_goto(context, this->location()); }
return stat_to_tree(this->label_->get_goto(context, this->location()));
}
private: private:
// The label that this branches to. // The label that this branches to.
...@@ -2536,8 +2524,8 @@ class Goto_statement : public Statement ...@@ -2536,8 +2524,8 @@ class Goto_statement : public Statement
do_may_fall_through() const do_may_fall_through() const
{ return false; } { return false; }
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
Label* label_; Label* label_;
...@@ -2559,13 +2547,11 @@ Goto_statement::do_check_types(Gogo*) ...@@ -2559,13 +2547,11 @@ Goto_statement::do_check_types(Gogo*)
// Return the tree for the goto statement. // Return the tree for the goto statement.
tree Bstatement*
Goto_statement::do_get_tree(Translate_context* context) Goto_statement::do_get_backend(Translate_context* context)
{ {
Blabel* blabel = this->label_->get_backend_label(context); Blabel* blabel = this->label_->get_backend_label(context);
Bstatement* statement = context->backend()->goto_statement(blabel, return context->backend()->goto_statement(blabel, this->location());
this->location());
return stat_to_tree(statement);
} }
// Make a goto statement. // Make a goto statement.
...@@ -2595,11 +2581,9 @@ class Goto_unnamed_statement : public Statement ...@@ -2595,11 +2581,9 @@ class Goto_unnamed_statement : public Statement
do_may_fall_through() const do_may_fall_through() const
{ return false; } { return false; }
tree Bstatement*
do_get_tree(Translate_context* context) do_get_backend(Translate_context* context)
{ { return this->label_->get_goto(context, this->location()); }
return stat_to_tree(this->label_->get_goto(context, this->location()));
}
private: private:
Unnamed_label* label_; Unnamed_label* label_;
...@@ -2626,13 +2610,11 @@ Label_statement::do_traverse(Traverse*) ...@@ -2626,13 +2610,11 @@ Label_statement::do_traverse(Traverse*)
// Return a tree defining this label. // Return a tree defining this label.
tree Bstatement*
Label_statement::do_get_tree(Translate_context* context) Label_statement::do_get_backend(Translate_context* context)
{ {
Blabel* blabel = this->label_->get_backend_label(context); Blabel* blabel = this->label_->get_backend_label(context);
Bstatement* statement; return context->backend()->label_definition_statement(blabel);
statement = context->backend()->label_definition_statement(blabel);
return stat_to_tree(statement);
} }
// Make a label statement. // Make a label statement.
...@@ -2658,9 +2640,9 @@ class Unnamed_label_statement : public Statement ...@@ -2658,9 +2640,9 @@ class Unnamed_label_statement : public Statement
do_traverse(Traverse*) do_traverse(Traverse*)
{ return TRAVERSE_CONTINUE; } { return TRAVERSE_CONTINUE; }
tree Bstatement*
do_get_tree(Translate_context* context) do_get_backend(Translate_context* context)
{ return stat_to_tree(this->label_->get_definition(context)); } { return this->label_->get_definition(context); }
private: private:
// The label. // The label.
...@@ -2699,8 +2681,8 @@ class If_statement : public Statement ...@@ -2699,8 +2681,8 @@ class If_statement : public Statement
bool bool
do_may_fall_through() const; do_may_fall_through() const;
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
Expression* cond_; Expression* cond_;
...@@ -2758,22 +2740,19 @@ If_statement::do_may_fall_through() const ...@@ -2758,22 +2740,19 @@ If_statement::do_may_fall_through() const
// Get tree. // Get tree.
tree Bstatement*
If_statement::do_get_tree(Translate_context* context) If_statement::do_get_backend(Translate_context* context)
{ {
gcc_assert(this->cond_->type()->is_boolean_type() gcc_assert(this->cond_->type()->is_boolean_type()
|| this->cond_->type()->is_error()); || this->cond_->type()->is_error());
tree cond_tree = this->cond_->get_tree(context); tree cond_tree = this->cond_->get_tree(context);
Bexpression* cond_expr = tree_to_expr(cond_tree);
Bblock* then_block = this->then_block_->get_backend(context); Bblock* then_block = this->then_block_->get_backend(context);
Bblock* else_block = (this->else_block_ == NULL Bblock* else_block = (this->else_block_ == NULL
? NULL ? NULL
: this->else_block_->get_backend(context)); : this->else_block_->get_backend(context));
Bexpression* cond_expr = tree_to_expr(cond_tree); return context->backend()->if_statement(cond_expr, then_block,
else_block, this->location());
Bstatement* ret = context->backend()->if_statement(cond_expr, then_block,
else_block,
this->location());
return stat_to_tree(ret);
} }
// Make an if statement. // Make an if statement.
...@@ -3255,8 +3234,8 @@ class Constant_switch_statement : public Statement ...@@ -3255,8 +3234,8 @@ class Constant_switch_statement : public Statement
bool bool
do_may_fall_through() const; do_may_fall_through() const;
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
// The value to switch on. // The value to switch on.
...@@ -3313,8 +3292,8 @@ Constant_switch_statement::do_may_fall_through() const ...@@ -3313,8 +3292,8 @@ Constant_switch_statement::do_may_fall_through() const
// Convert to GENERIC. // Convert to GENERIC.
tree Bstatement*
Constant_switch_statement::do_get_tree(Translate_context* context) Constant_switch_statement::do_get_backend(Translate_context* context)
{ {
tree switch_val_tree = this->val_->get_tree(context); tree switch_val_tree = this->val_->get_tree(context);
Bexpression* switch_val_expr = tree_to_expr(switch_val_tree); Bexpression* switch_val_expr = tree_to_expr(switch_val_tree);
...@@ -3334,9 +3313,7 @@ Constant_switch_statement::do_get_tree(Translate_context* context) ...@@ -3334,9 +3313,7 @@ Constant_switch_statement::do_get_tree(Translate_context* context)
all_statements, all_statements,
this->location()); this->location());
Bstatement* ldef = break_label->get_definition(context); Bstatement* ldef = break_label->get_definition(context);
Bstatement* ret = context->backend()->compound_statement(switch_statement, return context->backend()->compound_statement(switch_statement, ldef);
ldef);
return stat_to_tree(ret);
} }
// Class Switch_statement. // Class Switch_statement.
...@@ -3775,8 +3752,8 @@ Send_statement::do_check_types(Gogo*) ...@@ -3775,8 +3752,8 @@ Send_statement::do_check_types(Gogo*)
// Get a tree for a send statement. // Get a tree for a send statement.
tree Bstatement*
Send_statement::do_get_tree(Translate_context* context) Send_statement::do_get_backend(Translate_context* context)
{ {
source_location loc = this->location(); source_location loc = this->location();
...@@ -3824,7 +3801,7 @@ Send_statement::do_get_tree(Translate_context* context) ...@@ -3824,7 +3801,7 @@ Send_statement::do_get_tree(Translate_context* context)
case Type::TYPE_NAMED: case Type::TYPE_NAMED:
case Type::TYPE_FORWARD: case Type::TYPE_FORWARD:
gcc_assert(saw_errors()); gcc_assert(saw_errors());
return error_mark_node; return context->backend()->error_statement();
} }
// Only try to take the address of a variable. We have already // Only try to take the address of a variable. We have already
...@@ -3862,7 +3839,7 @@ Send_statement::do_get_tree(Translate_context* context) ...@@ -3862,7 +3839,7 @@ Send_statement::do_get_tree(Translate_context* context)
val, loc); val, loc);
Expression* ref = Expression::make_temporary_reference(temp, loc); Expression* ref = Expression::make_temporary_reference(temp, loc);
val = Expression::make_unary(OPERATOR_AND, ref, loc); val = Expression::make_unary(OPERATOR_AND, ref, loc);
btemp = tree_to_stat(temp->get_tree(context)); btemp = temp->get_backend(context);
} }
call = Runtime::make_call(code, loc, 3, this->channel_, val, call = Runtime::make_call(code, loc, 3, this->channel_, val,
...@@ -3873,9 +3850,9 @@ Send_statement::do_get_tree(Translate_context* context) ...@@ -3873,9 +3850,9 @@ Send_statement::do_get_tree(Translate_context* context)
Bstatement* s = context->backend()->expression_statement(bcall); Bstatement* s = context->backend()->expression_statement(bcall);
if (btemp == NULL) if (btemp == NULL)
return stat_to_tree(s); return s;
else else
return stat_to_tree(context->backend()->compound_statement(btemp, s)); return context->backend()->compound_statement(btemp, s);
} }
// Make a send statement. // Make a send statement.
...@@ -4232,7 +4209,7 @@ Select_clauses::get_backend(Translate_context* context, ...@@ -4232,7 +4209,7 @@ Select_clauses::get_backend(Translate_context* context,
Temporary_statement* chan_temp = Statement::make_temporary(chan_array_type, Temporary_statement* chan_temp = Statement::make_temporary(chan_array_type,
chans, chans,
location); location);
statements.push_back(tree_to_stat(chan_temp->get_tree(context))); statements.push_back(chan_temp->get_backend(context));
Type* is_send_array_type = Type::make_array_type(Type::lookup_bool_type(), Type* is_send_array_type = Type::make_array_type(Type::lookup_bool_type(),
ecount->copy()); ecount->copy());
...@@ -4243,7 +4220,7 @@ Select_clauses::get_backend(Translate_context* context, ...@@ -4243,7 +4220,7 @@ Select_clauses::get_backend(Translate_context* context,
context->gogo()->lower_expression(context->function(), &is_sends); context->gogo()->lower_expression(context->function(), &is_sends);
Temporary_statement* is_send_temp = Temporary_statement* is_send_temp =
Statement::make_temporary(is_send_array_type, is_sends, location); Statement::make_temporary(is_send_array_type, is_sends, location);
statements.push_back(tree_to_stat(is_send_temp->get_tree(context))); statements.push_back(is_send_temp->get_backend(context));
mpz_init_set_ui(ival, 0); mpz_init_set_ui(ival, 0);
Expression* zero = Expression::make_integer(&ival, NULL, location); Expression* zero = Expression::make_integer(&ival, NULL, location);
...@@ -4375,12 +4352,11 @@ Select_statement::do_lower(Gogo* gogo, Named_object* function, ...@@ -4375,12 +4352,11 @@ Select_statement::do_lower(Gogo* gogo, Named_object* function,
// Return the tree for a select statement. // Return the tree for a select statement.
tree Bstatement*
Select_statement::do_get_tree(Translate_context* context) Select_statement::do_get_backend(Translate_context* context)
{ {
Bstatement* ret = this->clauses_->get_backend(context, this->break_label(), return this->clauses_->get_backend(context, this->break_label(),
this->location()); this->location());
return stat_to_tree(ret);
} }
// Make a select statement. // Make a select statement.
......
...@@ -367,9 +367,9 @@ class Statement ...@@ -367,9 +367,9 @@ class Statement
may_fall_through() const may_fall_through() const
{ return this->do_may_fall_through(); } { return this->do_may_fall_through(); }
// Return the tree for a statement. BLOCK is the enclosing block. // Convert the statement to the backend representation.
tree Bstatement*
get_tree(Translate_context*); get_backend(Translate_context*);
protected: protected:
// Implemented by child class: traverse the tree. // Implemented by child class: traverse the tree.
...@@ -407,9 +407,9 @@ class Statement ...@@ -407,9 +407,9 @@ class Statement
do_may_fall_through() const do_may_fall_through() const
{ return true; } { return true; }
// Implemented by child class: return a tree. // Implemented by child class: convert to backend representation.
virtual tree virtual Bstatement*
do_get_tree(Translate_context*) = 0; do_get_backend(Translate_context*) = 0;
// Traverse an expression in a statement. // Traverse an expression in a statement.
int int
...@@ -507,8 +507,8 @@ class Temporary_statement : public Statement ...@@ -507,8 +507,8 @@ class Temporary_statement : public Statement
void void
do_check_types(Gogo*); do_check_types(Gogo*);
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
// The type of the temporary variable. // The type of the temporary variable.
...@@ -541,8 +541,8 @@ class Variable_declaration_statement : public Statement ...@@ -541,8 +541,8 @@ class Variable_declaration_statement : public Statement
bool bool
do_traverse_assignments(Traverse_assignments*); do_traverse_assignments(Traverse_assignments*);
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
Named_object* var_; Named_object* var_;
...@@ -578,8 +578,8 @@ class Return_statement : public Statement ...@@ -578,8 +578,8 @@ class Return_statement : public Statement
do_may_fall_through() const do_may_fall_through() const
{ return false; } { return false; }
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
// Return values. This may be NULL. // Return values. This may be NULL.
...@@ -614,8 +614,8 @@ class Send_statement : public Statement ...@@ -614,8 +614,8 @@ class Send_statement : public Statement
void void
do_check_types(Gogo*); do_check_types(Gogo*);
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
// The channel on which to send the value. // The channel on which to send the value.
...@@ -822,8 +822,8 @@ class Select_statement : public Statement ...@@ -822,8 +822,8 @@ class Select_statement : public Statement
do_may_fall_through() const do_may_fall_through() const
{ return this->clauses_->may_fall_through(); } { return this->clauses_->may_fall_through(); }
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
// The select clauses. // The select clauses.
...@@ -912,8 +912,8 @@ class Go_statement : public Thunk_statement ...@@ -912,8 +912,8 @@ class Go_statement : public Thunk_statement
{ } { }
protected: protected:
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
}; };
// A defer statement. // A defer statement.
...@@ -926,8 +926,8 @@ class Defer_statement : public Thunk_statement ...@@ -926,8 +926,8 @@ class Defer_statement : public Thunk_statement
{ } { }
protected: protected:
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
}; };
// A label statement. // A label statement.
...@@ -949,8 +949,8 @@ class Label_statement : public Statement ...@@ -949,8 +949,8 @@ class Label_statement : public Statement
int int
do_traverse(Traverse*); do_traverse(Traverse*);
tree Bstatement*
do_get_tree(Translate_context*); do_get_backend(Translate_context*);
private: private:
// The label. // The label.
...@@ -1001,8 +1001,8 @@ class For_statement : public Statement ...@@ -1001,8 +1001,8 @@ class For_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -1059,8 +1059,8 @@ class For_range_statement : public Statement ...@@ -1059,8 +1059,8 @@ class For_range_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -1288,8 +1288,8 @@ class Switch_statement : public Statement ...@@ -1288,8 +1288,8 @@ class Switch_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
...@@ -1434,8 +1434,8 @@ class Type_switch_statement : public Statement ...@@ -1434,8 +1434,8 @@ class Type_switch_statement : public Statement
Statement* Statement*
do_lower(Gogo*, Named_object*, Block*); do_lower(Gogo*, Named_object*, Block*);
tree Bstatement*
do_get_tree(Translate_context*) do_get_backend(Translate_context*)
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment