Commit 9093a1d7 authored by Marco Trevisan's avatar Marco Trevisan 🎺 Committed by Rico Tzschichholz

codegen: Use pointers when accessing constant multi-dimensional arrays

https://bugzilla.gnome.org/show_bug.cgi?id=604371
parent 30caeace
......@@ -164,6 +164,9 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
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, get_cvalue (indices[i]));
if (expr.container.is_constant ()) {
ccontainer = new CCodeUnaryExpression (CCodeUnaryOperator.POINTER_INDIRECTION, ccontainer);
}
}
set_cvalue (expr, new CCodeElementAccess (ccontainer, cindex));
}
......
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