[vala/wip/inline-destroy: 3/3] codegen: Turn destroy_value into an emit method with void result



commit 62a4fbd71b571bb5c28dd4378aa7090e29a9d8f1
Author: Luca Bruno <lucabru src gnome org>
Date:   Fri May 6 17:37:21 2011 +0200

    codegen: Turn destroy_value into an emit method with void result

 codegen/valaccodearraymodule.vala       |    9 ++-
 codegen/valaccodeassignmentmodule.vala  |    8 +-
 codegen/valaccodebasemodule.vala        |  112 +++++++++++++++----------------
 codegen/valaccodecontrolflowmodule.vala |    2 +-
 codegen/valaccodemethodcallmodule.vala  |    2 +-
 codegen/valagasyncmodule.vala           |    8 +-
 codegen/valagdbusclientmodule.vala      |    2 +-
 codegen/valagdbusservermodule.vala      |   10 ++--
 codegen/valagerrormodule.vala           |    2 +-
 codegen/valagobjectmodule.vala          |    2 +-
 10 files changed, 76 insertions(+), 81 deletions(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index 543dfb0..de5b020 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -452,14 +452,15 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 		}
 	}
 
-	public override CCodeExpression destroy_value (TargetValue value, bool is_wrapper = false) {
+	public override void destroy_value (TargetValue value, bool is_wrapper = false) {
 		var type = value.value_type;
 
 		if (type is ArrayType) {
 			var array_type = (ArrayType) type;
 
 			if (!array_type.fixed_length) {
-				return base.destroy_value (value, is_wrapper);
+				base.destroy_value (value, is_wrapper);
+				return;
 			}
 
 			requires_array_free = true;
@@ -471,9 +472,9 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
 			ccall.add_argument (new CCodeConstant ("%d".printf (array_type.length)));
 			ccall.add_argument (new CCodeCastExpression (get_destroy_func_expression (array_type.element_type), "GDestroyNotify"));
 
-			return ccall;
+			ccode.add_expression (ccall);
 		} else {
-			return base.destroy_value (value, is_wrapper);
+			base.destroy_value (value, is_wrapper);
 		}
 	}
 
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index 9ff0635..5464dd4 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -64,7 +64,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 				/* unref old value */
 				var value = ((GLibValue) assignment.left.target_value).copy ();
 				value.cvalue = lhs;
-				ccode.add_expression (destroy_value (value));
+				destroy_value (value);
 			}
 			
 			if (array && !variable.no_array_length && !variable.array_null_terminated) {
@@ -260,7 +260,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 	public override void store_local (LocalVariable local, TargetValue value, bool initializer) {
 		if (!initializer && requires_destroy (local.variable_type)) {
 			/* unref old value */
-			ccode.add_expression (destroy_local (local));
+			destroy_local (local);
 		}
 
 		store_variable (local, get_local_cvalue (local), value, initializer);
@@ -269,7 +269,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 	public override void store_parameter (Parameter param, TargetValue value) {
 		if (requires_destroy (param.variable_type)) {
 			/* unref old value */
-			ccode.add_expression (destroy_parameter (param));
+			destroy_parameter (param);
 		}
 
 		store_variable (param, get_parameter_cvalue (param), value, false);
@@ -278,7 +278,7 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
 	public override void store_field (Field field, TargetValue? instance, TargetValue value) {
 		if (requires_destroy (get_field_cvalue (field, instance).value_type)) {
 			/* unref old value */
-			ccode.add_expression (destroy_field (field, instance));
+			destroy_field (field, instance);
 		}
 
 		store_variable (field, get_field_cvalue (field, instance), value, false);
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index d3ca761..024cef1 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -985,7 +985,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 				}
 
 				foreach (LocalVariable local in temp_ref_vars) {
-					ccode.add_expression (destroy_local (local));
+					destroy_local (local);
 				}
 
 				temp_ref_vars.clear ();
@@ -995,7 +995,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			
 			if (requires_destroy (f.variable_type) && instance_finalize_context != null) {
 				push_context (instance_finalize_context);
-				ccode.add_expression (destroy_field (f, load_this_parameter ((TypeSymbol) f.parent_symbol)));
+				destroy_field (f, load_this_parameter ((TypeSymbol) f.parent_symbol));
 				pop_context ();
 			}
 		} else if (f.binding == MemberBinding.CLASS)  {
@@ -1023,7 +1023,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 				ccode.add_assignment (lhs, rhs);
 
 				foreach (LocalVariable local in temp_ref_vars) {
-					ccode.add_expression (destroy_local (local));
+					destroy_local (local);
 				}
 
 				temp_ref_vars.clear ();
@@ -1858,7 +1858,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 				if (in_constructor || (current_method != null && current_method.binding == MemberBinding.INSTANCE) ||
 				           (current_property_accessor != null && current_property_accessor.prop.binding == MemberBinding.INSTANCE)) {
 					var this_value = new GLibValue (get_data_type_for_symbol (current_type_symbol), new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data%d_".printf (block_id)), "self"));
-					ccode.add_expression (destroy_value (this_value));
+					destroy_value (this_value);
 				}
 			}
 
@@ -1873,7 +1873,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 							current_method.coroutine = false;
 						}
 
-						ccode.add_expression (destroy_local (local));
+						destroy_local (local);
 
 						if (old_coroutine) {
 							current_method.coroutine = true;
@@ -1900,7 +1900,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 								m.coroutine = false;
 							}
 
-							ccode.add_expression (destroy_parameter (param));
+							destroy_parameter (param);
 
 							if (old_coroutine) {
 								m.coroutine = true;
@@ -1918,7 +1918,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 					bool is_unowned_delegate = acc.value_parameter.variable_type is DelegateType && !acc.value_parameter.variable_type.value_owned;
 
 					if (requires_destroy (param_type) && !is_unowned_delegate) {
-						ccode.add_expression (destroy_parameter (acc.value_parameter));
+						destroy_parameter (acc.value_parameter);
 					}
 				}
 			}
@@ -1945,7 +1945,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			var local = local_vars[i];
 			local.active = false;
 			if (!local.unreachable && !local.floating && !local.captured && requires_destroy (local.variable_type)) {
-				ccode.add_expression (destroy_local (local));
+				destroy_local (local);
 			}
 		}
 
