]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Make get_temp_variable() default to init=false
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 10 Nov 2016 09:24:42 +0000 (10:24 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 10 Nov 2016 09:24:42 +0000 (10:24 +0100)
codegen/valaccodebasemodule.vala
codegen/valaccodememberaccessmodule.vala
codegen/valaccodemethodcallmodule.vala

index 3921b0e68b3408cc0c9c54db5e600cfbdbd44939..764b4d16f5baafc929bf4a7978c8a068f39044a6 100644 (file)
@@ -2570,7 +2570,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                return result;
        }
 
-       public LocalVariable get_temp_variable (DataType type, bool value_owned = true, CodeNode? node_reference = null, bool init = true) {
+       public LocalVariable get_temp_variable (DataType type, bool value_owned = true, CodeNode? node_reference = null, bool init = false) {
                var var_type = type.copy ();
                var_type.value_owned = value_owned;
                var local = new LocalVariable (var_type, "_tmp%d_".printf (next_temp_var_id));
index 65c71ae79521ec3bbec5deffef3f91e5ce690583..fb8a156f191b4115c6ef9102ab05004c492aebb1 100644 (file)
@@ -224,13 +224,14 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                                        ccall.add_argument (pub_inst);
                                }
 
-                               var temp_value = (GLibValue) create_temp_value (prop.get_accessor.value_type, false, expr);
+                               bool prop_is_real_non_null_struct_type = prop.property_type.is_real_non_null_struct_type ();
+                               var temp_value = (GLibValue) create_temp_value (prop.get_accessor.value_type, prop_is_real_non_null_struct_type, expr);
                                expr.target_value = load_temp_value (temp_value);
                                var ctemp = get_cvalue_ (temp_value);
 
                                // Property access to real struct types is handled differently
                                // The value is returned by out parameter
-                               if (prop.property_type.is_real_non_null_struct_type ()) {
+                               if (prop_is_real_non_null_struct_type) {
                                        ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
                                        ccode.add_expression (ccall);
                                } else {
index 7786d1bf9485a731d0df21b5cb4d36665fb41b7c..31e1839e67d8b427a3a5b28079c56ca30ac32cf1 100644 (file)
@@ -402,7 +402,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                        } else {
                                                arg.target_value = null;
 
-                                               var temp_var = get_temp_variable (param.variable_type, param.variable_type.value_owned);
+                                               var temp_var = get_temp_variable (param.variable_type, param.variable_type.value_owned, null, true);
                                                emit_temp_var (temp_var);
                                                set_cvalue (arg, get_variable_cexpression (temp_var.name));
                                                arg.target_value.value_type = arg.target_type;
@@ -425,12 +425,12 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                                        var deleg_type = (DelegateType) param.variable_type;
                                                        var d = deleg_type.delegate_symbol;
                                                        if (d.has_target) {
-                                                               temp_var = get_temp_variable (new PointerType (new VoidType ()));
+                                                               temp_var = get_temp_variable (new PointerType (new VoidType ()), true, null, true);
                                                                emit_temp_var (temp_var);
                                                                set_delegate_target (arg, get_variable_cexpression (temp_var.name));
                                                                carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param)), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target (arg)));
                                                                if (deleg_type.is_disposable ()) {
-                                                                       temp_var = get_temp_variable (gdestroynotify_type);
+                                                                       temp_var = get_temp_variable (gdestroynotify_type, true, null, true);
                                                                        emit_temp_var (temp_var);
                                                                        set_delegate_target_destroy_notify (arg, get_variable_cexpression (temp_var.name));
                                                                        carg_map.set (get_param_pos (get_ccode_delegate_target_pos (param) + 0.01), new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target_destroy_notify (arg)));
@@ -644,7 +644,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                CCodeExpression out_param_ref = null;
 
                if (return_result_via_out_param) {
-                       var out_param_var = get_temp_variable (itype.get_return_type ());
+                       var out_param_var = get_temp_variable (itype.get_return_type (), true, null, true);
                        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));
@@ -790,7 +790,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                        if (m != null && m.get_format_arg_index () >= 0) {
                                set_cvalue (expr, ccall_expr);
                        } else if (!return_result_via_out_param) {
-                               var temp_var = get_temp_variable (result_type, result_type.value_owned);
+                               var temp_var = get_temp_variable (result_type, result_type.value_owned, null, false);
                                var temp_ref = get_variable_cexpression (temp_var.name);
 
                                emit_temp_var (temp_var);