diff gen/toobj.c @ 64:b688ad419f8c trunk

[svn r68] Added support for multi-dimensional static arrays. Several bugfixes to array support.
author lindquist
date Thu, 25 Oct 2007 12:09:13 +0200
parents 2c39b5292cf3
children f918f3e2e99e
line wrap: on
line diff
--- a/gen/toobj.c	Thu Oct 25 10:05:21 2007 +0200
+++ b/gen/toobj.c	Thu Oct 25 12:09:13 2007 +0200
@@ -35,6 +35,7 @@
 #include "gen/elem.h"
 #include "gen/logger.h"
 #include "gen/tollvm.h"
+#include "gen/arrays.h"
 
 //////////////////////////////////////////////////////////////////////////////////////////
 
@@ -546,15 +547,7 @@
                 // array single value init
                 else if (llvm::isa<llvm::ArrayType>(_type))
                 {
-                    const llvm::ArrayType* at = llvm::cast<llvm::ArrayType>(_type);
-                    if (at->getElementType() == _init->getType()) {
-                        std::vector<llvm::Constant*> initvals;
-                        initvals.resize(at->getNumElements(), _init);
-                        _init = llvm::ConstantArray::get(at, initvals);
-                    }
-                    else {
-                        assert(0);
-                    }
+                    _init = LLVM_DtoConstantStaticArray(_type, _init);
                 }
                 else {
                     Logger::cout() << "Unexpected initializer type: " << *_type << '\n';
@@ -562,6 +555,7 @@
                 }
             }
 
+            Logger::cout() << "final init = " << *_init << '\n';
             gvar->setInitializer(_init);
         }