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



commit 1d60b3db1ecd5de1d3edbd537520cc3151dc5e66
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 251b1a8..118d99f 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2770,8 +2770,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 5a1329d..ad6155f 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -677,6 +677,8 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 			return get_local_cvalue ((LocalVariable) variable, not_in_coroutine);
 		} else if (variable is Parameter) {
 			return get_parameter_cvalue ((Parameter) variable, not_in_coroutine);
+		} 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]