[vala/staging: 8/10] codegen: More use of get_variable_cexpression()




commit 6f30d212f2b4a0b59d96605467738c66d0014b51
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Apr 18 21:02:21 2021 +0200

    codegen: More use of get_variable_cexpression()

 codegen/valaccodebasemodule.vala         |  2 +-
 codegen/valaccodememberaccessmodule.vala | 10 +++++-----
 codegen/valaccodemethodcallmodule.vala   |  5 ++---
 codegen/valagerrormodule.vala            |  3 +--
 4 files changed, 9 insertions(+), 11 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index c7b44e4e6..415522c42 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -1441,7 +1441,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                                                var vardecl = new 
CCodeVariableDeclarator.zero (temp_decl.name, rhs);
                                                                ccode.add_declaration (get_ccode_name 
(temp_decl.variable_type), vardecl);
 
-                                                               var tmp = get_variable_cexpression 
(get_variable_cname (temp_decl.name));
+                                                               var tmp = get_variable_cexpression 
(temp_decl.name);
                                                                ccode.add_assignment (lhs, tmp);
 
                                                                ccode.close ();
diff --git a/codegen/valaccodememberaccessmodule.vala b/codegen/valaccodememberaccessmodule.vala
index 05e5541f8..67a5434f3 100644
--- a/codegen/valaccodememberaccessmodule.vala
+++ b/codegen/valaccodememberaccessmodule.vala
@@ -485,9 +485,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                                }
                        } else if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
                                if (is_in_coroutine ()) {
-                                       result.delegate_target_cvalue = new CCodeMemberAccess.pointer (new 
CCodeIdentifier ("_data_"), get_delegate_target_cname (get_local_cname (local)));
+                                       result.delegate_target_cvalue = get_variable_cexpression 
(get_delegate_target_cname (get_local_cname (local)));
                                        if (local.variable_type.is_disposable ()) {
-                                               result.delegate_target_destroy_notify_cvalue = new 
CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_delegate_target_destroy_notify_cname 
(get_local_cname (local)));
+                                               result.delegate_target_destroy_notify_cvalue = 
get_variable_cexpression (get_delegate_target_destroy_notify_cname (get_local_cname (local)));
                                        }
                                } else {
                                        result.delegate_target_cvalue = new CCodeIdentifier 
(get_delegate_target_cname (get_local_cname (local)));
@@ -522,7 +522,7 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                if (param.name == "this") {
                        if (is_in_coroutine ()) {
                                // use closure
-                               result.cvalue = new CCodeMemberAccess.pointer (new CCodeIdentifier 
("_data_"), "self");
+                               result.cvalue = get_this_cexpression ();
                        } else {
                                unowned Struct? st = result.value_type.type_symbol as Struct;
                                if (st != null && !st.is_simple_type ()) {
@@ -555,9 +555,9 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
                                // use closure
                                result.cvalue = get_parameter_cexpression (param);
                                if (delegate_type != null && delegate_type.delegate_symbol.has_target) {
-                                       result.delegate_target_cvalue = new CCodeMemberAccess.pointer (new 
CCodeIdentifier ("_data_"), get_ccode_delegate_target_name (param));
+                                       result.delegate_target_cvalue = get_variable_cexpression 
(get_ccode_delegate_target_name (param));
                                        if (delegate_type.is_disposable ()) {
-                                               result.delegate_target_destroy_notify_cvalue = new 
CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), get_ccode_delegate_target_destroy_notify_name 
(param));
+                                               result.delegate_target_destroy_notify_cvalue = 
get_variable_cexpression (get_ccode_delegate_target_destroy_notify_name (param));
                                        }
                                }
                        } else {
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index c400dc2e9..7648f4126 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -160,11 +160,10 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                                params = m.get_async_begin_parameters ();
                        } else {
                                ccall = finish_call;
-
                                // output arguments used separately
                                out_arg_map = new HashMap<int,CCodeExpression> (direct_hash, direct_equal);
                                // pass GAsyncResult stored in closure to finish function
-                               out_arg_map.set (get_param_pos (get_ccode_async_result_pos (m)), new 
CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), "_res_"));
+                               out_arg_map.set (get_param_pos (get_ccode_async_result_pos (m)), 
get_variable_cexpression ("_res_"));
                        }
                }
 
@@ -806,7 +805,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                        // set state before calling async function to support immediate callbacks
                        int state = emit_context.next_coroutine_state++;
 
-                       ccode.add_assignment (new CCodeMemberAccess.pointer (new CCodeIdentifier ("_data_"), 
"_state_"), new CCodeConstant (state.to_string ()));
+                       ccode.add_assignment (get_variable_cexpression ("_state_"), new CCodeConstant 
(state.to_string ()));
                        ccode.add_expression (async_call);
                        ccode.add_return (new CCodeConstant ("FALSE"));
                        ccode.add_label ("_state_%d".printf (state));
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index d724c3c3a..92be271c7 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -157,9 +157,8 @@ public class Vala.GErrorModule : CCodeDelegateModule {
                                ccode.add_return (new CCodeConstant ("NULL"));
                        }
                } else if (is_in_coroutine ()) {
-                       var async_result_expr = new CCodeMemberAccess.pointer (new CCodeIdentifier 
("_data_"), "_async_result");
                        var unref = new CCodeFunctionCall (new CCodeIdentifier ("g_object_unref"));
-                       unref.add_argument (async_result_expr);
+                       unref.add_argument (get_variable_cexpression ("_async_result"));
                        ccode.add_expression (unref);
                        ccode.add_return (new CCodeConstant ("FALSE"));
                } else if (current_return_type != null) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]