comparison gen/toir.cpp @ 587:23538d0f0d5b

Fixed a few mini tests issues. Added 'darwin' and 'Posix' as versions user can't set. Fixed #80 .
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Thu, 11 Sep 2008 21:10:15 +0200
parents fbb1a366cfbc
children e6bcc4d9e5ff
comparison
equal deleted inserted replaced
586:192b82878b78 587:23538d0f0d5b
2154 // llvm target type 2154 // llvm target type
2155 const LLType* llType = DtoType(arrayType); 2155 const LLType* llType = DtoType(arrayType);
2156 Logger::cout() << (dyn?"dynamic":"static") << " array literal with length " << len << " of D type: '" << arrayType->toChars() << "' has llvm type: '" << *llType << "'\n"; 2156 Logger::cout() << (dyn?"dynamic":"static") << " array literal with length " << len << " of D type: '" << arrayType->toChars() << "' has llvm type: '" << *llType << "'\n";
2157 2157
2158 // llvm storage type 2158 // llvm storage type
2159 const LLType* llStoType = LLArrayType::get(DtoType(elemType), len); 2159 const LLType* llElemType = DtoTypeNotVoid(elemType);
2160 const LLType* llStoType = LLArrayType::get(llElemType, len);
2160 Logger::cout() << "llvm storage type: '" << *llStoType << "'\n"; 2161 Logger::cout() << "llvm storage type: '" << *llStoType << "'\n";
2161 2162
2163 // don't allocate storage for zero length dynamic array literals
2164 if (dyn && len == 0)
2165 {
2166 // dmd seems to just make them null...
2167 return new DSliceValue(type, DtoConstSize_t(0), getNullPtr(getPtrToType(llElemType)));
2168 }
2169
2162 // dst pointer 2170 // dst pointer
2163 LLValue* dstMem = 0; 2171 // FIXME: dynamic array literals should be allocated with the GC
2164 dstMem = DtoAlloca(llStoType, "arrayliteral"); 2172 LLValue* dstMem = DtoAlloca(llStoType, "arrayliteral");
2165 2173
2166 // store elements 2174 // store elements
2167 for (size_t i=0; i<len; ++i) 2175 for (size_t i=0; i<len; ++i)
2168 { 2176 {
2169 Expression* expr = (Expression*)elements->data[i]; 2177 Expression* expr = (Expression*)elements->data[i];