]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use transform_value instead of transform_expression
authorLuca Bruno <lucabru@src.gnome.org>
Sat, 7 May 2011 17:44:51 +0000 (19:44 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Sat, 7 May 2011 18:29:30 +0000 (20:29 +0200)
codegen/valaccodebasemodule.vala
codegen/valaccodecontrolflowmodule.vala
codegen/valaccodemethodcallmodule.vala
codegen/valaccodemethodmodule.vala
codegen/valagasyncmodule.vala
codegen/valagobjectmodule.vala

index 0599654f543f0fd120a12bc630fc521ec83f5d6d..6edcc7a952c4423edb9f69328ff471d1038d2fa8 100644 (file)
@@ -1584,7 +1584,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
 
                        if (is_virtual) {
                                ccode.add_declaration (this_type.get_cname (), new CCodeVariableDeclarator ("self"));
-                               ccode.add_assignment (new CCodeIdentifier ("self"), transform_expression (new CCodeIdentifier ("base"), base_type, this_type));
+                               ccode.add_assignment (new CCodeIdentifier ("self"), get_cvalue_ (transform_value (new GLibValue (base_type, new CCodeIdentifier ("base")), this_type, acc)));
                        }
 
                        acc.body.emit (this);
@@ -3380,7 +3380,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                        }
 
                        // memory management, implicit casts, and boxing/unboxing
