From c36bd9f4b07e548c8de0352b74fa8e0d37bde209 Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Wed, 12 Nov 2008 02:30:28 +0100 Subject: [PATCH] Applied fvbommel's patch from #112 Added missing TypeInfoInvariant codegen for D2 --- dmd/root.c | 9 +++++++-- dmd2/root.c | 9 +++++++-- gen/typinf.cpp | 43 +++++++++++++++---------------------------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/dmd/root.c b/dmd/root.c index 352c75f2..c51a9ed6 100644 --- a/dmd/root.c +++ b/dmd/root.c @@ -1613,6 +1613,11 @@ void OutBuffer::vprintf(const char *format, va_list args) unsigned psize; int count; + // On some platforms (i.e. x86_64) va_list is an array and thus passed by + // reference. Copy the input list so we can copy it back before retrying. + va_list orig_args; + va_copy(orig_args, args); + p = buffer; psize = sizeof(buffer); for (;;) @@ -1622,8 +1627,7 @@ void OutBuffer::vprintf(const char *format, va_list args) if (count != -1) break; psize *= 2; -#endif -#if POSIX +#elif POSIX count = vsnprintf(p,psize,format,args); if (count == -1) psize *= 2; @@ -1632,6 +1636,7 @@ void OutBuffer::vprintf(const char *format, va_list args) else break; #endif + va_copy(args, orig_args); p = (char *) alloca(psize); // buffer too small, try again with larger size } write(p,count); diff --git a/dmd2/root.c b/dmd2/root.c index 352c75f2..c51a9ed6 100644 --- a/dmd2/root.c +++ b/dmd2/root.c @@ -1613,6 +1613,11 @@ void OutBuffer::vprintf(const char *format, va_list args) unsigned psize; int count; + // On some platforms (i.e. x86_64) va_list is an array and thus passed by + // reference. Copy the input list so we can copy it back before retrying. + va_list orig_args; + va_copy(orig_args, args); + p = buffer; psize = sizeof(buffer); for (;;) @@ -1622,8 +1627,7 @@ void OutBuffer::vprintf(const char *format, va_list args) if (count != -1) break; psize *= 2; -#endif -#if POSIX +#elif POSIX count = vsnprintf(p,psize,format,args); if (count == -1) psize *= 2; @@ -1632,6 +1636,7 @@ void OutBuffer::vprintf(const char *format, va_list args) else break; #endif + va_copy(args, orig_args); p = (char *) alloca(psize); // buffer too small, try again with larger size } write(p,count); diff --git a/gen/typinf.cpp b/gen/typinf.cpp index 9bbdd678..a50197c8 100644 --- a/gen/typinf.cpp +++ b/gen/typinf.cpp @@ -1229,45 +1229,32 @@ void TypeInfoConstDeclaration::toDt(dt_t **pdt) assert(0); } -// void TypeInfoConstDeclaration::toDt(dt_t **pdt) -// { -// //printf("TypeInfoConstDeclaration::toDt() %s\n", toChars()); -// dtxoff(pdt, Type::typeinfoconst->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Const -// dtdword(pdt, 0); // monitor -// Type *tm = tinfo->mutableOf(); -// tm = tm->merge(); -// tm->getTypeInfo(NULL); -// dtxoff(pdt, tm->vtinfo->toSymbol(), 0, TYnptr); -// } - /////////////////////////////////////////////////////////// /* ========================================================================= */ -void TypeInfoInvariantDeclaration::toDt(dt_t **pdt) -{ - assert(0 && "TypeInfoInvariantDeclaration::toDt"); -} - void TypeInfoInvariantDeclaration::llvmDeclare() { - assert(0 && "TypeInfoInvariantDeclaration::llvmDeclare"); + Logger::println("TypeInfoInvariantDeclaration::toDt() %s", toChars()); + LOG_SCOPE; + + LLVM_D_Declare_TypeInfoBase(this, Type::typeinfoinvariant); } void TypeInfoInvariantDeclaration::llvmDefine() { - assert(0 && "TypeInfoInvariantDeclaration::llvmDeclare"); + Logger::println("TypeInfoInvariantDeclaration::toDt() %s", toChars()); + LOG_SCOPE; + + Type *tm = tinfo->mutableOf(); + tm = tm->merge(); + + LLVM_D_Define_TypeInfoBase(tm, this, Type::typeinfoinvariant); } -// void TypeInfoInvariantDeclaration::toDt(dt_t **pdt) -// { -// //printf("TypeInfoInvariantDeclaration::toDt() %s\n", toChars()); -// dtxoff(pdt, Type::typeinfoinvariant->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_Invariant -// dtdword(pdt, 0); // monitor -// Type *tm = tinfo->mutableOf(); -// tm = tm->merge(); -// tm->getTypeInfo(NULL); -// dtxoff(pdt, tm->vtinfo->toSymbol(), 0, TYnptr); -// } +void TypeInfoInvariantDeclaration::toDt(dt_t **pdt) +{ + assert(0); +} #endif \ No newline at end of file