@@ -1953,7 +1953,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			var m = (Method) b.parent_symbol;
 			foreach (Parameter param in m.get_parameters ()) {
 				if (!param.captured && !param.ellipsis && requires_destroy (param.variable_type) && param.direction == ParameterDirection.IN) {
-					ccode.add_expression (destroy_parameter (param));
+					destroy_parameter (param);
 				} else if (param.direction == ParameterDirection.OUT && !m.coroutine) {
 					return_out_parameter (param);
 				}
@@ -2631,7 +2631,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
 				push_function (function);
 
-				ccode.add_expression (destroy_value (new GLibValue (type, new CCodeIdentifier ("var")), true));
+				destroy_value (new GLibValue (type, new CCodeIdentifier ("var")), true);
 
 				pop_function ();
 
@@ -2801,19 +2801,19 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		return null;
 	}
 
-	public CCodeExpression destroy_local (LocalVariable local) {
-		return destroy_value (get_local_cvalue (local));
+	public void destroy_local (LocalVariable local) {
+		destroy_value (get_local_cvalue (local));
 	}
 
-	public CCodeExpression destroy_parameter (Parameter param) {
-		return destroy_value (get_parameter_cvalue (param));
+	public void destroy_parameter (Parameter param) {
+		destroy_value (get_parameter_cvalue (param));
 	}
 
-	public CCodeExpression destroy_field (Field field, TargetValue? instance) {
-		return destroy_value (get_field_cvalue (field, instance));
+	public void destroy_field (Field field, TargetValue? instance) {
+		destroy_value (get_field_cvalue (field, instance));
 	}
 
-	public virtual CCodeExpression destroy_value (TargetValue value, bool is_wrapper = false) {
+	public virtual void destroy_value (TargetValue value, bool is_wrapper = false) {
 		var type = value.value_type;
 		var cvar = get_cvalue_ (value);
 
@@ -2847,7 +2847,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 				ref_value.cvalue = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("var"));
 				ref_value.delegate_target_cvalue = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("target"));
 				ref_value.delegate_target_destroy_notify_cvalue = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, new CCodeIdentifier ("target_destroy_notify"));
-				ccode.add_expression (destroy_value (ref_value, true));
+				destroy_value (ref_value, true);
 
 				pop_function ();
 
@@ -2856,12 +2856,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			}
 
 			var ccall = new CCodeFunctionCall (new CCodeIdentifier (free0_func));
-			ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cvar));
+			ccall.add_argument (new CCodeCastExpression (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cvar), type.get_cname () + "*"));
 			if (type is DelegateType) {
 				ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target_cvalue (value)));
 				ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_delegate_target_destroy_notify_cvalue (value)));
 			}
