Mercurial > projects > ldc
comparison gen/structs.cpp @ 1149:5ebe8224988b
Fixed problems introduced by previous commits that prevented Tango from compiling.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Fri, 27 Mar 2009 23:17:04 +0100 |
parents | 3d1b16dabd25 |
children | 3cf0066e6faf |
comparison
equal
deleted
inserted
replaced
1148:3d1b16dabd25 | 1149:5ebe8224988b |
---|---|
95 // get TypeStruct | 95 // get TypeStruct |
96 assert(si->ad); | 96 assert(si->ad); |
97 TypeStruct* ts = (TypeStruct*)si->ad->type; | 97 TypeStruct* ts = (TypeStruct*)si->ad->type; |
98 | 98 |
99 // force constant initialization of the symbol | 99 // force constant initialization of the symbol |
100 si->ad->codegen(Type::sir);; | 100 si->ad->codegen(Type::sir); |
101 | |
102 // get formal type | |
103 const llvm::StructType* structtype = isaStruct(ts->ir.type->get()); | |
104 | |
105 #if 0 | |
106 // log it | |
107 if (Logger::enabled()) | |
108 Logger::cout() << "llvm struct type: " << *structtype << '\n'; | |
109 #endif | |
110 | 101 |
111 // sanity check | 102 // sanity check |
112 assert(si->value.dim > 0); | 103 assert(si->value.dim > 0); |
113 assert(si->value.dim == si->vars.dim); | 104 assert(si->value.dim == si->vars.dim); |
114 | 105 |
239 lastoffset = offset; | 230 lastoffset = offset; |
240 lastsize = size; | 231 lastsize = size; |
241 } | 232 } |
242 | 233 |
243 // there might still be padding after the last one, make sure that is defaulted/zeroed as well | 234 // there might still be padding after the last one, make sure that is defaulted/zeroed as well |
244 size_t structsize = getTypePaddedSize(structtype); | 235 size_t structsize = si->ad->structsize; |
245 | 236 |
246 // if there is space before the next explicit initializer | 237 // if there is space before the next explicit initializer |
247 // FIXME: this should be handled in the loop above as well | 238 // FIXME: this should be handled in the loop above as well |
248 Lpadding2: | 239 Lpadding2: |
249 size_t pos = lastoffset+lastsize; | 240 size_t pos = lastoffset+lastsize; |
643 } | 634 } |
644 | 635 |
645 // refine __initZ global type to the one of the initializer | 636 // refine __initZ global type to the one of the initializer |
646 llvm::cast<llvm::OpaqueType>(irstruct->initOpaque.get())->refineAbstractTypeTo(irstruct->constInit->getType()); | 637 llvm::cast<llvm::OpaqueType>(irstruct->initOpaque.get())->refineAbstractTypeTo(irstruct->constInit->getType()); |
647 | 638 |
639 // build initializers for static member variables | |
640 size_t n = irstruct->staticVars.size(); | |
641 for (size_t i = 0; i < n; ++i) | |
642 { | |
643 DtoConstInitGlobal(irstruct->staticVars[i]); | |
644 } | |
645 // This is all we use it for. Clear the memory! | |
646 irstruct->staticVars.clear(); | |
647 | |
648 gIR->structs.pop_back(); | 648 gIR->structs.pop_back(); |
649 | 649 |
650 // emit typeinfo | 650 // emit typeinfo |
651 if (sd->getModule() == gIR->dmodule && sd->llvmInternal != LLVMno_typeinfo) | 651 if (sd->getModule() == gIR->dmodule && sd->llvmInternal != LLVMno_typeinfo) |
652 DtoTypeInfoOf(sd->type, false); | 652 DtoTypeInfoOf(sd->type, false); |