From: Rico Tzschichholz Date: Thu, 10 Nov 2016 09:24:42 +0000 (+0100) Subject: codegen: Make get_temp_variable() default to init=false X-Git-Tag: 0.35.1~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=971f474f105bd1bbee7144eb4183635084c96821;p=thirdparty%2Fvala.git codegen: Make get_temp_variable() default to init=false --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 3921b0e68..764b4d16f 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -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)); diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala index 65c71ae79..fb8a156f1 100644 --- a/codegen/valaccodememberaccessmodule.vala +++ b/codegen/valaccodememberaccessmodule.vala @@ -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 { diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 7786d1bf9..31e1839e6 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -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);