comparison gen/tollvm.cpp @ 328:7086a84ab3d6 trunk

[svn r349] Fixed problems with static arrays of void as well as a static arrays with zero length. Fixed issues with DMD generated assert statements when using class invariants, generally due to incomplete ASTs. Removed some dead code. Added a few comments.
author lindquist
date Fri, 11 Jul 2008 00:17:00 +0200
parents 0d52412d5b1a
children e20ce6d8d374
comparison
equal deleted inserted replaced
327:781af50846b2 328:7086a84ab3d6
87 case Tcomplex80: 87 case Tcomplex80:
88 return DtoComplexType(t); 88 return DtoComplexType(t);
89 89
90 // pointers 90 // pointers
91 case Tpointer: 91 case Tpointer:
92 // getPtrToType checks for void itself
92 return getPtrToType(DtoType(t->next)); 93 return getPtrToType(DtoType(t->next));
93 94
94 // arrays 95 // arrays
95 case Tarray: 96 case Tarray:
96 return DtoArrayType(t); 97 return DtoArrayType(t);
150 151
151 // associative arrays 152 // associative arrays
152 case Taarray: 153 case Taarray:
153 { 154 {
154 TypeAArray* taa = (TypeAArray*)t; 155 TypeAArray* taa = (TypeAArray*)t;
156 // aa key/val can't be void
155 return getPtrToType(LLStructType::get(DtoType(taa->key), DtoType(taa->next), 0)); 157 return getPtrToType(LLStructType::get(DtoType(taa->key), DtoType(taa->next), 0));
156 } 158 }
157 159
158 default: 160 default:
159 printf("trying to convert unknown type with value %d\n", t->ty); 161 printf("trying to convert unknown type with value %d\n", t->ty);
160 assert(0); 162 assert(0);
161 } 163 }
162 return 0; 164 return 0;
165 }
166
167 //////////////////////////////////////////////////////////////////////////////////////////
168
169 const LLType* DtoTypeNotVoid(Type* t)
170 {
171 const LLType* lt = DtoType(t);
172 if (lt == LLType::VoidTy)
173 return LLType::Int8Ty;
174 return lt;
163 } 175 }
164 176
165 ////////////////////////////////////////////////////////////////////////////////////////// 177 //////////////////////////////////////////////////////////////////////////////////////////
166 178
167 const LLStructType* DtoDelegateType(Type* t) 179 const LLStructType* DtoDelegateType(Type* t)
497 509
498 ////////////////////////////////////////////////////////////////////////////////////////// 510 //////////////////////////////////////////////////////////////////////////////////////////
499 511
500 LLConstant* DtoConstString(const char* str) 512 LLConstant* DtoConstString(const char* str)
501 { 513 {
502 std::string s(str); 514 std::string s(str?str:"");
503 LLConstant* init = llvm::ConstantArray::get(s, true); 515 LLConstant* init = llvm::ConstantArray::get(s, true);
504 llvm::GlobalVariable* gvar = new llvm::GlobalVariable( 516 llvm::GlobalVariable* gvar = new llvm::GlobalVariable(
505 init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str", gIR->module); 517 init->getType(), true,llvm::GlobalValue::InternalLinkage, init, ".str", gIR->module);
506 LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) }; 518 LLConstant* idxs[2] = { DtoConstUint(0), DtoConstUint(0) };
507 return DtoConstSlice( 519 return DtoConstSlice(