summaryrefslogtreecommitdiff
path: root/codegen/valaccodeassignmentmodule.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2011-04-02 23:39:04 +0200
committerJürg Billeter <j@bitron.ch>2011-04-02 23:39:04 +0200
commit15bb27974b6c2e253744d7cc0de5a6f27a6ebbb4 (patch)
treed04d5844cbf303ecfd23ba3710da01967a24b7d6 /codegen/valaccodeassignmentmodule.vala
parent1a08e2d675514a251b680833d5fae6ee10f788a6 (diff)
downloadvala-15bb27974b6c2e253744d7cc0de5a6f27a6ebbb4.tar.gz
codegen: Fix use of property assignments as subexpressions
Fixes bug 640171.
Diffstat (limited to 'codegen/valaccodeassignmentmodule.vala')
-rw-r--r--codegen/valaccodeassignmentmodule.vala20
1 files changed, 18 insertions, 2 deletions
diff --git a/codegen/valaccodeassignmentmodule.vala b/codegen/valaccodeassignmentmodule.vala
index ab9285b2e..ed25014f0 100644
--- a/codegen/valaccodeassignmentmodule.vala
+++ b/codegen/valaccodeassignmentmodule.vala
@@ -156,9 +156,25 @@ public class Vala.CCodeAssignmentModule : CCodeMemberAccessModule {
var ma = assignment.left as MemberAccess;
var prop = (Property) assignment.left.symbol_reference;
- store_property (prop, ma.inner, assignment.right.target_value);
+ if (assignment.parent_node is ExpressionStatement) {
+ store_property (prop, ma.inner, assignment.right.target_value);
- set_cvalue (assignment, get_ccodenode (assignment.right));
+ set_cvalue (assignment, get_ccodenode (assignment.right));
+ } else {
+ // when load_variable is changed to use temporary
+ // variables, this exception is no longer necessary
+
+ var temp_decl = get_temp_variable (prop.property_type);
+ emit_temp_var (temp_decl);
+ ccode.add_assignment (get_variable_cexpression (temp_decl.name), get_cvalue_ (assignment.right.target_value));
+
+ var target_value = ((GLibValue) assignment.right.target_value).copy ();
+ target_value.cvalue = get_variable_cexpression (temp_decl.name);
+
+ store_property (prop, ma.inner, target_value);
+
+ assignment.target_value = target_value;
+ }
} else {
var array_type = assignment.left.value_type as ArrayType;
if (array_type != null && array_type.fixed_length) {