Commit f54d331e by Ian Lance Taylor Committed by Ian Lance Taylor

Use the backend interface for select statements.

From-SVN: r172468
parent 7427a368
2011-04-14 Ian Lance Taylor <iant@google.com>
* go-gcc.cc (Backend::error_statement): New function.
2011-04-13 Ian Lance Taylor <iant@google.com> 2011-04-13 Ian Lance Taylor <iant@google.com>
* Make-lang.in (go/gogo-tree.o): depend on $(GO_RUNTIME_H). * Make-lang.in (go/gogo-tree.o): depend on $(GO_RUNTIME_H).
......
...@@ -167,6 +167,10 @@ class Gcc_backend : public Backend ...@@ -167,6 +167,10 @@ class Gcc_backend : public Backend
// Statements. // Statements.
Bstatement* Bstatement*
error_statement()
{ return this->make_statement(error_mark_node); }
Bstatement*
expression_statement(Bexpression*); expression_statement(Bexpression*);
Bstatement* Bstatement*
......
...@@ -107,6 +107,12 @@ class Backend ...@@ -107,6 +107,12 @@ class Backend
// Statements. // Statements.
// Create an error statement. This is used for cases which should
// not occur in a correct program, in order to keep the compilation
// going without crashing.
virtual Bstatement*
error_statement() = 0;
// Create an expression statement. // Create an expression statement.
virtual Bstatement* virtual Bstatement*
expression_statement(Bexpression*) = 0; expression_statement(Bexpression*) = 0;
......
...@@ -3603,10 +3603,11 @@ Unsafe_type_conversion_expression::do_get_tree(Translate_context* context) ...@@ -3603,10 +3603,11 @@ Unsafe_type_conversion_expression::do_get_tree(Translate_context* context)
else if (t->channel_type() != NULL) else if (t->channel_type() != NULL)
gcc_assert(et->channel_type() != NULL); gcc_assert(et->channel_type() != NULL);
else if (t->points_to() != NULL && t->points_to()->channel_type() != NULL) else if (t->points_to() != NULL && t->points_to()->channel_type() != NULL)
gcc_assert(et->points_to() != NULL gcc_assert((et->points_to() != NULL
&& et->points_to()->channel_type() != NULL); && et->points_to()->channel_type() != NULL)
|| et->is_nil_type());
else if (t->is_unsafe_pointer_type()) else if (t->is_unsafe_pointer_type())
gcc_assert(et->points_to() != NULL); gcc_assert(et->points_to() != NULL || et->is_nil_type());
else if (et->is_unsafe_pointer_type()) else if (et->is_unsafe_pointer_type())
gcc_assert(t->points_to() != NULL); gcc_assert(t->points_to() != NULL);
else if (t->interface_type() != NULL && !t->interface_type()->is_empty()) else if (t->interface_type() != NULL && !t->interface_type()->is_empty())
......
...@@ -381,3 +381,12 @@ Runtime::map_iteration_type() ...@@ -381,3 +381,12 @@ Runtime::map_iteration_type()
return Type::make_array_type(runtime_function_type(RFT_POINTER), iexpr); return Type::make_array_type(runtime_function_type(RFT_POINTER), iexpr);
} }
// Return the type used to pass a list of general channels to the
// select runtime function.
Type*
Runtime::chanptr_type()
{
return runtime_function_type(RFT_CHANPTR);
}
...@@ -30,15 +30,24 @@ class Runtime ...@@ -30,15 +30,24 @@ class Runtime
NUMBER_OF_FUNCTIONS NUMBER_OF_FUNCTIONS
}; };
// Make a call to a runtime function.
static Call_expression* static Call_expression*
make_call(Function, source_location, int, ...); make_call(Function, source_location, int, ...);
// Convert all the types used by runtime functions to the backend
// representation.
static void static void
convert_types(Gogo*); convert_types(Gogo*);
// Return the type used for iterations over maps.
static Type* static Type*
map_iteration_type(); map_iteration_type();
// Return the type used to pass a list of general channels to the
// select runtime function.
static Type*
chanptr_type();
private: private:
static Named_object* static Named_object*
runtime_declaration(Function); runtime_declaration(Function);
......
...@@ -678,9 +678,9 @@ class Select_clauses ...@@ -678,9 +678,9 @@ class Select_clauses
bool bool
may_fall_through() const; may_fall_through() const;
// Return a tree implementing the select statement. // Convert to the backend representation.
tree Bstatement*
get_tree(Translate_context*, Unnamed_label* break_label, source_location); get_backend(Translate_context*, Unnamed_label* break_label, source_location);
private: private:
// A single clause. // A single clause.
...@@ -749,8 +749,8 @@ class Select_clauses ...@@ -749,8 +749,8 @@ class Select_clauses
may_fall_through() const; may_fall_through() const;
// Return a tree for the statements to execute. // Return a tree for the statements to execute.
tree Bstatement*
get_statements_tree(Translate_context*); get_statements_backend(Translate_context*);
private: private:
// The channel. // The channel.
...@@ -778,8 +778,10 @@ class Select_clauses ...@@ -778,8 +778,10 @@ class Select_clauses
}; };
void void
add_clause_tree(Translate_context*, int, Select_clause*, Unnamed_label*, add_clause_backend(Translate_context*, source_location, int index,
tree*); int case_value, Select_clause*, Unnamed_label*,
std::vector<std::vector<Bexpression*> >* cases,
std::vector<Bstatement*>* clauses);
typedef std::vector<Select_clause> Clauses; typedef std::vector<Select_clause> Clauses;
......
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