store_value (get_parameter_cvalue (param), value, source_reference);
}
- public override void store_field (Field field, TargetValue? instance, TargetValue value, SourceReference? source_reference = null) {
+ public override void store_field (Field field, TargetValue? instance, TargetValue value, bool initializer, SourceReference? source_reference = null) {
var lvalue = get_field_cvalue (field, instance);
var type = lvalue.value_type;
if (lvalue.actual_value_type != null) {
type = lvalue.actual_value_type;
}
- if ((!(field.variable_type is DelegateType) || get_ccode_delegate_target (field)) && requires_destroy (type)) {
+ if (!initializer && (!(field.variable_type is DelegateType) || get_ccode_delegate_target (field)) && requires_destroy (type)) {
/* unref old value */
ccode.add_expression (destroy_field (field, instance));
}
+ if (initializer && instance != null && get_ccode_delegate_target (field) && get_delegate_target_cvalue (value) == null) {
+ unowned DelegateType delegate_type = field.variable_type as DelegateType;
+ if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
+ ((GLibValue) value).delegate_target_cvalue = get_cvalue_ (instance);
+ }
+ }
store_value (lvalue, value, source_reference);
}
}
}
- store_field (field, instance, expr.target_value, expr.source_reference);
+ store_field (field, instance, expr.target_value, false, expr.source_reference);
}
list.target_value = instance;
var f = (Field) init.symbol_reference;
var instance_target_type = SemanticAnalyzer.get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
var typed_inst = transform_value (new GLibValue (expr.type_reference, instance, true), instance_target_type, init);
- store_field (f, typed_inst, init.initializer.target_value, init.source_reference);
+ store_field (f, typed_inst, init.initializer.target_value, false, init.source_reference);
var cl = f.parent_symbol as Class;
if (cl != null) {
continue;
}
}
- store_field (f, dest_struct, value);
+ store_field (f, dest_struct, value, false);
}
}
continue;
}
}
- store_field (f, dest_struct, value);
+ store_field (f, dest_struct, value, false);
}
}
} else if (param != null) {
codegen.store_parameter (param, new_value, false, source_reference);
} else if (field != null) {
- codegen.store_field (field, instance && ma.inner != null ? ma.inner.target_value : null, new_value, source_reference);
+ codegen.store_field (field, instance && ma.inner != null ? ma.inner.target_value : null, new_value, false, source_reference);
}
if (!(parent_node is ExpressionStatement)) {
public abstract TargetValue load_field (Field field, TargetValue? instance, Expression? expr = null);
- public abstract void store_field (Field field, TargetValue? instance, TargetValue value, SourceReference? source_reference = null);
+ public abstract void store_field (Field field, TargetValue? instance, TargetValue value, bool initializer, SourceReference? source_reference = null);
}