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

cast object instances in comparisons to reduce the number of warnings

2006-10-25  Jürg Billeter  <j@bitron.ch>

	* vala/valacodegenerator.vala: cast object instances in comparisons to
	  reduce the number of warnings during C compilation

svn path=/trunk/; revision=152
parent 46b759a5
2006-10-25 Jürg Billeter <j@bitron.ch>
* vala/valacodegenerator.vala: cast object instances in comparisons to
reduce the number of warnings during C compilation
2006-10-25 Jürg Billeter <j@bitron.ch>
* vala/valacodegenerator.vala, vala/valaarray.vala,
......
......@@ -3070,7 +3070,28 @@ public class Vala.CodeGenerator : CodeVisitor {
} else if (expr.operator == BinaryOperator.OR) {
op = CCodeBinaryOperator.OR;
}
expr.ccodenode = new CCodeBinaryExpression (op, (CCodeExpression) expr.left.ccodenode, (CCodeExpression) expr.right.ccodenode);
var cleft = (CCodeExpression) expr.left.ccodenode;
var cright = (CCodeExpression) expr.right.ccodenode;
if (expr.operator == BinaryOperator.EQUALITY ||
expr.operator == BinaryOperator.INEQUALITY) {
if (expr.left.static_type != null && expr.right.static_type != null &&
expr.left.static_type.data_type is Class && expr.right.static_type.data_type is Class) {
var left_cl = (Class) expr.left.static_type.data_type;
var right_cl = (Class) expr.right.static_type.data_type;
if (left_cl != right_cl) {
if (left_cl.is_subtype_of (right_cl)) {
cleft = new InstanceCast (cleft, right_cl);
} else if (right_cl.is_subtype_of (left_cl)) {
cright = new InstanceCast (cright, left_cl);
}
}
}
}
expr.ccodenode = new CCodeBinaryExpression (op, cleft, cright);
visit_expression (expr);
}
......
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