diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-05-05 19:05:59 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-05-05 19:05:59 +0000 |
commit | 535d5152fedfcf2c404a84d2655942a4eb86734f (patch) | |
tree | 46982fde598833169f721a2dd7cf05daaa13432a /gcc/go/gofrontend | |
parent | 36d06319953f53c821094eadd2310cb2dd3460fe (diff) | |
download | gcc-535d5152fedfcf2c404a84d2655942a4eb86734f.zip gcc-535d5152fedfcf2c404a84d2655942a4eb86734f.tar.gz gcc-535d5152fedfcf2c404a84d2655942a4eb86734f.tar.bz2 |
compiler: Use backend interface for sink expressions.
From-SVN: r210078
Diffstat (limited to 'gcc/go/gofrontend')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index c52b396..a4f959d 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -931,7 +931,7 @@ class Sink_expression : public Expression public: Sink_expression(Location location) : Expression(EXPRESSION_SINK, location), - type_(NULL), var_(NULL_TREE) + type_(NULL), bvar_(NULL) { } protected: @@ -959,7 +959,7 @@ class Sink_expression : public Expression // The type of this sink variable. Type* type_; // The temporary variable we generate. - tree var_; + Bvariable* bvar_; }; // Return the type of a sink expression. @@ -987,13 +987,24 @@ Sink_expression::do_determine_type(const Type_context* context) tree Sink_expression::do_get_tree(Translate_context* context) { - if (this->var_ == NULL_TREE) + Location loc = this->location(); + Gogo* gogo = context->gogo(); + if (this->bvar_ == NULL) { go_assert(this->type_ != NULL && !this->type_->is_sink_type()); + Named_object* fn = context->function(); + go_assert(fn != NULL); + Bfunction* fn_ctx = fn->func_value()->get_or_make_decl(gogo, fn); Btype* bt = this->type_->get_backend(context->gogo()); - this->var_ = create_tmp_var(type_to_tree(bt), "blank"); + Bstatement* decl; + this->bvar_ = + gogo->backend()->temporary_variable(fn_ctx, context->bblock(), bt, NULL, + false, loc, &decl); + Bexpression* var_ref = gogo->backend()->var_expression(this->bvar_, loc); + var_ref = gogo->backend()->compound_expression(decl, var_ref, loc); + return expr_to_tree(var_ref); } - return this->var_; + return expr_to_tree(gogo->backend()->var_expression(this->bvar_, loc)); } // Ast dump for sink expression. |