Commit 8524dc8d authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Use temp-var for MethodCall with out/ref arguments

Checking arguments of a MethodCall expression is required for varidic
methods where checking parameters isn't sufficient. Doing this makes
looking for out/ref parameters superfluous.

Fixes #722
parent 2cea36af
......@@ -814,7 +814,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
} else if (m != null && m.get_attribute_bool ("CCode", "use_inplace", false)) {
set_cvalue (expr, ccall_expr);
} else if (!return_result_via_out_param
&& ((m != null && !has_ref_out_param (m)) || (deleg != null && !has_ref_out_param (deleg)))
&& !has_ref_out_argument (expr)
&& (result_type is ValueType && !result_type.is_disposable ())) {
set_cvalue (expr, ccall_expr);
} else if (!return_result_via_out_param) {
......@@ -909,9 +909,10 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
return to_string_func;
}
bool has_ref_out_param (Callable c) {
foreach (var param in c.get_parameters ()) {
if (param.direction != ParameterDirection.IN) {
bool has_ref_out_argument (MethodCall c) {
foreach (var arg in c.get_argument_list ()) {
unowned UnaryExpression? unary = arg as UnaryExpression;
if (unary != null && (unary.operator == UnaryOperator.OUT || unary.operator == UnaryOperator.REF)) {
return true;
}
}
......
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