Commit 6a9d3fbc authored by Luca Bruno's avatar Luca Bruno

Add actual_value_type to TargetValue

parent 851b2802
......@@ -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);
}
}
......@@ -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;
......
......@@ -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 ());
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment