[vala] codegen: Use separate C statements for object creation expressions
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Use separate C statements for object creation expressions
- Date: Sun, 10 Oct 2010 16:38:32 +0000 (UTC)
commit 15c5ba9f4394e8ee405001a2bac27f5c183c990b
Author: Jürg Billeter <j bitron ch>
Date: Sun Oct 10 09:52:06 2010 +0200
codegen: Use separate C statements for object creation expressions
codegen/valaccodebasemodule.vala | 17 +++++++++++++----
codegen/valadovabasemodule.vala | 14 +++++++++++---
2 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 7a29f1f..5adc2a3 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4226,8 +4226,9 @@ public class Vala.CCodeBaseModule : CodeGenerator {
var local = expr.parent_node as LocalVariable;
if (local != null && has_simple_struct_initializer (local)) {
- // no comma expression necessary
+ // no temporary variable necessary
set_cvalue (expr, creation_expr);
+ return;
} else if (instance != null) {
var ccomma = new CCodeCommaExpression ();
@@ -4287,9 +4288,17 @@ public class Vala.CCodeBaseModule : CodeGenerator {
ccomma.append_expression (instance);
- set_cvalue (expr, ccomma);
- } else if (creation_expr != null) {
- set_cvalue (expr, creation_expr);
+ creation_expr = ccomma;
+ }
+
+ if (creation_expr != null) {
+ var temp_var = get_temp_variable (expr.value_type);
+ var temp_ref = get_variable_cexpression (temp_var.name);
+
+ emit_temp_var (temp_var);
+
+ ccode.add_expression (new CCodeAssignment (temp_ref, creation_expr));
+ set_cvalue (expr, temp_ref);
}
}
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 7eb81b6..2c66c8c 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -1706,9 +1706,17 @@ public class Vala.DovaBaseModule : CodeGenerator {
ccomma.append_expression (instance);
- set_cvalue (expr, ccomma);
- } else if (creation_expr != null) {
- set_cvalue (expr, creation_expr);
+ creation_expr = ccomma;
+ }
+
+ if (creation_expr != null) {
+ var temp_var = get_temp_variable (expr.value_type);
+ var temp_ref = get_variable_cexpression (temp_var.name);
+
+ emit_temp_var (temp_var);
+
+ ccode.add_expression (new CCodeAssignment (temp_ref, creation_expr));
+ set_cvalue (expr, temp_ref);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]