[vala/wip/transform: 88/107] Use return_temp_access in coalescing expression
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/transform: 88/107] Use return_temp_access in coalescing expression
- Date: Mon, 15 May 2017 14:55:07 +0000 (UTC)
commit 4ede9bc0630ecc8f53ac0cc4fda3dd0436eb437e
Author: Luca Bruno <lucabru src gnome org>
Date: Sat Feb 1 11:22:18 2014 +0100
Use return_temp_access in coalescing expression
codegen/valaccodetransformer.vala | 5 +++--
vala/valabinaryexpression.vala | 2 ++
2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodetransformer.vala b/codegen/valaccodetransformer.vala
index d0ab093..432dea0 100644
--- a/codegen/valaccodetransformer.vala
+++ b/codegen/valaccodetransformer.vala
@@ -444,12 +444,13 @@ public class Vala.CCodeTransformer : CodeTransformer {
replacement = expression (result);
} else if (expr.operator == BinaryOperator.COALESCE) {
var is_owned = expr.left.value_type.value_owned || expr.right.value_type.value_owned;
- var result = b.add_temp_declaration (copy_type (expr.value_type, is_owned, true),
expr.left);
+ var result = b.add_temp_declaration (copy_type (expr.value_type), expr.left);
b.open_if (expression (@"$result == null"));
b.add_assignment (expression (result), expr.right);
b.close ();
- replacement = expression (result);
+
+ replacement = return_temp_access (result, expr.value_type, target_type);
} else if (expr.operator == BinaryOperator.IN && !(expr.left.value_type.compatible
(context.analyzer.int_type) && expr.right.value_type.compatible (context.analyzer.int_type)) &&
!(expr.right.value_type is ArrayType)) {
// neither enums nor array, it's contains()
var call = new MethodCall (new MemberAccess (expr.right, "contains",
expr.source_reference), expr.source_reference);
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index 95d8c70..ce8f43a 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -193,6 +193,8 @@ public class Vala.BinaryExpression : Expression {
if (operator == BinaryOperator.COALESCE) {
left.target_type.nullable = true;
+ left.target_type.value_owned = left.value_type.value_owned ||
right.value_type.value_owned;
+
right.target_type = left.target_type.copy ();
value_type = left.target_type.copy ();
} else if (left.value_type.data_type == context.analyzer.string_type.data_type
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]