aboutsummaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/expressions.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/go/gofrontend/expressions.cc')
-rw-r--r--gcc/go/gofrontend/expressions.cc21
1 files changed, 8 insertions, 13 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 564c5b7..ee8af84 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -6321,6 +6321,7 @@ Bound_method_expression::create_thunk(Gogo* gogo, const Method* method,
Variable* cvar = new Variable(closure_type, NULL, false, false, false, loc);
cvar->set_is_used();
+ cvar->set_is_closure();
Named_object* cp = Named_object::make_variable("$closure", NULL, cvar);
new_no->func_value()->set_closure_var(cp);
@@ -9328,19 +9329,11 @@ Call_expression::do_get_backend(Translate_context* context)
fn_args[0] = first_arg->get_backend(context);
}
- if (!has_closure_arg)
- go_assert(closure == NULL);
+ Bexpression* bclosure = NULL;
+ if (has_closure_arg)
+ bclosure = closure->get_backend(context);
else
- {
- // Pass the closure argument by calling the function function
- // __go_set_closure. In the order_evaluations pass we have
- // ensured that if any parameters contain call expressions, they
- // will have been moved out to temporary variables.
- go_assert(closure != NULL);
- Expression* set_closure =
- Runtime::make_call(Runtime::SET_CLOSURE, location, 1, closure);
- fn = Expression::make_compound(set_closure, fn, location);
- }
+ go_assert(closure == NULL);
Bexpression* bfn = fn->get_backend(context);
@@ -9356,7 +9349,8 @@ Call_expression::do_get_backend(Translate_context* context)
bfn = gogo->backend()->convert_expression(bft, bfn, location);
}
- Bexpression* call = gogo->backend()->call_expression(bfn, fn_args, location);
+ Bexpression* call = gogo->backend()->call_expression(bfn, fn_args,
+ bclosure, location);
if (this->results_ != NULL)
{
@@ -11132,6 +11126,7 @@ Interface_field_reference_expression::create_thunk(Gogo* gogo,
Variable* cvar = new Variable(closure_type, NULL, false, false, false, loc);
cvar->set_is_used();
+ cvar->set_is_closure();
Named_object* cp = Named_object::make_variable("$closure", NULL, cvar);
new_no->func_value()->set_closure_var(cp);