Mercurial > projects > ldc
comparison gen/toobj.cpp @ 102:027b8d8b71ec trunk
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
Basically it tries to do the following in order: Resolve types, Declare symbols, Create constant initializers, Apply initializers, Generate functions bodies.
ClassInfo is now has the most useful(biased?) members working.
Probably other stuf...
author | lindquist |
---|---|
date | Sun, 18 Nov 2007 06:52:57 +0100 |
parents | 5071469303d4 |
children | 855adfdb8d38 |
comparison
equal
deleted
inserted
replaced
101:169fda3a77d4 | 102:027b8d8b71ec |
---|---|
90 Dsymbol* dsym = (Dsymbol*)(members->data[k]); | 90 Dsymbol* dsym = (Dsymbol*)(members->data[k]); |
91 assert(dsym); | 91 assert(dsym); |
92 dsym->toObjFile(); | 92 dsym->toObjFile(); |
93 } | 93 } |
94 | 94 |
95 // process deferred const initializers | 95 // main driver loop |
96 for (size_t i=0; i<ir.constInitQueue.size(); ++i) { | 96 for(;;) |
97 DtoConstInitDsymbol(ir.constInitQueue[i]); | 97 { |
98 } | 98 Dsymbol* dsym; |
99 | 99 if (!ir.resolveList.empty()) { |
100 // process deferred definitions | 100 dsym = ir.resolveList.front(); |
101 for (size_t i=0; i<ir.defineQueue.size(); ++i) { | 101 ir.resolveList.pop_front(); |
102 DtoDefineDsymbol(ir.defineQueue[i]); | 102 DtoResolveDsymbol(dsym); |
103 } | |
104 else if (!ir.declareList.empty()) { | |
105 dsym = ir.declareList.front(); | |
106 ir.declareList.pop_front(); | |
107 DtoDeclareDsymbol(dsym); | |
108 } | |
109 else if (!ir.constInitList.empty()) { | |
110 dsym = ir.constInitList.front(); | |
111 ir.constInitList.pop_front(); | |
112 DtoConstInitDsymbol(dsym); | |
113 } | |
114 else if (!ir.defineList.empty()) { | |
115 dsym = ir.defineList.front(); | |
116 ir.defineList.pop_front(); | |
117 DtoDefineDsymbol(dsym); | |
118 } | |
119 else { | |
120 break; | |
121 } | |
103 } | 122 } |
104 | 123 |
105 // generate ModuleInfo | 124 // generate ModuleInfo |
106 genmoduleinfo(); | 125 genmoduleinfo(); |
107 | 126 |
324 | 343 |
325 /* ================================================================== */ | 344 /* ================================================================== */ |
326 | 345 |
327 void StructDeclaration::toObjFile() | 346 void StructDeclaration::toObjFile() |
328 { | 347 { |
329 DtoDeclareStruct(this); | 348 gIR->resolveList.push_back(this); |
330 } | 349 } |
331 | 350 |
332 /* ================================================================== */ | 351 /* ================================================================== */ |
333 | 352 |
334 static unsigned LLVM_ClassOffsetToIndex(ClassDeclaration* cd, unsigned os, unsigned& idx) | 353 static unsigned LLVM_ClassOffsetToIndex(ClassDeclaration* cd, unsigned os, unsigned& idx) |
362 | 381 |
363 /* ================================================================== */ | 382 /* ================================================================== */ |
364 | 383 |
365 void ClassDeclaration::toObjFile() | 384 void ClassDeclaration::toObjFile() |
366 { | 385 { |
367 DtoDeclareClass(this); | 386 gIR->resolveList.push_back(this); |
368 } | 387 } |
369 | 388 |
370 /****************************************** | 389 /****************************************** |
371 * Get offset of base class's vtbl[] initializer from start of csym. | 390 * Get offset of base class's vtbl[] initializer from start of csym. |
372 * Returns ~0 if not this csym. | 391 * Returns ~0 if not this csym. |
392 } | 411 } |
393 | 412 |
394 // global variable or magic | 413 // global variable or magic |
395 if (isDataseg()) | 414 if (isDataseg()) |
396 { | 415 { |
397 if (llvmTouched) return; | 416 if (llvmResolved) return; |
398 else llvmTouched = true; | 417 llvmResolved = true; |
418 llvmDeclared = true; | |
399 | 419 |
400 llvmIRGlobal = new IRGlobal(this); | 420 llvmIRGlobal = new IRGlobal(this); |
401 | 421 |
402 Logger::println("parent: %s (%s)", parent->toChars(), parent->kind()); | 422 Logger::println("parent: %s (%s)", parent->toChars(), parent->kind()); |
403 | 423 |
428 llvmValue = gvar; | 448 llvmValue = gvar; |
429 | 449 |
430 if (static_local) | 450 if (static_local) |
431 DtoConstInitGlobal(this); | 451 DtoConstInitGlobal(this); |
432 else | 452 else |
433 gIR->constInitQueue.push_back(this); | 453 gIR->constInitList.push_back(this); |
434 | 454 |
435 //if (storage_class & STCprivate) | 455 //if (storage_class & STCprivate) |
436 // gvar->setVisibility(llvm::GlobalValue::ProtectedVisibility); | 456 // gvar->setVisibility(llvm::GlobalValue::ProtectedVisibility); |
437 } | 457 } |
438 | 458 |
471 | 491 |
472 /* ================================================================== */ | 492 /* ================================================================== */ |
473 | 493 |
474 void FuncDeclaration::toObjFile() | 494 void FuncDeclaration::toObjFile() |
475 { | 495 { |
476 DtoDeclareFunction(this); | 496 gIR->resolveList.push_back(this); |
477 } | 497 } |