]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Fix initialization of static array fields, fixes bug 472545
authorJürg Billeter <j@bitron.ch>
Wed, 17 Dec 2008 22:55:10 +0000 (22:55 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Wed, 17 Dec 2008 22:55:10 +0000 (22:55 +0000)
2008-12-17  Jürg Billeter  <j@bitron.ch>

* gobject/valaccodebasemodule.vala:

Fix initialization of static array fields, fixes bug 472545

svn path=/trunk/; revision=2205

ChangeLog
gobject/valaccodebasemodule.vala

index c52ece6913d1f81fd6e15165b39ff22eb95e7eb5..1aa899611c0af83e9af5dc50b13fa8addef8ac4a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-17  Jürg Billeter  <j@bitron.ch>
+
+       * gobject/valaccodebasemodule.vala:
+
+       Fix initialization of static array fields, fixes bug 472545
+
 2008-12-17  Jürg Billeter  <j@bitron.ch>
 
        * vapi/glib-2.0.vapi:
index e3d566d36fa738a6ebc0b697058db01a4892ab3b..6721b218d72e250e3220f90eba24e73f432a9ce1 100644 (file)
@@ -973,6 +973,23 @@ public class Vala.CCodeBaseModule : CCodeModule {
                                if (!is_constant_ccode_expression (rhs)) {
                                        if (f.parent_symbol is Class) {
                                                class_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (lhs, rhs)));
+
+                                               if (f.field_type is ArrayType && !f.no_array_length &&
+                                                   f.initializer is ArrayCreationExpression) {
+                                                       var array_type = (ArrayType) f.field_type;
+                                                       var ma = new MemberAccess.simple (f.name);
+                                                       ma.symbol_reference = f;
+                                       
+                                                       Gee.List<Expression> sizes = ((ArrayCreationExpression) f.initializer).get_sizes ();
+                                                       for (int dim = 1; dim <= array_type.rank; dim++) {
+                                                               var array_len_lhs = head.get_array_length_cexpression (ma, dim);
+                                                               var size = sizes[dim - 1];
+                                                               class_init_fragment.append (new CCodeExpressionStatement (new CCodeAssignment (array_len_lhs, (CCodeExpression) size.ccodenode)));
+                                                       }
+                                               }
+
+                                               append_temp_decl (class_init_fragment, temp_vars);
+                                               temp_vars.clear ();
                                        } else {
                                                f.error = true;
                                                Report.error (f.source_reference, "Non-constant field initializers not supported in this context");