[vala/emit-let: 3/4] codegen: Use get_field_cvalue to unref fields.



commit 9e3b41f6fe6e5886b990b4626aabd5ff3db3b6c4
Author: Luca Bruno <lucabru src gnome org>
Date:   Tue Jan 18 16:49:03 2011 +0100

    codegen: Use get_field_cvalue to unref fields.

 codegen/valaccodebasemodule.vala         |    9 +++++++--
 codegen/valaccodememberaccessmodule.vala |    2 ++
 2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index cde070e..e9c2326 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2794,8 +2794,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	}
 
 	public CCodeExpression get_unref_expression (CCodeExpression cvar, DataType type, Expression? expr, bool is_macro_definition = false) {
-		if (expr != null && (expr.symbol_reference is LocalVariable || expr.symbol_reference is Parameter)) {
-			return get_unref_expression_ ((Variable) expr.symbol_reference);
+		if (expr != null && (expr.symbol_reference is LocalVariable || expr.symbol_reference is Parameter || expr.symbol_reference is Field)) {
+			TargetValue inner = null;
+			var ma = expr as MemberAccess;
+			if (ma != null && ma.inner != null) {
+				inner = ma.inner.target_value;
+			}
+			return get_unref_expression_ ((Variable) expr.symbol_reference, inner);
 		}
 		var value = new GLibValue (type, cvar);
 		if (expr != null && expr.target_value != null) {
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 2cc4a0c..f3f9ccd 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -672,6 +672,8 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			return get_local_cvalue ((LocalVariable) variable);
 		} else if (variable is Parameter) {
 			return get_parameter_cvalue ((Parameter) variable);
+		} else if (variable is Field) {
+			return get_field_cvalue ((Field) variable, inner);
 		} else {
 			assert_not_reached ();
 		}



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