-			return ccall;
+			ccode.add_expression (ccall);
+			return;
 		}
 
 		if (type is DelegateType) {
@@ -2875,15 +2876,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			destroy_call.append_expression (ccall);
 			destroy_call.append_expression (new CCodeConstant ("NULL"));
 
-			var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, delegate_target_destroy_notify, new CCodeConstant ("NULL"));
-
-			var ccomma = new CCodeCommaExpression ();
-			ccomma.append_expression (new CCodeConditionalExpression (cisnull, new CCodeConstant ("NULL"), destroy_call));
-			ccomma.append_expression (new CCodeAssignment (cvar, new CCodeConstant ("NULL")));
-			ccomma.append_expression (new CCodeAssignment (delegate_target, new CCodeConstant ("NULL")));
-			ccomma.append_expression (new CCodeAssignment (delegate_target_destroy_notify, new CCodeConstant ("NULL")));
+			ccode.open_if (new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, delegate_target_destroy_notify, new CCodeConstant ("NULL")));
+			ccode.add_expression (destroy_call);
+			ccode.close ();
+			ccode.add_assignment (cvar, new CCodeConstant ("NULL"));
+			ccode.add_assignment (delegate_target, new CCodeConstant ("NULL"));
+			ccode.add_assignment (delegate_target_destroy_notify, new CCodeConstant ("NULL"));
 
-			return ccomma;
+			return;
 		}
 
 		var ccall = new CCodeFunctionCall (destroy_func);
@@ -2902,40 +2902,35 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 				// g_value_unset must not be called for already unset values
 				var cisvalid = new CCodeFunctionCall (new CCodeIdentifier ("G_IS_VALUE"));
 				cisvalid.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, cvar));
-
-				var ccomma = new CCodeCommaExpression ();
-				ccomma.append_expression (ccall);
-				ccomma.append_expression (new CCodeConstant ("NULL"));
-
-				return new CCodeConditionalExpression (cisvalid, ccomma, new CCodeConstant ("NULL"));
+				ccode.open_if (cisvalid);
+				ccode.add_expression (ccall);
+				ccode.close ();
 			} else {
-				return ccall;
+				ccode.add_expression (ccall);
 			}
+			return;
 		}
 
-		/* (foo == NULL ? NULL : foo = (unref (foo), NULL)) */
+		/* if (foo != NULL) { unref (foo); foo = NULL } */
 		
 		/* can be simplified to
-		 * foo = (unref (foo), NULL)
+		 * unref (foo); foo = NULL;
 		 * if foo is of static type non-null
 		 */
 
-		var cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, cvar, new CCodeConstant ("NULL"));
+		var cnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, cvar, new CCodeConstant ("NULL"));
 		if (type.type_parameter != null) {
 			if (!(current_type_symbol is Class) || current_class.is_compact) {
-				return new CCodeConstant ("NULL");
+				return;
 			}
 
 			// unref functions are optional for type parameters
-			var cunrefisnull = new CCodeBinaryExpression (CCodeBinaryOperator.EQUALITY, get_destroy_func_expression (type), new CCodeConstant ("NULL"));
-			cisnull = new CCodeBinaryExpression (CCodeBinaryOperator.OR, cisnull, cunrefisnull);
+			var cunrefnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, get_destroy_func_expression (type), new CCodeConstant ("NULL"));
+			cnotnull = new CCodeBinaryExpression (CCodeBinaryOperator.AND, cnotnull, cunrefnotnull);
 		}
 
 		ccall.add_argument (cvar);
 
