[vala] codegen: Use transform_value instead of transform_expression
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Use transform_value instead of transform_expression
- Date: Sat, 7 May 2011 18:32:14 +0000 (UTC)
commit e3ffbdcbd2c126aa24ce1399a7c6b6549768dac0
Author: Luca Bruno <lucabru src gnome org>
Date: Sat May 7 19:44:51 2011 +0200
codegen: Use transform_value instead of transform_expression
codegen/valaccodebasemodule.vala | 12 +++++++++---
codegen/valaccodecontrolflowmodule.vala | 4 ++--
codegen/valaccodemethodcallmodule.vala | 4 +++-
codegen/valaccodemethodmodule.vala | 2 +-
codegen/valagasyncmodule.vala | 2 +-
codegen/valagobjectmodule.vala | 8 ++++----
6 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0599654..6edcc7a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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 ());
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index 59756d1..b939bed 100644
--- a/codegen/valaccodecontrolflowmodule.vala
+++ b/codegen/valaccodecontrolflowmodule.vala
@@ -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);
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index ce45393..8a51f4c 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -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) {
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 957532f..879fe32 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -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);
diff --git a/codegen/valagasyncmodule.vala b/codegen/valagasyncmodule.vala
index e11dc7a..e1f75e4 100644
--- a/codegen/valagasyncmodule.vala
+++ b/codegen/valagasyncmodule.vala
@@ -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);
}
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index ad50455..63419b1 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]