Commit 56061d44 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Simplify some code around get_ccode_delegate_target() invocations

parent faf85dc2
......@@ -1101,7 +1101,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
decl_space.add_type_member_declaration (cdecl);
}
}
} else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
} else if (get_ccode_delegate_target (f)) {
var delegate_type = (DelegateType) f.variable_type;
if (delegate_type.delegate_symbol.has_target) {
// create field to store delegate target
......@@ -1189,7 +1189,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var rhs_array_len = get_array_length_cvalue (field_value, 1);
ccode.add_assignment (lhs_array_size, rhs_array_len);
}
} else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
} else if (get_ccode_delegate_target (f)) {
var delegate_type = (DelegateType) f.variable_type;
if (delegate_type.delegate_symbol.has_target) {
var field_value = get_field_cvalue (f, load_this_parameter ((TypeSymbol) f.parent_symbol));
......@@ -1313,7 +1313,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
cfile.add_type_member_declaration (cdecl);
}
}
} else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
} else if (get_ccode_delegate_target (f)) {
var delegate_type = (DelegateType) f.variable_type;
if (delegate_type.delegate_symbol.has_target) {
// create field to store delegate target
......
......@@ -565,7 +565,6 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
result.ctype = get_ccode_type (field);
var array_type = result.value_type as ArrayType;
var delegate_type = result.value_type as DelegateType;
if (field.binding == MemberBinding.INSTANCE) {
CCodeExpression pub_inst = null;
......@@ -629,7 +628,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
set_array_size_cvalue (result, new CCodeMemberAccess (inst, size_cname));
}
}
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target && get_ccode_delegate_target (field)) {
} else if (get_ccode_delegate_target (field)) {
string target_cname = get_ccode_delegate_target_name (field);
string target_destroy_notify_cname = get_ccode_delegate_target_destroy_notify_name (field);
......@@ -695,7 +694,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
if (array_type.rank == 1 && field.is_internal_symbol ()) {
set_array_size_cvalue (result, new CCodeIdentifier (get_array_size_cname (get_ccode_name (field))));
}
} else if (delegate_type != null && delegate_type.delegate_symbol.has_target && get_ccode_delegate_target (field)) {
} else if (get_ccode_delegate_target (field)) {
result.delegate_target_cvalue = new CCodeIdentifier (get_ccode_delegate_target_name (field));
if (result.value_type.is_disposable ()) {
result.delegate_target_destroy_notify_cvalue = new CCodeIdentifier (get_ccode_delegate_target_destroy_notify_name (field));
......@@ -744,7 +743,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
}
result.array_size_cvalue = null;
} else if (delegate_type != null) {
if (!delegate_type.delegate_symbol.has_target || !get_ccode_delegate_target (variable)) {
if (!get_ccode_delegate_target (variable)) {
result.delegate_target_cvalue = new CCodeConstant ("NULL");
}
......
......@@ -101,7 +101,7 @@ public abstract class Vala.CCodeStructModule : CCodeBaseModule {
instance_struct.add_field (length_ctype, get_array_size_cname (get_ccode_name (f)));
}
}
} else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
} else if (get_ccode_delegate_target (f)) {
var delegate_type = (DelegateType) f.variable_type;
if (delegate_type.delegate_symbol.has_target) {
// create field to store delegate target
......
......@@ -432,7 +432,7 @@ public class Vala.GTypeModule : GErrorModule {
instance_struct.add_field (length_ctype, get_array_size_cname (get_ccode_name (f)));
}
}
} else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
} else if (get_ccode_delegate_target (f)) {
var delegate_type = (DelegateType) f.variable_type;
if (delegate_type.delegate_symbol.has_target) {
// create field to store delegate target
......@@ -534,7 +534,7 @@ public class Vala.GTypeModule : GErrorModule {
instance_priv_struct.add_field (length_ctype, get_array_size_cname (get_ccode_name (f)));
}
}
} else if (f.variable_type is DelegateType && get_ccode_delegate_target (f)) {
} else if (get_ccode_delegate_target (f)) {
var delegate_type = (DelegateType) f.variable_type;
if (delegate_type.delegate_symbol.has_target) {
// create field to store delegate target
......
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