From 4e4835ba77214f586080cf222fc9d161a28083c7 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 22 Mar 2011 21:53:22 +0100 Subject: [PATCH] codegen: Always call _finish() after yield Fixes bug 645606. --- codegen/valaccodemethodcallmodule.vala | 28 ++++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 87a083f51..f7abf5ebd 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -618,16 +618,13 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { } } - if (return_result_via_out_param) { - var temp_var = get_temp_variable (itype.get_return_type ()); - var temp_ref = get_variable_cexpression (temp_var.name); - - emit_temp_var (temp_var); - - out_arg_map.set (get_param_pos (-3), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, temp_ref)); + CCodeExpression out_param_ref = null; - ccode.add_expression (ccall_expr); - ccall_expr = temp_ref; + if (return_result_via_out_param) { + var out_param_var = get_temp_variable (itype.get_return_type ()); + out_param_ref = get_variable_cexpression (out_param_var.name); + emit_temp_var (out_param_var); + out_arg_map.set (get_param_pos (-3), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, out_param_ref)); } // append C arguments in the right order @@ -670,10 +667,6 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { } } - if (m != null && m.binding == MemberBinding.INSTANCE && m.returns_modified_pointer) { - ccall_expr = new CCodeAssignment (instance, ccall_expr); - } - if (expr.is_yield_expression) { // set state before calling async function to support immediate callbacks int state = next_coroutine_state++; @@ -684,6 +677,15 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { ccode.add_label ("_state_%d".printf (state)); } + if (return_result_via_out_param) { + ccode.add_expression (ccall_expr); + ccall_expr = out_param_ref; + } + + if (m != null && m.binding == MemberBinding.INSTANCE && m.returns_modified_pointer) { + ccall_expr = new CCodeAssignment (instance, ccall_expr); + } + if (m is ArrayResizeMethod) { // FIXME: size expression must not be evaluated twice at runtime (potential side effects) Iterator arg_it = expr.get_argument_list ().iterator (); -- 2.47.2