Mercurial > projects > ldc
comparison gen/functions.cpp @ 1155:ba9d6292572a
Fixed forward reference problem in struct methods on x86-64.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Sat, 28 Mar 2009 09:00:32 +0100 |
parents | 521dd1626d76 |
children | 0424e7dfadb1 |
comparison
equal
deleted
inserted
replaced
1154:9279a9dc6df3 | 1155:ba9d6292572a |
---|---|
301 if (!global.params.useUnitTests && fdecl->isUnitTestDeclaration()) { | 301 if (!global.params.useUnitTests && fdecl->isUnitTestDeclaration()) { |
302 Logger::println("Ignoring unittest %s", fdecl->toPrettyChars()); | 302 Logger::println("Ignoring unittest %s", fdecl->toPrettyChars()); |
303 return; // ignore declaration completely | 303 return; // ignore declaration completely |
304 } | 304 } |
305 | 305 |
306 if (AggregateDeclaration* ad = fdecl->isMember()) | |
307 { | |
308 ad->codegen(Type::sir); | |
309 if (ad->isStructDeclaration() && llvm::isa<llvm::OpaqueType>(DtoType(ad->type))) | |
310 { | |
311 ad->ir.irStruct->structFuncs.push_back(fdecl); | |
312 return; | |
313 } | |
314 } | |
315 | |
306 //printf("resolve function: %s\n", fdecl->toPrettyChars()); | 316 //printf("resolve function: %s\n", fdecl->toPrettyChars()); |
307 | 317 |
308 if (fdecl->parent) | 318 if (fdecl->parent) |
309 if (TemplateInstance* tinst = fdecl->parent->isTemplateInstance()) | 319 if (TemplateInstance* tinst = fdecl->parent->isTemplateInstance()) |
310 { | 320 { |
432 | 442 |
433 ////////////////////////////////////////////////////////////////////////////////////////// | 443 ////////////////////////////////////////////////////////////////////////////////////////// |
434 | 444 |
435 void DtoDeclareFunction(FuncDeclaration* fdecl) | 445 void DtoDeclareFunction(FuncDeclaration* fdecl) |
436 { | 446 { |
447 DtoResolveFunction(fdecl); | |
448 | |
437 if (fdecl->ir.declared) return; | 449 if (fdecl->ir.declared) return; |
438 fdecl->ir.declared = true; | 450 fdecl->ir.declared = true; |
439 | 451 |
440 Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); | 452 Logger::println("DtoDeclareFunction(%s): %s", fdecl->toPrettyChars(), fdecl->loc.toChars()); |
441 LOG_SCOPE; | 453 LOG_SCOPE; |
475 // construct function | 487 // construct function |
476 const llvm::FunctionType* functype = DtoFunctionType(fdecl); | 488 const llvm::FunctionType* functype = DtoFunctionType(fdecl); |
477 llvm::Function* func = vafunc ? vafunc : gIR->module->getFunction(mangled_name); | 489 llvm::Function* func = vafunc ? vafunc : gIR->module->getFunction(mangled_name); |
478 if (!func) | 490 if (!func) |
479 func = llvm::Function::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module); | 491 func = llvm::Function::Create(functype, DtoLinkage(fdecl), mangled_name, gIR->module); |
492 | |
493 if (Logger::enabled()) | |
494 Logger::cout() << "func = " << *func << std::endl; | |
480 | 495 |
481 // add func to IRFunc | 496 // add func to IRFunc |
482 fdecl->ir.irFunc->func = func; | 497 fdecl->ir.irFunc->func = func; |
483 | 498 |
484 // calling convention | 499 // calling convention |
592 | 607 |
593 // FIXME: this isn't too pretty! | 608 // FIXME: this isn't too pretty! |
594 | 609 |
595 void DtoDefineFunction(FuncDeclaration* fd) | 610 void DtoDefineFunction(FuncDeclaration* fd) |
596 { | 611 { |
612 DtoDeclareFunction(fd); | |
613 | |
597 if (fd->ir.defined) return; | 614 if (fd->ir.defined) return; |
598 fd->ir.defined = true; | 615 fd->ir.defined = true; |
599 | 616 |
600 assert(fd->ir.declared); | 617 assert(fd->ir.declared); |
601 | 618 |