[vala/staging] codegen: Keep respecting CCode array_length_type of Parameter/Method/Delegate



commit ec232b6e04d52149be040bf6aa6ac290e29b1444
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Oct 31 11:09:21 2018 +0100

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

 codegen/valaccode.vala                 | 1 +
 codegen/valaccodearraymodule.vala      | 2 +-
 codegen/valaccodedelegatemodule.vala   | 4 ++--
 codegen/valaccodemethodcallmodule.vala | 6 +++---
 codegen/valaccodemethodmodule.vala     | 2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)
---
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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]