-                       set_cvalue (expr, transform_expression (get_cvalue (expr), expr.value_type, expr.target_type, expr));
+                       if (expr.value_type != null) {
+                               // FIXME: temporary workaround, not all target_value have a value_type
+                               var old_type = expr.target_value.value_type;
+                               expr.target_value.value_type = expr.value_type;
+                               set_cvalue (expr, get_cvalue_ (transform_value (expr.target_value, expr.target_type, expr)));
+                               expr.target_value.value_type = old_type;
+                       }
 
                        if (expr.formal_target_type is GenericType && !(expr.target_type is GenericType)) {
                                if (expr.formal_target_type.type_parameter.parent_symbol != garray_type) {
@@ -4260,7 +4266,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                if (init.symbol_reference is Field) {
                                        var f = (Field) init.symbol_reference;
                                        var instance_target_type = get_data_type_for_symbol ((TypeSymbol) f.parent_symbol);
-                                       var typed_inst = transform_expression (instance, expr.type_reference, instance_target_type);
+                                       var typed_inst = get_cvalue_ (transform_value (new GLibValue (expr.type_reference, instance), instance_target_type, init));
                                        CCodeExpression lhs;
                                        if (expr.type_reference.data_type is Struct) {
                                                lhs = new CCodeMemberAccess (typed_inst, f.get_cname ());
index 59756d19dd0f5bac7f94fa44a85cdc157a7d9706..b939bed1cc24ec0e4c2d7a194191bd92b754fbb0 100644 (file)
@@ -260,7 +260,7 @@ public abstract class Vala.CCodeControlFlowModule : CCodeMethodModule {
 
                        var element_type = array_type.element_type.copy ();
                        element_type.value_owned = false;
-                       element_expr = transform_expression (element_expr, element_type, stmt.type_reference);
+                       element_expr = get_cvalue_ (transform_value (new GLibValue (element_type, element_expr), stmt.type_reference, stmt));
 
                        visit_local_variable (stmt.element_variable);
                        ccode.add_assignment (get_variable_cexpression (stmt.variable_name), element_expr);
@@ -300,7 +300,7 @@ public abstract class Vala.CCodeControlFlowModule : CCodeMethodModule {
                        var element_data_type = collection_type.get_type_arguments ().get (0).copy ();
                        element_data_type.value_owned = false;
                        element_expr = convert_from_generic_pointer (element_expr, element_data_type);
-                       element_expr = transform_expression (element_expr, element_data_type, stmt.type_reference);
+                       element_expr = get_cvalue_ (transform_value (new GLibValue (element_data_type, element_expr), stmt.type_reference, stmt));
 
                        visit_local_variable (stmt.element_variable);
                        ccode.add_assignment (get_variable_cexpression (stmt.variable_name), element_expr);
index ce45393285c75788f02666fc49ca97728f1f621c..8a51f4ccb3e986d5e9cbe617d2a4fd0aa0950245 100644 (file)
@@ -775,7 +775,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                        }
 
                        // assign new value
-                       ccode.add_assignment (get_cvalue (unary.inner), transform_expression (get_cvalue (unary), unary.target_type, unary.inner.value_type, arg));
+                       var value = ((GLibValue) unary.target_value).copy ();
+                       value.value_type = unary.target_type;
+                       ccode.add_assignment (get_cvalue (unary.inner), get_cvalue_ (transform_value (value, unary.inner.value_type, arg)));
 
                        var array_type = arg.value_type as ArrayType;
                        if (array_type != null) {
index 957532f939f76dabb2da627b09748518af87ea75..879fe329ef5322789f9984b609d19d433d0b6984 100644 (file)
@@ -436,7 +436,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                                                        base_expression_type = new ObjectType ((Interface) base_method.parent_symbol);
                                                }
                                                var self_target_type = new ObjectType (cl);
-                                               CCodeExpression cself = transform_expression (new CCodeIdentifier ("base"), base_expression_type, self_target_type);
+                                               CCodeExpression cself = get_cvalue_ (transform_value (new GLibValue (base_expression_type, new CCodeIdentifier ("base")), self_target_type, m));
 
                                                ccode.add_declaration ("%s *".printf (cl.get_cname ()), new CCodeVariableDeclarator ("self"));
                                                ccode.add_assignment (new CCodeIdentifier ("self"), cself);
index e11dc7a8c5a8e6efb37779b3dff91ebda81e7954..e1f75e4d9afca3ef61133c5f14c28387636e108e 100644 (file)
@@ -179,7 +179,7 @@ public class Vala.GAsyncModule : GSignalModule {
                        var type_symbol = m.parent_symbol as ObjectTypeSymbol;
 
                        var self_target_type = new ObjectType (type_symbol);
-                       var cself = transform_expression (new CCodeIdentifier ("base"), base_expression_type, self_target_type);
+                       var cself = get_cvalue_ (transform_value (new GLibValue (base_expression_type, new CCodeIdentifier ("base")), self_target_type, m));
                        ccode.add_declaration ("%s *".printf (type_symbol.get_cname ()), new CCodeVariableDeclarator ("self"));
                        ccode.add_assignment (new CCodeIdentifier ("self"), cself);
                }
index ad50455ea5740ecd9e15fcd43579288aa6182be6..63419b1dd30956955cd7be1f146c3f5d653afe7a 100644 (file)
@@ -202,13 +202,13 @@ public class Vala.GObjectModule : GTypeModule {
                        if (prop.base_property != null) {
                                var base_type = (Class) prop.base_property.parent_symbol;
                                base_prop = prop.base_property;
-                               cself = transform_expression (cself, new ObjectType (cl), new ObjectType (base_type));
+                               cself = get_cvalue_ (transform_value (new GLibValue (new ObjectType (cl), cself), new ObjectType (base_type), prop));
 
                                generate_property_accessor_declaration (prop.base_property.get_accessor, cfile);
                        } else if (prop.base_interface_property != null) {
                                var base_type = (Interface) prop.base_interface_property.parent_symbol;
                                base_prop = prop.base_interface_property;
-                               cself = transform_expression (cself, new ObjectType (cl), new ObjectType (base_type));
+                               cself = get_cvalue_ (transform_value (new GLibValue (new ObjectType (cl), cself), new ObjectType (base_type), prop));
 
                                generate_property_accessor_declaration (prop.base_interface_property.get_accessor, cfile);
                        }
@@ -301,13 +301,13 @@ public class Vala.GObjectModule : GTypeModule {
                        if (prop.base_property != null) {
                                var base_type = (Class) prop.base_property.parent_symbol;
                                base_prop = prop.base_property;
-                               cself = transform_expression (cself, new ObjectType (cl), new ObjectType (base_type));
+                               cself = get_cvalue_ (transform_value (new GLibValue (new ObjectType (cl), cself), new ObjectType (base_type), prop));
 
                                generate_property_accessor_declaration (prop.base_property.set_accessor, cfile);
                        } else if (prop.base_interface_property != null) {
                                var base_type = (Interface) prop.base_interface_property.parent_symbol;
                                base_prop = prop.base_interface_property;
-                               cself = transform_expression (cself, new ObjectType (cl), new ObjectType (base_type));
+                               cself = get_cvalue_ (transform_value (new GLibValue (new ObjectType (cl), cself), new ObjectType (base_type), prop));
 
                                generate_property_accessor_declaration (prop.base_interface_property.set_accessor, cfile);
                        }