Fix closing over raw function pointers

This commit is contained in:
Nathan Braswell
2017-06-13 00:40:29 -04:00
parent 754ff41226
commit 6f659ece49

View File

@@ -645,10 +645,14 @@ obj c_generator (Object) {
ref_pre += "(*"
ref_post += ")"
}
if (!func_type->is_raw && (!is_function(node->function_call.func) || node->function_call.func->function.closed_variables.size())) {
if (!is_function(node->function_call.func) || node->function_call.func->function.closed_variables.size()) {
// not function, so we must be an identifier or function call return or something
// and also is closure style, so need special call
if (!dot_style_method_call) {
// if is a raw function pointer closed over (or something)
if (func_type->is_raw) {
func_name = generate(node->function_call.func, enclosing_object, enclosing_func, false).one_string()
} else {
// lambda
if (pre_call == "" && (!func_return_type->is_void() || func_return_type->indirection)) {
var temp_ident = ast_identifier_ptr(string("temporary_return") + get_id(), func_return_type, null<ast_node>())
@@ -678,6 +682,7 @@ obj c_generator (Object) {
return call_string
}
}
}
if (pre_call != "") {
call_string.pre += pre_call + " = " + func_name + "(" + call_string.value + ");"
call_string.value = pre_call