[vala/wip/effectfree: 16/43] Add actual_value_type to TargetValue



commit 4191a0a4337520ed2a04f189d423fdd3e06e2757
Author: Luca Bruno <lucabru src gnome org>
Date:   Fri Jul 1 20:19:50 2011 +0200

    Add actual_value_type to TargetValue

 codegen/valaccodeassignmentmodule.vala   |    9 +++++++--
 codegen/valaccodebasemodule.vala         |    4 ++++
 codegen/valaccodememberaccessmodule.vala |    6 +++---
 vala/valatargetvalue.vala                |    1 +
 4 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index 725fde0..b748868 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -268,11 +268,16 @@ 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)) {
+		var lvalue = get_field_cvalue (field, instance);
+		var type = lvalue.value_type;
+		if (lvalue.actual_value_type != null) {
+			type = lvalue.actual_value_type;
+		}
+		if (requires_destroy (type)) {
 			/* unref old value */
 			ccode.add_expression (destroy_field (field, instance));
 		}
 
-		store_value (get_field_cvalue (field, instance), value);
+		store_value (lvalue, value);
 	}
 }
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 45d69ae..febf6d7 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -2888,6 +2888,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 	// apply changes to both methods
 	public virtual CCodeExpression destroy_value (TargetValue value, bool is_macro_definition = false) {
 		var type = value.value_type;
+		if (value.actual_value_type != null) {
+			type = value.actual_value_type;
+		}
 		var cvar = get_cvalue_ (value);
 
 		if (type is DelegateType) {
@@ -5908,6 +5911,7 @@ public class Vala.GLibValue : TargetValue {
 
 	public GLibValue copy () {
 		var result = new GLibValue (value_type.copy (), cvalue);
+		result.actual_value_type = actual_value_type;
 		result.non_null = non_null;
 		result.ctype = ctype;
 
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index b652ecd..bf1c6e9 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -513,11 +513,11 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
 	/* Returns lvalue access to the given field */
 	public override TargetValue get_field_cvalue (Field field, TargetValue? instance) {
 		var value_type = field.variable_type.copy ();
-		if (instance != null) {
-			value_type = value_type.get_actual_type (instance.value_type, null, field);
-		}
 
 		var result = new GLibValue (value_type);
+		if (instance != null) {
+			result.actual_value_type = field.variable_type.get_actual_type (instance.value_type, null, field);
+		}
 		result.array_null_terminated = field.array_null_terminated;
 		if (field.has_array_length_cexpr) {
 			result.array_length_cexpr = new CCodeConstant (field.get_array_length_cexpr ());
diff --git a/vala/valatargetvalue.vala b/vala/valatargetvalue.vala
index b21483e..4cdbccc 100644
--- a/vala/valatargetvalue.vala
+++ b/vala/valatargetvalue.vala
@@ -22,6 +22,7 @@
 
 public abstract class Vala.TargetValue {
 	public DataType? value_type { get; set; }
+	public DataType? actual_value_type { get; set; }
 
 	protected TargetValue (DataType? value_type) {
 		this.value_type = value_type;



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