[vala/0.42] codegen: Use temp-var for MethodCall with out/ref arguments



commit c57c8f52636b608a1944797f3c2de0400edf7601
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Dec 26 20:34:39 2018 +0100

    codegen: Use temp-var for MethodCall with out/ref arguments
    
    Checking arguments of a MethodCall expression is required for varidic
    methods where checking parameters isn't sufficient. Doing this makes
    looking for out/ref parameters superfluous.
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/722

 codegen/valaccodemethodcallmodule.vala | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index b57f154cd..efbd61b27 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -827,7 +827,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                        } else if (m != null && m.get_attribute_bool ("CCode", "use_inplace", false)) {
                                set_cvalue (expr, ccall_expr);
                        } else if (!return_result_via_out_param
-                           && ((m != null && !has_ref_out_param (m)) || (deleg != null && !has_ref_out_param 
(deleg)))
+                           && !has_ref_out_argument (expr)
                            && (result_type is ValueType && !result_type.is_disposable ())) {
                                set_cvalue (expr, ccall_expr);
                        } else if (!return_result_via_out_param) {
@@ -922,9 +922,10 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                return to_string_func;
        }
 
-       bool has_ref_out_param (Callable c) {
-               foreach (var param in c.get_parameters ()) {
-                       if (param.direction != ParameterDirection.IN) {
+       bool has_ref_out_argument (MethodCall c) {
+               foreach (var arg in c.get_argument_list ()) {
+                       unowned UnaryExpression? unary = arg as UnaryExpression;
+                       if (unary != null && (unary.operator == UnaryOperator.OUT || unary.operator == 
UnaryOperator.REF)) {
                                return true;
                        }
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]