Mercurial > projects > ldc
changeset 90:16e88334bba7 trunk
[svn r94] started on complex support
calling final class methods was being treated as a virtual call failing an assertion.
author | lindquist |
---|---|
date | Wed, 07 Nov 2007 03:36:07 +0100 |
parents | ccca1c13e13a |
children | 3f949c6e2e9d |
files | dmd/expression.h gen/toir.cpp gen/tollvm.cpp gen/tollvm.h test/bug53.d test/classinfo1.d test/complex1.d |
diffstat | 7 files changed, 59 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/dmd/expression.h Wed Nov 07 02:45:47 2007 +0100 +++ b/dmd/expression.h Wed Nov 07 03:36:07 2007 +0100 @@ -233,6 +233,8 @@ #endif elem *toElem(IRState *irs); dt_t **toDt(dt_t **pdt); + // LLVMDC + virtual llvm::Constant *toConstElem(IRState *irs); }; struct IdentifierExp : Expression
--- a/gen/toir.cpp Wed Nov 07 02:45:47 2007 +0100 +++ b/gen/toir.cpp Wed Nov 07 03:36:07 2007 +0100 @@ -318,6 +318,24 @@ ////////////////////////////////////////////////////////////////////////////////////////// +DValue* ComplexExp::toElem(IRState* p) +{ + Logger::print("ComplexExp::toElem(): %s | %s\n", toChars(), type->toChars()); + LOG_SCOPE; + assert(0); +} + +////////////////////////////////////////////////////////////////////////////////////////// + +llvm::Constant* ComplexExp::toConstElem(IRState* p) +{ + Logger::print("ComplexExp::toConstElem(): %s | %s\n", toChars(), type->toChars()); + LOG_SCOPE; + assert(0); +} + +////////////////////////////////////////////////////////////////////////////////////////// + DValue* StringExp::toElem(IRState* p) { Logger::print("StringExp::toElem: %s | %s\n", toChars(), type->toChars()); @@ -1631,7 +1649,7 @@ unsigned cc = (unsigned)-1; // virtual call - if (fdecl->isVirtual()) { + if (!fdecl->isFinal() && fdecl->isVirtual()) { assert(fdecl->vtblIndex > 0); assert(e1type->ty == Tclass); @@ -2858,7 +2876,7 @@ STUB(TypeExp); //STUB(RealExp); -STUB(ComplexExp); +//STUB(ComplexExp); //STUB(StringExp); //STUB(IntegerExp); STUB(BoolExp); @@ -2885,6 +2903,7 @@ //CONSTSTUB(IntegerExp); //CONSTSTUB(RealExp); //CONSTSTUB(NullExp); +//CONSTSTUB(ComplexExp); //CONSTSTUB(StringExp); //CONSTSTUB(VarExp); //CONSTSTUB(ArrayLiteralExp);
--- a/gen/tollvm.cpp Wed Nov 07 02:45:47 2007 +0100 +++ b/gen/tollvm.cpp Wed Nov 07 03:36:07 2007 +0100 @@ -69,9 +69,10 @@ // complex case Tcomplex32: + return DtoComplexType(llvm::Type::FloatTy); case Tcomplex64: case Tcomplex80: - assert(0 && "complex number types not yet implemented"); + return DtoComplexType(llvm::Type::DoubleTy); // pointers case Tpointer: { @@ -376,6 +377,16 @@ ////////////////////////////////////////////////////////////////////////////////////////// +const llvm::StructType* DtoComplexType(const llvm::Type* base) +{ + std::vector<const llvm::Type*> types; + types.push_back(base); + types.push_back(base); + return llvm::StructType::get(types); +} + +////////////////////////////////////////////////////////////////////////////////////////// + static llvm::Function* LLVM_DeclareMemIntrinsic(const char* name, int bits, bool set=false) { assert(bits == 32 || bits == 64);
--- a/gen/tollvm.h Wed Nov 07 02:45:47 2007 +0100 +++ b/gen/tollvm.h Wed Nov 07 03:36:07 2007 +0100 @@ -26,6 +26,8 @@ const llvm::Type* DtoSize_t(); +const llvm::StructType* DtoComplexType(const llvm::Type* base); + void DtoMain(); void DtoCallClassDtors(TypeClass* tc, llvm::Value* instance);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug53.d Wed Nov 07 03:36:07 2007 +0100 @@ -0,0 +1,6 @@ +module bug53; +class Foo { + final void bar() {} + void test() { bar(); } +} +void main() {}