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

fixes for multi-dimension arrays

2007-08-06  Juerg Billeter  <j@bitron.ch>

	* gobject/valacodegenerator.vala,
	  gobject/valacodegeneratorassignment.vala: fixes for multi-dimension
	  arrays

svn path=/trunk/; revision=418
parent bfd68d7a
2007-08-06 Jürg Billeter <j@bitron.ch>
* gobject/valacodegenerator.vala,
gobject/valacodegeneratorassignment.vala: fixes for multi-dimension
arrays
2007-08-05 Jürg Billeter <j@bitron.ch>
* vapi/Makefile.am, vapi/gtkmozembed.vala: add GtkMozEmbed bindings,
......
......@@ -444,13 +444,16 @@ public class Vala.CodeGenerator : CodeVisitor {
if (f.type_reference.data_type is Array && !f.no_array_length &&
f.initializer is ArrayCreationExpression) {
var array = (Array) f.type_reference.data_type;
var ma = new MemberAccess.simple (f.name);
ma.symbol_reference = f;
var array_len_lhs = get_array_length_cexpression (ma, 1);
Gee.List<Expression> sizes = ((ArrayCreationExpression) f.initializer).get_sizes ();
var size = sizes[0];
instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode)));
for (int dim = 1; dim <= array.rank; dim++) {
var array_len_lhs = get_array_length_cexpression (ma, dim);
var size = sizes[dim - 1];
instance_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode)));
}
}
}
......@@ -2067,8 +2070,8 @@ public class Vala.CodeGenerator : CodeVisitor {
} else {
// access to element in an array
for (int i = 1; i < rank; i++) {
var cmul = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, cindex, get_array_length_cexpression (expr.container, i + 1));
cindex = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cmul, (CCodeExpression) indices[i].ccodenode);
var cmul = new CCodeBinaryExpression (CCodeBinaryOperator.MUL, new CCodeParenthesizedExpression (cindex), get_array_length_cexpression (expr.container, i + 1));
cindex = new CCodeBinaryExpression (CCodeBinaryOperator.PLUS, cmul, new CCodeParenthesizedExpression ((CCodeExpression) indices[i].ccodenode));
}
expr.ccodenode = new CCodeElementAccess (ccontainer, cindex);
}
......
......@@ -268,9 +268,12 @@ public class Vala.CodeGenerator {
}
if (array) {
var lhs_array_len = get_array_length_cexpression (a.left, 1);
var rhs_array_len = get_array_length_cexpression (a.right, 1);
ccomma.append_expression (new CCodeAssignment (lhs_array_len, rhs_array_len));
var arr = (Array) a.left.static_type.data_type;
for (int dim = 1; dim <= arr.rank; dim++) {
var lhs_array_len = get_array_length_cexpression (a.left, dim);
var rhs_array_len = get_array_length_cexpression (a.right, dim);
ccomma.append_expression (new CCodeAssignment (lhs_array_len, rhs_array_len));
}
}
ccomma.append_expression (new CCodeIdentifier (temp_decl.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