-		/* set freed references to NULL to prevent further use */
-		var ccomma = new CCodeCommaExpression ();
-
 		if (context.profile == Profile.GOBJECT) {
 			if (type.data_type != null && !type.data_type.is_reference_counting () &&
 			    (type.data_type == gstringbuilder_type
@@ -2977,19 +2972,18 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 			}
 		}
 		
-		ccomma.append_expression (ccall);
-		ccomma.append_expression (new CCodeConstant ("NULL"));
-		
-		var cassign = new CCodeAssignment (cvar, ccomma);
-
 		// g_free (NULL) is allowed
 		bool uses_gfree = (type.data_type != null && !type.data_type.is_reference_counting () && type.data_type.get_free_function () == "g_free");
 		uses_gfree = uses_gfree || type is ArrayType;
-		if (uses_gfree) {
-			return cassign;
+		if (!uses_gfree) {
+			ccode.open_if (cnotnull);
+		}
+		ccode.add_expression (ccall);
+		/* set freed references to NULL to prevent further use */
+		ccode.add_assignment (cvar, new CCodeConstant ("NULL"));
+		if (!uses_gfree) {
+			ccode.close ();
 		}
-
-		return new CCodeConditionalExpression (cisnull, new CCodeConstant ("NULL"), cassign);
 	}
 	
 	public override void visit_end_full_expression (Expression expr) {
@@ -3021,7 +3015,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		}
 		
 		foreach (LocalVariable local in temp_ref_vars) {
-			ccode.add_expression (destroy_local (local));
+			destroy_local (local);
 		}
 
 		if (full_expr_var != null) {
@@ -3095,7 +3089,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		/* free temporary objects and handle errors */
 
 		foreach (LocalVariable local in temp_ref_vars) {
-			ccode.add_expression (destroy_local (local));
+			destroy_local (local);
 		}
 
 		if (stmt.tree_can_fail && stmt.expression.tree_can_fail) {
@@ -3114,7 +3108,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		for (int i = local_vars.size - 1; i >= 0; i--) {
 			var local = local_vars[i];
 			if (!local.unreachable && local.active && !local.floating && !local.captured && requires_destroy (local.variable_type)) {
-				ccode.add_expression (destroy_local (local));
+				destroy_local (local);
 			}
 		}
 
@@ -3155,7 +3149,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	private void append_param_free (Method m) {
 		foreach (Parameter param in m.get_parameters ()) {
 			if (!param.ellipsis && requires_destroy (param.variable_type) && param.direction == ParameterDirection.IN) {
-				ccode.add_expression (destroy_parameter (param));
+				destroy_parameter (param);
 			}
 		}
 	}
@@ -3195,7 +3189,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
 		if (param.variable_type.is_disposable ()){
 			ccode.add_else ();
-			ccode.add_expression (destroy_parameter (param));
+			destroy_parameter (param);
 		}
 		ccode.close ();
 
@@ -5631,7 +5625,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 		foreach (Field f in st.get_fields ()) {
 			if (f.binding == MemberBinding.INSTANCE) {
 				if (requires_destroy (f.variable_type)) {
-					ccode.add_expression (destroy_field (f, this_value));
+					destroy_field (f, this_value);
 				}
 			}
 		}
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index 6d9c37e..77396a0 100644
--- a/codegen/valaccodecontrolflowmodule.vala
+++ b/codegen/valaccodecontrolflowmodule.vala
@@ -341,7 +341,7 @@ public abstract class Vala.CCodeControlFlowModule : CCodeMethodModule {
 
 		foreach (LocalVariable local in stmt.get_local_variables ()) {
 			if (requires_destroy (local.variable_type)) {
-				ccode.add_expression (destroy_local (local));
+				destroy_local (local);
 			}
 		}
 
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index ce45393..e4382bc 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -771,7 +771,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
 
 			if (requires_destroy (arg.value_type)) {
 				// unref old value
-				ccode.add_expression (destroy_value (unary.inner.target_value));
+				destroy_value (unary.inner.target_value);
 			}
 
 			// assign new value
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index 8bcdfd8..dfae3ed 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -107,7 +107,7 @@ public class Vala.GAsyncModule : GSignalModule {
 					bool old_captured = param.captured;
 					param.captured = false;
 
-					ccode.add_expression (destroy_parameter (param));
+					destroy_parameter (param);
 
 					param.captured = old_captured;
 				}
@@ -117,7 +117,7 @@ public class Vala.GAsyncModule : GSignalModule {
 		if (requires_destroy (m.return_type)) {
 			/* this is very evil. */
 			var v = new LocalVariable (m.return_type, ".result");
-			ccode.add_expression (destroy_local (v));
+			destroy_local (v);
 		}
 
 		if (m.binding == MemberBinding.INSTANCE) {
@@ -125,7 +125,7 @@ public class Vala.GAsyncModule : GSignalModule {
 			this_type.value_owned = true;
 
 			if (requires_destroy (this_type)) {
-				ccode.add_expression (destroy_parameter (m.this_parameter));
+				destroy_parameter (m.this_parameter);
 			}
 		}
 
@@ -578,7 +578,7 @@ public class Vala.GAsyncModule : GSignalModule {
 		/* free temporary objects */
 
 		foreach (LocalVariable local in temp_ref_vars) {
-			ccode.add_expression (destroy_local (local));
+			destroy_local (local);
 		}
 
 		temp_ref_vars.clear ();
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 75fea19..4ae41b9 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -404,7 +404,7 @@ public class Vala.GDBusClientModule : GDBusModule {
 			if (requires_destroy (owned_type)) {
 				// keep local alive (symbol_reference is weak)
 				var local = new LocalVariable (owned_type, param.name);
-				ccode.add_expression (destroy_local (local));
+				destroy_local (local);
 			}
 		}
 
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index 8c1507d..398d537 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -315,7 +315,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 					if (requires_destroy (m.return_type)) {
 						// keep local alive (symbol_reference is weak)
 						var local = new LocalVariable (m.return_type, ".result");
-						ccode.add_expression (destroy_local (local));
+						destroy_local (local);
 					}
 				} else {
 					ccode.add_declaration (m.return_type.get_cname (), new CCodeVariableDeclarator ("result"));
@@ -334,7 +334,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 					if (requires_destroy (m.return_type)) {
 						// keep local alive (symbol_reference is weak)
 						var local = new LocalVariable (m.return_type, ".result");
-						ccode.add_expression (destroy_local (local));
+						destroy_local (local);
 					}
 				}
 			}
@@ -380,7 +380,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 				if (requires_destroy (owned_type)) {
 					// keep local alive (symbol_reference is weak)
 					var local = new LocalVariable (owned_type, get_variable_cname (param.name));
-					ccode.add_expression (destroy_local (local));
+					destroy_local (local);
 				}
 			}
 		}
@@ -523,7 +523,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 		if (requires_destroy (prop.get_accessor.value_type)) {
 			// keep local alive (symbol_reference is weak)
 			var local = new LocalVariable (prop.get_accessor.value_type, ".result");
-			ccode.add_expression (destroy_local (local));
+			destroy_local (local);
 		}
 
 		ccode.add_return (new CCodeIdentifier ("_reply"));
@@ -578,7 +578,7 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 		if (requires_destroy (owned_type)) {
 			// keep local alive (symbol_reference is weak)
 			var local = new LocalVariable (owned_type, "value");
-			ccode.add_expression (destroy_local (local));
+			destroy_local (local);
 		}
 
 		pop_function ();
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index 7331280..40698eb 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -104,7 +104,7 @@ public class Vala.GErrorModule : CCodeDelegateModule {
 
 		if (current_method is CreationMethod && current_method.parent_symbol is Class) {
 			var cl = (Class) current_method.parent_symbol;
-			ccode.add_expression (destroy_value (new GLibValue (new ObjectType (cl), new CCodeIdentifier ("self"))));
+			destroy_value (new GLibValue (new ObjectType (cl), new CCodeIdentifier ("self")));
 			ccode.add_return (new CCodeConstant ("NULL"));
 		} else if (is_in_coroutine ()) {
 			ccode.add_return (new CCodeConstant ("FALSE"));
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index ad50455..51a2b82 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -233,7 +233,7 @@ public class Vala.GObjectModule : GTypeModule {
 				ccode.add_expression (csetcall);
 
 				if (requires_destroy (prop.get_accessor.value_type)) {
-					ccode.add_expression (destroy_value (new GLibValue (prop.get_accessor.value_type, new CCodeIdentifier ("boxed"))));
+					destroy_value (new GLibValue (prop.get_accessor.value_type, new CCodeIdentifier ("boxed")));
 				}
 				ccode.close ();
 			} else {



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