# HG changeset patch # User lindquist # Date 1194402967 -3600 # Node ID 16e88334bba7040512fbbd882e0b4d4eb6648308 # Parent ccca1c13e13a8661b12e8be413b8661434482ddd [svn r94] started on complex support calling final class methods was being treated as a virtual call failing an assertion. diff -r ccca1c13e13a -r 16e88334bba7 dmd/expression.h --- 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 diff -r ccca1c13e13a -r 16e88334bba7 gen/toir.cpp --- 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); diff -r ccca1c13e13a -r 16e88334bba7 gen/tollvm.cpp --- 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 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); diff -r ccca1c13e13a -r 16e88334bba7 gen/tollvm.h --- 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); diff -r ccca1c13e13a -r 16e88334bba7 test/bug53.d --- /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() {} diff -r ccca1c13e13a -r 16e88334bba7 test/classinfo1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/classinfo1.d Wed Nov 07 03:36:07 2007 +0100 @@ -0,0 +1,10 @@ +module classinfo1; + +class C +{ +} + +void main() +{ + auto ci = C.classinfo; +} diff -r ccca1c13e13a -r 16e88334bba7 test/complex1.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/complex1.d Wed Nov 07 03:36:07 2007 +0100 @@ -0,0 +1,6 @@ +module complex1; + +void main() +{ + cfloat c1; +}