Commit bc1af8f5 authored by Rico Tzschichholz's avatar Rico Tzschichholz

codegen: Keep respecting CCode array_length_type of Parameter/Method/Delegate

parent 7dc69101
......@@ -250,6 +250,7 @@ namespace Vala {
if (node is ArrayType) {
return get_ccode_name (((ArrayType) node).length_type);
} else {
assert (node is Method || node is Parameter || node is Delegate);
return get_ccode_attribute(node).array_length_type;
}
}
......
......@@ -744,7 +744,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
}
if (!array_type.fixed_length && get_ccode_array_length (param)) {
var length_ctype = get_ccode_array_length_type (array_type);
var length_ctype = get_ccode_array_length_type (param) ?? get_ccode_array_length_type (array_type);
if (param.direction != ParameterDirection.IN) {
length_ctype = "%s*".printf (length_ctype);
}
......
......@@ -88,7 +88,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
if (get_ccode_array_length (d) && d.return_type is ArrayType) {
// return array length if appropriate
var array_type = (ArrayType) d.return_type;
var length_ctype = get_ccode_array_length_type (array_type) + "*";
var length_ctype = (get_ccode_array_length_type (d) ?? get_ccode_array_length_type (array_type)) + "*";
for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeParameter (get_array_length_cname ("result", dim), length_ctype);
......@@ -238,7 +238,7 @@ public class Vala.CCodeDelegateModule : CCodeArrayModule {
if (get_ccode_array_length (d) && d.return_type is ArrayType) {
// return array length if appropriate
var array_type = (ArrayType) d.return_type;
var length_ctype = get_ccode_array_length_type (array_type) + "*";
var length_ctype = (get_ccode_array_length_type (d) ?? get_ccode_array_length_type (array_type)) + "*";
for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeParameter (get_array_length_cname ("result", dim), length_ctype);
......
......@@ -366,7 +366,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (unary == null || unary.operator != UnaryOperator.OUT) {
if (get_ccode_array_length (param) && param.variable_type is ArrayType && !((ArrayType) param.variable_type).fixed_length) {
var array_type = (ArrayType) param.variable_type;
var length_ctype = get_ccode_array_length_type (array_type);
var length_ctype = get_ccode_array_length_type (param) ?? get_ccode_array_length_type (array_type);
if (unary != null && unary.operator == UnaryOperator.REF) {
length_ctype = "%s*".printf (length_ctype);
}
......@@ -427,7 +427,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
if (get_ccode_array_length (param) && param.variable_type is ArrayType && !((ArrayType) param.variable_type).fixed_length) {
var array_type = (ArrayType) param.variable_type;
var length_ctype = get_ccode_array_length_type (array_type);
var length_ctype = get_ccode_array_length_type (param) ?? get_ccode_array_length_type (array_type);
for (int dim = 1; dim <= array_type.rank; dim++) {
var temp_array_length = get_temp_variable (new CType (length_ctype));
emit_temp_var (temp_array_length);
......@@ -504,7 +504,7 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
append_array_length (expr, len_call);
} else if (get_ccode_array_length (m)) {
var length_ctype = get_ccode_array_length_type (array_type);
var length_ctype = get_ccode_array_length_type (m) ?? get_ccode_array_length_type (array_type);
var temp_var = get_temp_variable (new CType (length_ctype), true, null, true);
var temp_ref = get_variable_cexpression (temp_var.name);
......
......@@ -80,7 +80,7 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
} else if (get_ccode_array_length (m) && m.return_type is ArrayType) {
// return array length if appropriate
var array_type = (ArrayType) m.return_type;
var length_ctype = get_ccode_array_length_type (array_type) + "*";
var length_ctype = (get_ccode_array_length_type (m) ?? get_ccode_array_length_type (array_type)) + "*";
for (int dim = 1; dim <= array_type.rank; dim++) {
var cparam = new CCodeParameter (get_array_length_cname ("result", dim), length_ctype);
......
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