From d16ddb524faaeb781d173081cd3e4e7e6c669762 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 9 Jul 2008 17:01:08 +0200 Subject: [PATCH] [svn r342] Fix DMD bug 2206. Implement mixin declarations in LLVMDC. --- dmd/mangle.c | 25 +++++++++++++++++++++++++ dmd/template.h | 1 + gen/toir.cpp | 10 ++++++++++ 3 files changed, 36 insertions(+) diff --git a/dmd/mangle.c b/dmd/mangle.c index 5eead78e..0aa2ff26 100644 --- a/dmd/mangle.c +++ b/dmd/mangle.c @@ -221,6 +221,31 @@ char *TemplateInstance::mangle() } +char *TemplateMixin::mangle() +{ + OutBuffer buf; + char *id; + +#if 0 + printf("TemplateMixin::mangle() %s", toChars()); + if (parent) + printf(" parent = %s %s", parent->kind(), parent->toChars()); + printf("\n"); +#endif + id = ident ? ident->toChars() : toChars(); + if (parent) + { + char *p = parent->mangle(); + if (p[0] == '_' && p[1] == 'D') + p += 2; + buf.writestring(p); + } + buf.printf("%"PRIuSIZE"%s", strlen(id), id); + id = buf.toChars(); + buf.data = NULL; + //printf("TemplateMixin::mangle() %s = %s\n", toChars(), id); + return id; +} char *Dsymbol::mangle() { diff --git a/dmd/template.h b/dmd/template.h index c246e347..9db26d05 100644 --- a/dmd/template.h +++ b/dmd/template.h @@ -309,6 +309,7 @@ struct TemplateMixin : TemplateInstance int oneMember(Dsymbol **ps); int hasPointers(); char *toChars(); + char *mangle(); void toCBuffer(OutBuffer *buf, HdrGenState *hgs); void toObjFile(); // compile to .obj file diff --git a/gen/toir.cpp b/gen/toir.cpp index 5b1badee..da27c45a 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -18,6 +18,7 @@ #include "total.h" #include "init.h" #include "mtype.h" +#include "template.h" #include "hdrgen.h" #include "port.h" @@ -140,6 +141,15 @@ DValue* DeclarationExp::toElem(IRState* p) DtoForceDeclareDsymbol((Dsymbol*)a->decl->data[i]); } } + // mixin declaration + else if (TemplateMixin* m = declaration->isTemplateMixin()) + { + Logger::println("TemplateMixin"); + for (int i=0; i < m->members->dim; ++i) + { + DtoForceDeclareDsymbol((Dsymbol*)m->members->data[i]); + } + } // unsupported declaration else {