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>
* Make-lang.in (go/gogo-tree.o): depend on $(GO_RUNTIME_H).
......
......@@ -167,6 +167,10 @@ class Gcc_backend : public Backend
// Statements.
Bstatement*
error_statement()
{ return this->make_statement(error_mark_node); }
Bstatement*
expression_statement(Bexpression*);
Bstatement*
......
......@@ -107,6 +107,12 @@ class Backend
// 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.
virtual Bstatement*
expression_statement(Bexpression*) = 0;
......
......@@ -3603,10 +3603,11 @@ Unsafe_type_conversion_expression::do_get_tree(Translate_context* context)
else if (t->channel_type() != NULL)
gcc_assert(et->channel_type() != NULL);
else if (t->points_to() != NULL && t->points_to()->channel_type() != NULL)
gcc_assert(et->points_to() != NULL
&& et->points_to()->channel_type() != NULL);
gcc_assert((et->points_to() != NULL
&& et->points_to()->channel_type() != NULL)
|| et->is_nil_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())
gcc_assert(t->points_to() != NULL);
else if (t->interface_type() != NULL && !t->interface_type()->is_empty())
......
......@@ -381,3 +381,12 @@ Runtime::map_iteration_type()
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
NUMBER_OF_FUNCTIONS
};
// Make a call to a runtime function.
static Call_expression*
make_call(Function, source_location, int, ...);
// Convert all the types used by runtime functions to the backend
// representation.
static void
convert_types(Gogo*);
// Return the type used for iterations over maps.
static 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:
static Named_object*
runtime_declaration(Function);
......
......@@ -678,9 +678,9 @@ class Select_clauses
bool
may_fall_through() const;
// Return a tree implementing the select statement.
tree
get_tree(Translate_context*, Unnamed_label* break_label, source_location);
// Convert to the backend representation.
Bstatement*
get_backend(Translate_context*, Unnamed_label* break_label, source_location);
private:
// A single clause.
......@@ -749,8 +749,8 @@ class Select_clauses
may_fall_through() const;
// Return a tree for the statements to execute.
tree
get_statements_tree(Translate_context*);
Bstatement*
get_statements_backend(Translate_context*);
private:
// The channel.
......@@ -778,8 +778,10 @@ class Select_clauses
};
void
add_clause_tree(Translate_context*, int, Select_clause*, Unnamed_label*,
tree*);
add_clause_backend(Translate_context*, source_location, int index,
int case_value, Select_clause*, Unnamed_label*,
std::vector<std::vector<Bexpression*> >* cases,
std::vector<Bstatement*>* 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