Mercurial > projects > ldc
comparison ir/irstruct.cpp @ 800:d14e4594c7d7
Changed aggregate field initializers to be created lazily, fixes problem with static void arrays in aggregates.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 29 Nov 2008 18:28:17 +0100 |
parents | 340acf1535d0 |
children | 28ce72c60a21 |
comparison
equal
deleted
inserted
replaced
797:340acf1535d0 | 800:d14e4594c7d7 |
---|---|
7 | 7 |
8 #include "ir/irstruct.h" | 8 #include "ir/irstruct.h" |
9 #include "gen/irstate.h" | 9 #include "gen/irstate.h" |
10 #include "gen/tollvm.h" | 10 #include "gen/tollvm.h" |
11 #include "gen/logger.h" | 11 #include "gen/logger.h" |
12 #include "gen/llvmhelpers.h" | |
12 | 13 |
13 IrInterface::IrInterface(BaseClass* b) | 14 IrInterface::IrInterface(BaseClass* b) |
14 : vtblInitTy(llvm::OpaqueType::get()) | 15 : vtblInitTy(llvm::OpaqueType::get()) |
15 { | 16 { |
16 base = b; | 17 base = b; |
316 size_t pos = lastoffset + lastsize; | 317 size_t pos = lastoffset + lastsize; |
317 addZeros(inits, pos, offset); | 318 addZeros(inits, pos, offset); |
318 } | 319 } |
319 | 320 |
320 // add the field | 321 // add the field |
321 assert(var->ir.irField->constInit); | 322 // lazily default initialize |
323 if (!var->ir.irField->constInit) | |
324 var->ir.irField->constInit = DtoConstFieldInitializer(var->loc, var->type, var->init); | |
322 inits.push_back(var->ir.irField->constInit); | 325 inits.push_back(var->ir.irField->constInit); |
323 | 326 |
324 lastoffset = offset; | 327 lastoffset = offset; |
325 lastsize = var->type->size(); | 328 lastsize = var->type->size(); |
326 } | 329 } |