Commit f2e56f94 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

use cast for field initializers when necessary

2007-07-27  Juerg Billeter  <j@bitron.ch>

	* gobject/valacodegenerator.vala: use cast for field initializers when
	  necessary

svn path=/trunk/; revision=401
parent 5a485fa0
2007-07-27 Jürg Billeter <j@bitron.ch>
* gobject/valacodegenerator.vala: use cast for field initializers when
necessary
2007-07-27 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: fix memory leak in cast expressions
......
......@@ -429,8 +429,17 @@ public class Vala.CodeGenerator : CodeVisitor {
}
if (f.initializer != null) {
instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (lhs, (CCodeExpression) f.initializer.ccodenode)));
var rhs = (CCodeExpression) f.initializer.ccodenode;
if (f.type_reference.data_type != null
&& f.initializer.static_type.data_type != null
&& f.type_reference.data_type.is_reference_type ()
&& f.initializer.static_type.data_type != f.type_reference.data_type) {
// FIXME: use C cast if debugging disabled
rhs = new InstanceCast (rhs, f.type_reference.data_type);
}
instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (lhs, rhs)));
if (f.type_reference.data_type is Array && !f.no_array_length &&
f.initializer is ArrayCreationExpression) {
var ma = new MemberAccess.simple (f.name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment