From: Rico Tzschichholz Date: Wed, 31 Oct 2018 10:09:21 +0000 (+0100) Subject: codegen: Keep respecting CCode array_length_type of Parameter/Method/Delegate X-Git-Tag: 0.43.1~150 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc1af8f5d86041e6c5aea01d747c2af29d979a22;p=thirdparty%2Fvala.git codegen: Keep respecting CCode array_length_type of Parameter/Method/Delegate --- diff --git a/codegen/valaccode.vala b/codegen/valaccode.vala index bc29b259d..ac9b5ead6 100644 --- a/codegen/valaccode.vala +++ b/codegen/valaccode.vala @@ -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; } } diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala index c3ad53fc7..38a4d773a 100644 --- a/codegen/valaccodearraymodule.vala +++ b/codegen/valaccodearraymodule.vala @@ -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); } diff --git a/codegen/valaccodedelegatemodule.vala b/codegen/valaccodedelegatemodule.vala index 8251e4fa9..7ef39e395 100644 --- a/codegen/valaccodedelegatemodule.vala +++ b/codegen/valaccodedelegatemodule.vala @@ -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); diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala index 8b92c78c2..82411bf17 100644 --- a/codegen/valaccodemethodcallmodule.vala +++ b/codegen/valaccodemethodcallmodule.vala @@ -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); diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala index b8740002f..5aba1446e 100644 --- a/codegen/valaccodemethodmodule.vala +++ b/codegen/valaccodemethodmodule.vala @@ -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);