]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Don't call get_ccode_finish_instance() with non-async methods
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 4 Jun 2020 06:10:21 +0000 (08:10 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 22 Jun 2020 08:19:59 +0000 (10:19 +0200)
and restrict evaluation of CCode.finish_* attributes to async methods only

codegen/valaccode.vala
codegen/valaccodebasemodule.vala
codegen/valaccodemethodcallmodule.vala

index a9b93ce18e438cfc6667098d7d27f8f6da90d666..75d36b67a6cd9f2744ed7a101d03245aed083c05 100644 (file)
@@ -220,8 +220,9 @@ namespace Vala {
                return get_ccode_free_function (sym) == "g_boxed_free";
        }
 
-       public static bool get_ccode_finish_instance (CodeNode node) {
-               return get_ccode_attribute (node).finish_instance;
+       public static bool get_ccode_finish_instance (Method m) {
+               assert (m.coroutine);
+               return get_ccode_attribute (m).finish_instance;
        }
 
        public static string get_ccode_type_id (CodeNode node) {
@@ -412,14 +413,17 @@ namespace Vala {
        }
 
        public static string get_ccode_finish_name (Method m) {
+               assert (m.coroutine);
                return get_ccode_attribute(m).finish_name;
        }
 
        public static string get_ccode_finish_vfunc_name (Method m) {
+               assert (m.coroutine);
                return get_ccode_attribute(m).finish_vfunc_name;
        }
 
        public static string get_ccode_finish_real_name (Method m) {
+               assert (m.coroutine);
                return get_ccode_attribute(m).finish_real_name;
        }
 
index 696e82cd3670d764a4fc7b5d86748d102613df5f..0cee17e8fb09077d2926b6fa8f35118a7bbb58c8 100644 (file)
@@ -5034,7 +5034,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                }
                        }
 
-                       if (m != null && m.parent_symbol is Class) {
+                       if (m != null && m.coroutine && m.parent_symbol is Class) {
                                if (get_ccode_finish_instance (m)) {
                                        var tmp = new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_source_object_");
                                        out_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), tmp);
index 2b7cefb4ac653b8e11e78f77f6d9da5aae2d7cf4..c672faa69022023dd2c807c6920fc8b4cf38493a 100644 (file)
@@ -231,7 +231,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                instance = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, get_cvalue_ (instance_value));
                        }
 
-                       if (expr.is_yield_expression) {
+                       if (!m.coroutine) {
+                               in_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), instance);
+                       } else if (expr.is_yield_expression) {
                                in_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), instance);
                                if (get_ccode_finish_instance (m)) {
                                        out_arg_map.set (get_param_pos (get_ccode_instance_pos (m)), instance);