diff options
Diffstat (limited to 'codegen/valaccodememberaccessmodule.vala')
-rw-r--r-- | codegen/valaccodememberaccessmodule.vala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala index 5f5a50d1b..110341aac 100644 --- a/codegen/valaccodememberaccessmodule.vala +++ b/codegen/valaccodememberaccessmodule.vala @@ -90,6 +90,29 @@ public class Vala.CCodeMemberAccessModule : CCodeControlFlowModule { } else { set_cvalue (expr, new CCodeIdentifier (m.get_cname ())); } + + if (expr.target_type is DelegateType) { + if (m.binding == MemberBinding.STATIC) { + set_delegate_target (expr, new CCodeConstant ("NULL")); + } else if (m.is_async_callback) { + if (current_method.closure) { + var block = ((Method) m.parent_symbol).body; + set_delegate_target (expr, new CCodeMemberAccess.pointer (get_variable_cexpression ("_data%d_".printf (get_block_id (block))), "_async_data_")); + } else { + set_delegate_target (expr, new CCodeIdentifier ("data")); + } + } else { + var delegate_target = (CCodeExpression) get_ccodenode (expr.inner); + var delegate_type = expr.target_type as DelegateType; + if ((expr.value_type.value_owned || (delegate_type != null && delegate_type.is_called_once)) && expr.inner.value_type.data_type != null && expr.inner.value_type.data_type.is_reference_counting ()) { + var ref_call = new CCodeFunctionCall (get_dup_func_expression (expr.inner.value_type, expr.source_reference)); + ref_call.add_argument (delegate_target); + delegate_target = ref_call; + set_delegate_target_destroy_notify (expr, get_destroy_func_expression (expr.inner.value_type)); + } + set_delegate_target (expr, delegate_target); + } + } } else if (expr.symbol_reference is ArrayLengthField) { if (expr.value_type is ArrayType && !(expr.parent_node is ElementAccess)) { Report.error (expr.source_reference, "unsupported use of length field of multi-dimensional array"); |