summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Bruno <lucabru@src.gnome.org>2011-07-01 20:19:50 +0200
committerLuca Bruno <lucabru@src.gnome.org>2011-07-06 22:32:28 +0200
commit6a9d3fbc2e0dedc9c86716ab3283ffba9c0bb6b4 (patch)
tree796a58e74bc769ceca198d24295c3d1184e6cc56
parent851b2802354ead100cfe366101be597dbb13e1f1 (diff)
downloadvala-6a9d3fbc2e0dedc9c86716ab3283ffba9c0bb6b4.tar.gz
Add actual_value_type to TargetValue
-rw-r--r--codegen/valaccodeassignmentmodule.vala9
-rw-r--r--codegen/valaccodebasemodule.vala4
-rw-r--r--codegen/valaccodememberaccessmodule.vala6
-rw-r--r--vala/valatargetvalue.vala1
4 files changed, 15 insertions, 5 deletions
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index 725fde0f3..b74886861 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 c25f0bebe..ae8f07f44 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) {
@@ -5910,6 +5913,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 8ecd8419e..2b594db9a 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -514,11 +514,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 b21483ea0..4cdbccc27 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;