]> 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>
Thu, 4 Jun 2020 06:34:30 +0000 (08:34 +0200)
and restrict evaluation of CCode.finish_* attributes to async methods only

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

index e39fdbeccbdeb23421b0837c4f31395635702e34..f10eb3f6d8fc6fa4f10132fefa3031d3ae0c8ebb 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) {
@@ -415,14 +416,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 b4a65dd7741f31f08ccc02e70b1b8aae74c272bb..97c2617bea36d1e313cb4c79ef8d9dbc8e222118 100644 (file)
@@ -4991,7 +4991,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 25effa396f61d191efb4de760762253b317b007c..9ffb8deb7575594b77a672ad07feb946bb6660e6 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);