[vala] codegen: Drop unnecessary comma expressions in creation expressions
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Drop unnecessary comma expressions in creation expressions
- Date: Sun, 10 Oct 2010 16:38:37 +0000 (UTC)
commit 4cfbae719cd97a6465ca2ffc6e2f72da9fb1c55b
Author: Jürg Billeter <j bitron ch>
Date: Sun Oct 10 10:50:21 2010 +0200
codegen: Drop unnecessary comma expressions in creation expressions
codegen/valaccodebasemodule.vala | 18 +++++++-----------
codegen/valadovabasemodule.vala | 14 +++++---------
2 files changed, 12 insertions(+), 20 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 5adc2a3..d0b5a8c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4230,12 +4230,10 @@ public class Vala.CCodeBaseModule : CodeGenerator {
set_cvalue (expr, creation_expr);
return;
} else if (instance != null) {
- var ccomma = new CCodeCommaExpression ();
-
if (expr.type_reference.data_type is Struct) {
- ccomma.append_expression (creation_expr);
+ ccode.add_expression (creation_expr);
} else {
- ccomma.append_expression (new CCodeAssignment (instance, creation_expr));
+ ccode.add_expression (new CCodeAssignment (instance, creation_expr));
}
foreach (MemberInitializer init in expr.get_object_initializer ()) {
@@ -4249,7 +4247,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
} else {
lhs = new CCodeMemberAccess.pointer (typed_inst, f.get_cname ());
}
- ccomma.append_expression (new CCodeAssignment (lhs, get_cvalue (init.initializer)));
+ ccode.add_expression (new CCodeAssignment (lhs, get_cvalue (init.initializer)));
if (f.variable_type is ArrayType && !f.no_array_length) {
var array_type = (ArrayType) f.variable_type;
@@ -4260,7 +4258,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
lhs = new CCodeMemberAccess.pointer (typed_inst, get_array_length_cname (f.get_cname (), dim));
}
var rhs_array_len = get_array_length_cexpression (init.initializer, dim);
- ccomma.append_expression (new CCodeAssignment (lhs, rhs_array_len));
+ ccode.add_expression (new CCodeAssignment (lhs, rhs_array_len));
}
} else if (f.variable_type is DelegateType && (f.variable_type as DelegateType).delegate_symbol.has_target && !f.no_delegate_target) {
if (expr.type_reference.data_type is Struct) {
@@ -4270,7 +4268,7 @@ public class Vala.CCodeBaseModule : CodeGenerator {
}
CCodeExpression rhs_delegate_target_destroy_notify;
var rhs_delegate_target = get_delegate_target_cexpression (init.initializer, out rhs_delegate_target_destroy_notify);
- ccomma.append_expression (new CCodeAssignment (lhs, rhs_delegate_target));
+ ccode.add_expression (new CCodeAssignment (lhs, rhs_delegate_target));
}
var cl = f.parent_symbol as Class;
@@ -4282,13 +4280,11 @@ public class Vala.CCodeBaseModule : CodeGenerator {
inst_ma.value_type = expr.type_reference;
set_cvalue (inst_ma, instance);
var ma = new MemberAccess (inst_ma, init.name);
- ccomma.append_expression (get_property_set_call ((Property) init.symbol_reference, ma, get_cvalue (init.initializer)));
+ ccode.add_expression (get_property_set_call ((Property) init.symbol_reference, ma, get_cvalue (init.initializer)));
}
}
- ccomma.append_expression (instance);
-
- creation_expr = ccomma;
+ creation_expr = instance;
}
if (creation_expr != null) {
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 2c66c8c..8e42962 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -1675,12 +1675,10 @@ public class Vala.DovaBaseModule : CodeGenerator {
}
if (instance != null) {
- var ccomma = new CCodeCommaExpression ();
-
if (expr.type_reference.data_type is Struct) {
- ccomma.append_expression (creation_expr);
+ ccode.add_expression (creation_expr);
} else {
- ccomma.append_expression (new CCodeAssignment (instance, creation_expr));
+ ccode.add_expression (new CCodeAssignment (instance, creation_expr));
}
foreach (MemberInitializer init in expr.get_object_initializer ()) {
@@ -1694,19 +1692,17 @@ public class Vala.DovaBaseModule : CodeGenerator {
} else {
lhs = new CCodeMemberAccess.pointer (typed_inst, f.get_cname ());
}
- ccomma.append_expression (new CCodeAssignment (lhs, get_cvalue (init.initializer)));
+ ccode.add_expression (new CCodeAssignment (lhs, get_cvalue (init.initializer)));
} else if (init.symbol_reference is Property) {
var inst_ma = new MemberAccess.simple ("new");
inst_ma.value_type = expr.type_reference;
set_cvalue (inst_ma, instance);
var ma = new MemberAccess (inst_ma, init.name);
- ccomma.append_expression (get_property_set_call ((Property) init.symbol_reference, ma, get_cvalue (init.initializer)));
+ ccode.add_expression (get_property_set_call ((Property) init.symbol_reference, ma, get_cvalue (init.initializer)));
}
}
- ccomma.append_expression (instance);
-
- creation_expr = ccomma;
+ creation_expr = instance;
}
if (creation_expr != null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]