Mercurial > projects > ldc
comparison gen/classes.cpp @ 414:ac1fcc138e42
Fixed issue with internal real representation, incorrect for non x86-32 architectures.
Cleaned up CallExp::toElem, moved implementation to tocall.cpp providing a single procedure to call arbitrary D functions fairly easily.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Mon, 28 Jul 2008 02:11:34 +0200 |
parents | 051ab876fe11 |
children | fa91b03d9cd7 |
comparison
equal
deleted
inserted
replaced
413:1a9bdbd4ac60 | 414:ac1fcc138e42 |
---|---|
789 | 789 |
790 // allocate | 790 // allocate |
791 LLValue* mem; | 791 LLValue* mem; |
792 if (newexp->onstack) | 792 if (newexp->onstack) |
793 { | 793 { |
794 mem = new llvm::AllocaInst(DtoType(tc)->getContainedType(0), "newclass_alloca", gIR->topallocapoint()); | 794 mem = new llvm::AllocaInst(DtoType(tc)->getContainedType(0), ".newclass_alloca", gIR->topallocapoint()); |
795 } | 795 } |
796 // custom allocator | 796 // custom allocator |
797 else if (newexp->allocator) | 797 else if (newexp->allocator) |
798 { | 798 { |
799 DValue* res = DtoCallDFunc(newexp->allocator, newexp->newargs); | 799 DtoForceDeclareDsymbol(newexp->allocator); |
800 mem = DtoBitCast(res->getRVal(), DtoType(tc), "newclass_custom"); | 800 DFuncValue dfn(newexp->allocator, newexp->allocator->ir.irFunc->func); |
801 DValue* res = DtoCallFunction(NULL, &dfn, newexp->newargs); | |
802 mem = DtoBitCast(res->getRVal(), DtoType(tc), ".newclass_custom"); | |
801 } | 803 } |
802 // default allocator | 804 // default allocator |
803 else | 805 else |
804 { | 806 { |
805 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_newclass"); | 807 llvm::Function* fn = LLVM_D_GetRuntimeFunction(gIR->module, "_d_newclass"); |
806 mem = gIR->CreateCallOrInvoke(fn, tc->sym->ir.irStruct->classInfo, "newclass_gc_alloc")->get(); | 808 mem = gIR->CreateCallOrInvoke(fn, tc->sym->ir.irStruct->classInfo, ".newclass_gc_alloc")->get(); |
807 mem = DtoBitCast(mem, DtoType(tc), "newclass_gc"); | 809 mem = DtoBitCast(mem, DtoType(tc), ".newclass_gc"); |
808 } | 810 } |
809 | 811 |
810 // init | 812 // init |
811 DtoInitClass(tc, mem); | 813 DtoInitClass(tc, mem); |
812 | 814 |
846 | 848 |
847 // call constructor | 849 // call constructor |
848 if (newexp->member) | 850 if (newexp->member) |
849 { | 851 { |
850 assert(newexp->arguments != NULL); | 852 assert(newexp->arguments != NULL); |
851 return DtoCallDFunc(newexp->member, newexp->arguments, tc, mem); | 853 DtoForceDeclareDsymbol(newexp->member); |
854 DFuncValue dfn(newexp->member, newexp->member->ir.irFunc->func, mem); | |
855 return DtoCallFunction(tc, &dfn, newexp->arguments); | |
852 } | 856 } |
853 | 857 |
854 // return default constructed class | 858 // return default constructed class |
855 return new DImValue(tc, mem, false); | 859 return new DImValue(tc, mem, false); |
856 } | 860 } |