~ubuntu-branches/ubuntu/vivid/vala/vivid

« back to all changes in this revision

Viewing changes to codegen/valaccodeassignmentmodule.vala

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2010-09-05 10:32:13 UTC
  • mfrom: (1.5.9 upstream) (28.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20100905103213-8nn88erk20o4wgm3
Tags: 0.9.8-1
New upstream development release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
                        }
46
46
                }
47
47
 
48
 
                if (prop.set_accessor.construction && current_type_symbol is Class && current_class.is_subtype_of (gobject_type) && in_creation_method) {
49
 
                        return get_construct_property_assignment (prop.get_canonical_cconstant (), prop.property_type, (CCodeExpression) assignment.right.ccodenode);
 
48
                CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode;
 
49
 
 
50
                if (!prop.no_accessor_method) {
 
51
                        if (prop.property_type.is_real_non_null_struct_type ()) {
 
52
                                cexpr = get_address_of_expression (assignment.right, cexpr);
 
53
                        }
 
54
                }
 
55
 
 
56
                if (assignment.operator != AssignmentOperator.SIMPLE) {
 
57
                        CCodeBinaryOperator cop;
 
58
                        if (assignment.operator == AssignmentOperator.BITWISE_OR) {
 
59
                                cop = CCodeBinaryOperator.BITWISE_OR;
 
60
                        } else if (assignment.operator == AssignmentOperator.BITWISE_AND) {
 
61
                                cop = CCodeBinaryOperator.BITWISE_AND;
 
62
                        } else if (assignment.operator == AssignmentOperator.BITWISE_XOR) {
 
63
                                cop = CCodeBinaryOperator.BITWISE_XOR;
 
64
                        } else if (assignment.operator == AssignmentOperator.ADD) {
 
65
                                cop = CCodeBinaryOperator.PLUS;
 
66
                        } else if (assignment.operator == AssignmentOperator.SUB) {
 
67
                                cop = CCodeBinaryOperator.MINUS;
 
68
                        } else if (assignment.operator == AssignmentOperator.MUL) {
 
69
                                cop = CCodeBinaryOperator.MUL;
 
70
                        } else if (assignment.operator == AssignmentOperator.DIV) {
 
71
                                cop = CCodeBinaryOperator.DIV;
 
72
                        } else if (assignment.operator == AssignmentOperator.PERCENT) {
 
73
                                cop = CCodeBinaryOperator.MOD;
 
74
                        } else if (assignment.operator == AssignmentOperator.SHIFT_LEFT) {
 
75
                                cop = CCodeBinaryOperator.SHIFT_LEFT;
 
76
                        } else if (assignment.operator == AssignmentOperator.SHIFT_RIGHT) {
 
77
                                cop = CCodeBinaryOperator.SHIFT_RIGHT;
 
78
                        } else {
 
79
                                assert_not_reached ();
 
80
                        }
 
81
                        cexpr = new CCodeBinaryExpression (cop, (CCodeExpression) get_ccodenode (assignment.left), cexpr);
 
82
                }
 
83
                
 
84
                var ccall = get_property_set_call (prop, ma, cexpr, assignment.right);
 
85
                
 
86
                // assignments are expressions, so return the current property value, except if we're sure that it can't be used
 
87
                if (!(assignment.parent_node is ExpressionStatement)) {
 
88
                        var ccomma = new CCodeCommaExpression ();
 
89
                        ccomma.append_expression (ccall); // update property
 
90
                        ccomma.append_expression ((CCodeExpression) get_ccodenode (ma)); // current property value
 
91
                        
 
92
                        return ccomma;
50
93
                } else {
51
 
                        CCodeExpression cexpr = (CCodeExpression) assignment.right.ccodenode;
52
 
 
53
 
                        if (!prop.no_accessor_method) {
54
 
                                if (prop.property_type.is_real_non_null_struct_type ()) {
55
 
                                        cexpr = get_address_of_expression (assignment.right, cexpr);
56
 
                                }
57
 
                        }
58
 
 
59
 
                        if (assignment.operator != AssignmentOperator.SIMPLE) {
60
 
                                CCodeBinaryOperator cop;
61
 
                                if (assignment.operator == AssignmentOperator.BITWISE_OR) {
62
 
                                        cop = CCodeBinaryOperator.BITWISE_OR;
63
 
                                } else if (assignment.operator == AssignmentOperator.BITWISE_AND) {
64
 
                                        cop = CCodeBinaryOperator.BITWISE_AND;
65
 
                                } else if (assignment.operator == AssignmentOperator.BITWISE_XOR) {
66
 
                                        cop = CCodeBinaryOperator.BITWISE_XOR;
67
 
                                } else if (assignment.operator == AssignmentOperator.ADD) {
68
 
                                        cop = CCodeBinaryOperator.PLUS;
69
 
                                } else if (assignment.operator == AssignmentOperator.SUB) {
70
 
                                        cop = CCodeBinaryOperator.MINUS;
71
 
                                } else if (assignment.operator == AssignmentOperator.MUL) {
72
 
                                        cop = CCodeBinaryOperator.MUL;
73
 
                                } else if (assignment.operator == AssignmentOperator.DIV) {
74
 
                                        cop = CCodeBinaryOperator.DIV;
75
 
                                } else if (assignment.operator == AssignmentOperator.PERCENT) {
76
 
                                        cop = CCodeBinaryOperator.MOD;
77
 
                                } else if (assignment.operator == AssignmentOperator.SHIFT_LEFT) {
78
 
                                        cop = CCodeBinaryOperator.SHIFT_LEFT;
79
 
                                } else if (assignment.operator == AssignmentOperator.SHIFT_RIGHT) {
80
 
                                        cop = CCodeBinaryOperator.SHIFT_RIGHT;
81
 
                                } else {
82
 
                                        assert_not_reached ();
83
 
                                }
84
 
                                cexpr = new CCodeBinaryExpression (cop, (CCodeExpression) get_ccodenode (assignment.left), cexpr);
85
 
                        }
86
 
                        
87
 
                        var ccall = get_property_set_call (prop, ma, cexpr, assignment.right);
88
 
                        
89
 
                        // assignments are expressions, so return the current property value, except if we're sure that it can't be used
90
 
                        if (!(assignment.parent_node is ExpressionStatement)) {
91
 
                                var ccomma = new CCodeCommaExpression ();
92
 
                                ccomma.append_expression (ccall); // update property
93
 
                                ccomma.append_expression ((CCodeExpression) get_ccodenode (ma)); // current property value
94
 
                                
95
 
                                return ccomma;
96
 
                        } else {
97
 
                                return ccall;
98
 
                        }
 
94
                        return ccall;
99
95
                }
100
96
        }
101
97