Mercurial > projects > ldc
comparison gen/llvmhelpers.cpp @ 294:94435b0ab2dd trunk
[svn r315] Build full const initializer for static arrays in DtoConstInitializer if necessary.
author | ChristianK |
---|---|
date | Sun, 22 Jun 2008 21:36:07 +0200 |
parents | 068cb3c60afb |
children | 895e1b50cf2a |
comparison
equal
deleted
inserted
replaced
293:ebfa488f4abc | 294:94435b0ab2dd |
---|---|
967 { | 967 { |
968 LLConstant* _init = 0; // may return zero | 968 LLConstant* _init = 0; // may return zero |
969 if (!init) | 969 if (!init) |
970 { | 970 { |
971 Logger::println("const default initializer for %s", type->toChars()); | 971 Logger::println("const default initializer for %s", type->toChars()); |
972 _init = type->defaultInit()->toConstElem(gIR); | 972 |
973 if(type->ty == Tsarray) | |
974 { | |
975 Logger::println("type is a static array, building constant array initializer"); | |
976 TypeSArray* arrtype = (TypeSArray*)type; | |
977 Type* elemtype = type->next; | |
978 | |
979 integer_t arraydim; | |
980 arraydim = arrtype->dim->toInteger(); | |
981 | |
982 std::vector<LLConstant*> inits(arraydim, elemtype->defaultInit()->toConstElem(gIR)); | |
983 const LLArrayType* arrty = LLArrayType::get(DtoType(elemtype),arraydim); | |
984 _init = LLConstantArray::get(arrty, inits); | |
985 } | |
986 else | |
987 _init = type->defaultInit()->toConstElem(gIR); | |
973 } | 988 } |
974 else if (ExpInitializer* ex = init->isExpInitializer()) | 989 else if (ExpInitializer* ex = init->isExpInitializer()) |
975 { | 990 { |
976 Logger::println("const expression initializer"); | 991 Logger::println("const expression initializer"); |
977 _init = ex->exp->toConstElem(gIR); | 992 _init = ex->exp->toConstElem(gIR); |