From: Rico Tzschichholz Date: Tue, 4 May 2021 07:21:10 +0000 (+0200) Subject: codegen: More use of get_this_{class|interface}_cexpression() X-Git-Tag: 0.53.1~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8b8340a4392bdff429b99a465acd96a9630ee6b8;p=thirdparty%2Fvala.git codegen: More use of get_this_{class|interface}_cexpression() --- diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala index 944aa3ea8..8f74e0d34 100644 --- a/codegen/valaccodememberaccessmodule.vala +++ b/codegen/valaccodememberaccessmodule.vala @@ -66,18 +66,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule { if (m.base_method != null) { if (get_ccode_no_wrapper (m.base_method)) { - var base_class = (Class) m.base_method.parent_symbol; + unowned Class base_class = (Class) m.base_method.parent_symbol; if (!base_class.is_compact) { - CCodeFunctionCall vclass; - if (base_class.external_package) { - vclass = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_INSTANCE_GET_CLASS")); - vclass.add_argument (pub_inst); - vclass.add_argument (new CCodeIdentifier (get_ccode_type_id (base_class))); - vclass.add_argument (new CCodeIdentifier (get_ccode_type_name (base_class))); - } else { - vclass = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_class))); - vclass.add_argument (pub_inst); - } + var vclass = get_this_class_cexpression (base_class, expr.inner.target_value); set_cvalue (expr, new CCodeMemberAccess.pointer (vclass, get_ccode_vfunc_name (m))); } else { set_cvalue (expr, new CCodeMemberAccess.pointer (pub_inst, get_ccode_vfunc_name (m))); @@ -87,17 +78,8 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule { } } else if (m.base_interface_method != null) { if (get_ccode_no_wrapper (m.base_interface_method)) { - var base_iface = (Interface) m.base_interface_method.parent_symbol; - CCodeFunctionCall vclass; - if (base_iface.external_package) { - vclass = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_INSTANCE_GET_INTERFACE")); - vclass.add_argument (pub_inst); - vclass.add_argument (new CCodeIdentifier (get_ccode_type_id (base_iface))); - vclass.add_argument (new CCodeIdentifier (get_ccode_type_name (base_iface))); - } else { - vclass = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_iface))); - vclass.add_argument (pub_inst); - } + unowned Interface base_iface = (Interface) m.base_interface_method.parent_symbol; + var vclass = get_this_interface_cexpression (base_iface, expr.inner.target_value); set_cvalue (expr, new CCodeMemberAccess.pointer (vclass, get_ccode_vfunc_name (m))); } else { set_cvalue (expr, new CCodeIdentifier (get_ccode_name (m.base_interface_method))); diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 399a05721..95b4618c6 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -114,31 +114,14 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule { var inner_ma = (MemberAccess) ma.inner; instance_value = inner_ma.inner.target_value; } - var pub_inst = get_cvalue_ (instance_value); - CCodeFunctionCall? vcast = null; + CCodeExpression? vcast = null; if (m.parent_symbol is Class) { unowned Class base_class = (Class) m.parent_symbol; - if (base_class.external_package) { - vcast = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_INSTANCE_GET_CLASS")); - vcast.add_argument (pub_inst); - vcast.add_argument (new CCodeIdentifier (get_ccode_type_id (base_class))); - vcast.add_argument (new CCodeIdentifier (get_ccode_type_name (base_class))); - } else { - vcast = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_class))); - vcast.add_argument (pub_inst); - } + vcast = get_this_class_cexpression (base_class, instance_value); } else if (m.parent_symbol is Interface) { unowned Interface base_iface = (Interface) m.parent_symbol; - if (base_iface.external_package) { - vcast = new CCodeFunctionCall (new CCodeIdentifier ("G_TYPE_INSTANCE_GET_INTERFACE")); - vcast.add_argument (pub_inst); - vcast.add_argument (new CCodeIdentifier (get_ccode_type_id (base_iface))); - vcast.add_argument (new CCodeIdentifier (get_ccode_type_name (base_iface))); - } else { - vcast = new CCodeFunctionCall (new CCodeIdentifier (get_ccode_type_get_function (base_iface))); - vcast.add_argument (pub_inst); - } + vcast = get_this_interface_cexpression (base_iface, instance_value); } if (vcast != null) { async_call.call = new CCodeMemberAccess.pointer (vcast, get_ccode_vfunc_name (m));