]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Use append_array_size for array creation expressions
authorJürg Billeter <j@bitron.ch>
Sat, 9 Oct 2010 14:03:27 +0000 (16:03 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 9 Oct 2010 14:03:27 +0000 (16:03 +0200)
codegen/valaccodearraymodule.vala

index 276f5c73d727036b7f1b7a0c9cacc991cce224c2..09772cb3e52d9661379ce0d297579fe2ea441472 100644 (file)
@@ -83,6 +83,10 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                                emit_temp_var (temp_var);
 
                                csize = new CCodeAssignment (name_cnode, csize);
+
+                               append_array_size (expr, name_cnode);
+                       } else {
+                               append_array_size (expr, csize);
                        }
 
                        if (first) {
@@ -171,11 +175,7 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                        array_expr = reftransfer_expr.inner;
                }
                
-               if (array_expr is ArrayCreationExpression) {
-                       List<Expression> size = ((ArrayCreationExpression) array_expr).get_sizes ();
-                       var length_expr = size[dim - 1];
-                       return (CCodeExpression) get_ccodenode (length_expr);
-               } else if (array_expr is MethodCall || array_expr is CastExpression || array_expr is SliceExpression) {
+               if (array_expr is ArrayCreationExpression || array_expr is MethodCall || array_expr is CastExpression || array_expr is SliceExpression) {
                        List<CCodeExpression> size = get_array_sizes (array_expr);
                        if (size != null && size.size >= dim) {
                                return size[dim - 1];