Commit 8f888468 by Ian Lance Taylor Committed by Ian Lance Taylor

statement.cc no longer includes gcc headers.

	* go-system.h: Include "intl.h".
	* Make-lang.in (GO_SYSTEM_H): Add intl.h.
	(go/statements.o): Remove dependencies on intl.h $(TREE_H)
	$(GIMPLE_H) convert.h tree-iterator.h $(TREE_FLOW_H) $(REAL_H).

From-SVN: r172743
parent 0c6caf5a
2011-04-19 Ian Lance Taylor <iant@google.com> 2011-04-19 Ian Lance Taylor <iant@google.com>
* go-system.h: Include "intl.h".
* Make-lang.in (GO_SYSTEM_H): Add intl.h.
(go/statements.o): Remove dependencies on intl.h $(TREE_H)
$(GIMPLE_H) convert.h tree-iterator.h $(TREE_FLOW_H) $(REAL_H).
2011-04-19 Ian Lance Taylor <iant@google.com>
* go-gcc.cc (Gcc_backend::temporary_variable): New function. * go-gcc.cc (Gcc_backend::temporary_variable): New function.
2011-04-19 Ian Lance Taylor <iant@google.com> 2011-04-19 Ian Lance Taylor <iant@google.com>
......
...@@ -211,7 +211,7 @@ go.stagefeedback: stagefeedback-start ...@@ -211,7 +211,7 @@ go.stagefeedback: stagefeedback-start
-mv go/*$(objext) stagefeedback/go -mv go/*$(objext) stagefeedback/go
GO_SYSTEM_H = go/go-system.h $(CONFIG_H) $(SYSTEM_H) coretypes.h \ GO_SYSTEM_H = go/go-system.h $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(DIAGNOSTIC_CORE_H) $(INPUT_H) $(DIAGNOSTIC_CORE_H) $(INPUT_H) intl.h
GO_C_H = go/go-c.h $(MACHMODE_H) GO_C_H = go/go-c.h $(MACHMODE_H)
GO_LEX_H = go/gofrontend/lex.h go/gofrontend/operator.h GO_LEX_H = go/gofrontend/lex.h go/gofrontend/operator.h
...@@ -281,8 +281,7 @@ go/parse.o: go/gofrontend/parse.cc $(GO_SYSTEM_H) $(GO_LEX_H) $(GO_GOGO_H) \ ...@@ -281,8 +281,7 @@ go/parse.o: go/gofrontend/parse.cc $(GO_SYSTEM_H) $(GO_LEX_H) $(GO_GOGO_H) \
go/runtime.o: go/gofrontend/runtime.cc $(GO_SYSTEM_H) $(GO_GOGO_H) \ go/runtime.o: go/gofrontend/runtime.cc $(GO_SYSTEM_H) $(GO_GOGO_H) \
$(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_RUNTIME_H) \ $(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_RUNTIME_H) \
go/gofrontend/runtime.def go/gofrontend/runtime.def
go/statements.o: go/gofrontend/statements.cc $(GO_SYSTEM_H) intl.h $(TREE_H) \ go/statements.o: go/gofrontend/statements.cc $(GO_SYSTEM_H) \
$(GIMPLE_H) convert.h tree-iterator.h $(TREE_FLOW_H) $(REAL_H) \
$(GO_C_H) $(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_GOGO_H) \ $(GO_C_H) $(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_GOGO_H) \
$(GO_RUNTIME_H) go/gofrontend/backend.h $(GO_STATEMENTS_H) $(GO_RUNTIME_H) go/gofrontend/backend.h $(GO_STATEMENTS_H)
go/types.o: go/gofrontend/types.cc $(GO_SYSTEM_H) $(TOPLEV_H) intl.h $(TREE_H) \ go/types.o: go/gofrontend/types.cc $(GO_SYSTEM_H) $(TOPLEV_H) intl.h $(TREE_H) \
......
// go-system.h -- Go frontend inclusion of gcc header files -*- C++ -*- // go-system.h -- Go frontend inclusion of gcc header files -*- C++ -*-
// Copyright (C) 2009, 2010 Free Software Foundation, Inc. // Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
// This file is part of GCC. // This file is part of GCC.
...@@ -145,6 +145,7 @@ extern "C" ...@@ -145,6 +145,7 @@ extern "C"
#include "diagnostic-core.h" /* For error_at and friends. */ #include "diagnostic-core.h" /* For error_at and friends. */
#include "input.h" /* For source_location. */ #include "input.h" /* For source_location. */
#include "intl.h" /* For _(). */
#ifndef ENABLE_BUILD_WITH_CXX #ifndef ENABLE_BUILD_WITH_CXX
} // End extern "C" } // End extern "C"
......
...@@ -8,23 +8,6 @@ ...@@ -8,23 +8,6 @@
#include <gmp.h> #include <gmp.h>
#ifndef ENABLE_BUILD_WITH_CXX
extern "C"
{
#endif
#include "intl.h"
#include "tree.h"
#include "gimple.h"
#include "convert.h"
#include "tree-iterator.h"
#include "tree-flow.h"
#include "real.h"
#ifndef ENABLE_BUILD_WITH_CXX
}
#endif
#include "go-c.h" #include "go-c.h"
#include "types.h" #include "types.h"
#include "expressions.h" #include "expressions.h"
...@@ -148,8 +131,8 @@ Statement::thunk_statement() ...@@ -148,8 +131,8 @@ Statement::thunk_statement()
return ret; return ret;
} }
// Get a tree for a Statement. This is really done by the child // Convert a Statement to the backend representation. This is really
// class. // done by the child class.
Bstatement* Bstatement*
Statement::get_backend(Translate_context* context) Statement::get_backend(Translate_context* context)
...@@ -159,17 +142,6 @@ Statement::get_backend(Translate_context* context) ...@@ -159,17 +142,6 @@ Statement::get_backend(Translate_context* context)
return this->do_get_backend(context); return this->do_get_backend(context);
} }
// Build tree nodes and set locations.
tree
Statement::build_stmt_1(int tree_code_value, tree node)
{
tree ret = build1(static_cast<tree_code>(tree_code_value),
void_type_node, node);
SET_EXPR_LOCATION(ret, this->location_);
return ret;
}
// Note that this statement is erroneous. This is called by children // Note that this statement is erroneous. This is called by children
// when they discover an error. // when they discover an error.
...@@ -245,7 +217,7 @@ Variable_declaration_statement::do_traverse_assignments( ...@@ -245,7 +217,7 @@ Variable_declaration_statement::do_traverse_assignments(
return true; return true;
} }
// Return the tree for a variable declaration. // Convert a variable declaration to the backend representation.
Bstatement* Bstatement*
Variable_declaration_statement::do_get_backend(Translate_context* context) Variable_declaration_statement::do_get_backend(Translate_context* context)
...@@ -254,40 +226,48 @@ Variable_declaration_statement::do_get_backend(Translate_context* context) ...@@ -254,40 +226,48 @@ Variable_declaration_statement::do_get_backend(Translate_context* context)
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 ? NULL : tree_to_expr(init);
if (!var->is_in_heap()) if (!var->is_in_heap())
{ {
gcc_assert(binit != NULL); gcc_assert(binit != NULL);
return context->backend()->init_statement(bvar, binit); return context->backend()->init_statement(bvar, binit);
} }
else
// Something takes the address of this variable, so the value is
// stored in the heap. Initialize it to newly allocated memory
// space, and assign the initial value to the new space.
source_location loc = this->location();
Named_object* newfn = context->gogo()->lookup_global("new");
gcc_assert(newfn != NULL && newfn->is_function_declaration());
Expression* func = Expression::make_func_reference(newfn, NULL, loc);
Expression_list* params = new Expression_list();
params->push_back(Expression::make_type(var->type(), loc));
Expression* call = Expression::make_call(func, params, false, loc);
context->gogo()->lower_expression(context->function(), &call);
Temporary_statement* temp = Statement::make_temporary(NULL, call, loc);
Bstatement* btemp = temp->get_backend(context);
Bstatement* set = NULL;
if (binit != NULL)
{ {
// Something takes the address of this variable, so the value is Expression* e = Expression::make_temporary_reference(temp, loc);
// stored in the heap. Initialize it to newly allocated memory e = Expression::make_unary(OPERATOR_MULT, e, loc);
// space, and assign the initial value to the new space. Bexpression* be = tree_to_expr(e->get_tree(context));
source_location loc = this->location(); set = context->backend()->assignment_statement(be, binit, loc);
tree decl = var_to_tree(bvar);
tree decl_type = TREE_TYPE(decl);
gcc_assert(POINTER_TYPE_P(decl_type));
tree size = TYPE_SIZE_UNIT(TREE_TYPE(decl_type));
tree space = context->gogo()->allocate_memory(var->type(), size, loc);
if (binit != NULL)
space = save_expr(space);
space = fold_convert_loc(loc, decl_type, space);
Bstatement* s1 = context->backend()->init_statement(bvar,
tree_to_expr(space));
if (binit == NULL)
return s1;
else
{
tree indir = build_fold_indirect_ref_loc(loc, space);
Bexpression* bindir = tree_to_expr(indir);
Bstatement* s2 = context->backend()->assignment_statement(bindir,
binit,
loc);
return context->backend()->compound_statement(s1, s2);
}
} }
Expression* ref = Expression::make_temporary_reference(temp, loc);
Bexpression* bref = tree_to_expr(ref->get_tree(context));
Bstatement* sinit = context->backend()->init_statement(bvar, bref);
std::vector<Bstatement*> stats;
stats.reserve(3);
stats.push_back(btemp);
if (set != NULL)
stats.push_back(set);
stats.push_back(sinit);
return context->backend()->statement_list(stats);
} }
// Make a variable declaration. // Make a variable declaration.
...@@ -379,7 +359,7 @@ Temporary_statement::do_check_types(Gogo*) ...@@ -379,7 +359,7 @@ Temporary_statement::do_check_types(Gogo*)
} }
} }
// Return a tree. // Convert to backend representation.
Bstatement* Bstatement*
Temporary_statement::do_get_backend(Translate_context* context) Temporary_statement::do_get_backend(Translate_context* context)
...@@ -535,29 +515,18 @@ Assignment_statement::do_check_types(Gogo*) ...@@ -535,29 +515,18 @@ Assignment_statement::do_check_types(Gogo*)
this->set_is_error(); this->set_is_error();
} }
// Build a tree for an assignment statement. // Convert an assignment statement to the backend representation.
Bstatement* Bstatement*
Assignment_statement::do_get_backend(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 context->backend()->expression_statement(tree_to_expr(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)
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)
return context->backend()->error_statement();
return context->backend()->assignment_statement(tree_to_expr(lhs_tree), return context->backend()->assignment_statement(tree_to_expr(lhs_tree),
tree_to_expr(rhs_tree), tree_to_expr(rhs_tree),
this->location()); this->location());
...@@ -2190,7 +2159,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std::string& thunk_name, ...@@ -2190,7 +2159,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std::string& thunk_name,
gogo->finish_function(location); gogo->finish_function(location);
} }
// Get the function and argument trees. // Get the function and argument expressions.
bool bool
Thunk_statement::get_fn_and_arg(Expression** pfn, Expression** parg) Thunk_statement::get_fn_and_arg(Expression** pfn, Expression** parg)
...@@ -2545,7 +2514,7 @@ Goto_statement::do_check_types(Gogo*) ...@@ -2545,7 +2514,7 @@ Goto_statement::do_check_types(Gogo*)
} }
} }
// Return the tree for the goto statement. // Convert the goto statement to the backend representation.
Bstatement* Bstatement*
Goto_statement::do_get_backend(Translate_context* context) Goto_statement::do_get_backend(Translate_context* context)
...@@ -2608,7 +2577,8 @@ Label_statement::do_traverse(Traverse*) ...@@ -2608,7 +2577,8 @@ Label_statement::do_traverse(Traverse*)
return TRAVERSE_CONTINUE; return TRAVERSE_CONTINUE;
} }
// Return a tree defining this label. // Return the backend representation of the statement defining this
// label.
Bstatement* Bstatement*
Label_statement::do_get_backend(Translate_context* context) Label_statement::do_get_backend(Translate_context* context)
...@@ -2738,7 +2708,7 @@ If_statement::do_may_fall_through() const ...@@ -2738,7 +2708,7 @@ If_statement::do_may_fall_through() const
|| this->else_block_->may_fall_through()); || this->else_block_->may_fall_through());
} }
// Get tree. // Get the backend representation.
Bstatement* Bstatement*
If_statement::do_get_backend(Translate_context* context) If_statement::do_get_backend(Translate_context* context)
...@@ -3750,7 +3720,7 @@ Send_statement::do_check_types(Gogo*) ...@@ -3750,7 +3720,7 @@ Send_statement::do_check_types(Gogo*)
} }
} }
// Get a tree for a send statement. // Convert a send statement to the backend representation.
Bstatement* Bstatement*
Send_statement::do_get_backend(Translate_context* context) Send_statement::do_get_backend(Translate_context* context)
...@@ -4034,7 +4004,7 @@ Select_clauses::Select_clause::may_fall_through() const ...@@ -4034,7 +4004,7 @@ Select_clauses::Select_clause::may_fall_through() const
return this->statements_->may_fall_through(); return this->statements_->may_fall_through();
} }
// Return a tree for the statements to execute. // Return the backend representation for the statements to execute.
Bstatement* Bstatement*
Select_clauses::Select_clause::get_statements_backend( Select_clauses::Select_clause::get_statements_backend(
...@@ -4287,7 +4257,7 @@ Select_clauses::get_backend(Translate_context* context, ...@@ -4287,7 +4257,7 @@ Select_clauses::get_backend(Translate_context* context,
return context->backend()->statement_list(statements); return context->backend()->statement_list(statements);
} }
// Add the tree for CLAUSE to STMT_LIST. // Add CLAUSE to CASES/CLAUSES at INDEX.
void void
Select_clauses::add_clause_backend( Select_clauses::add_clause_backend(
...@@ -4350,7 +4320,7 @@ Select_statement::do_lower(Gogo* gogo, Named_object* function, ...@@ -4350,7 +4320,7 @@ Select_statement::do_lower(Gogo* gogo, Named_object* function,
return Statement::make_block_statement(b, this->location()); return Statement::make_block_statement(b, this->location());
} }
// Return the tree for a select statement. // Return the backend representation for a select statement.
Bstatement* Bstatement*
Select_statement::do_get_backend(Translate_context* context) Select_statement::do_get_backend(Translate_context* context)
......
...@@ -424,12 +424,6 @@ class Statement ...@@ -424,12 +424,6 @@ class Statement
int int
traverse_type(Traverse*, Type*); traverse_type(Traverse*, Type*);
// Build a tree node with one operand, setting the location. The
// first operand really has type "enum tree_code", but that enum is
// not defined here.
tree
build_stmt_1(int tree_code_value, tree);
// For children to call when they detect that they are in error. // For children to call when they detect that they are in error.
void void
set_is_error(); set_is_error();
...@@ -744,7 +738,7 @@ class Select_clauses ...@@ -744,7 +738,7 @@ class Select_clauses
bool bool
may_fall_through() const; may_fall_through() const;
// Return a tree for the statements to execute. // Convert the statements to the backend representation.
Bstatement* Bstatement*
get_statements_backend(Translate_context*); get_statements_backend(Translate_context*);
...@@ -865,7 +859,7 @@ class Thunk_statement : public Statement ...@@ -865,7 +859,7 @@ class Thunk_statement : public Statement
void void
do_check_types(Gogo*); do_check_types(Gogo*);
// Return the function and argument trees for the call. // Return the function and argument for the call.
bool bool
get_fn_and_arg(Expression** pfn, Expression** parg); get_fn_and_arg(Expression** pfn, Expression** parg);
...@@ -1168,8 +1162,8 @@ class Case_clauses ...@@ -1168,8 +1162,8 @@ class Case_clauses
std::vector<Bstatement*>* all_statements) const; std::vector<Bstatement*>* all_statements) const;
private: private:
// For a constant tree we need to keep a record of constants we have // For a constant switch we need to keep a record of constants we
// already seen. Note that INTEGER_CST trees are interned. // have already seen.
class Hash_integer_value; class Hash_integer_value;
class Eq_integer_value; class Eq_integer_value;
typedef Unordered_set_hash(Expression*, Hash_integer_value, typedef Unordered_set_hash(Expression*, Hash_integer_value,
...@@ -1439,10 +1433,6 @@ class Type_switch_statement : public Statement ...@@ -1439,10 +1433,6 @@ class Type_switch_statement : public Statement
{ gcc_unreachable(); } { gcc_unreachable(); }
private: private:
// Get the type descriptor.
tree
get_type_descriptor(Translate_context*, Type*, tree);
// The variable holding the value we are switching on. // The variable holding the value we are switching on.
Named_object* var_; Named_object* var_;
// The expression we are switching on if there is no variable. // The expression we are switching on if there is no variable.
......
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