diff dmd/mtype.c @ 1245:465a77c904d4

Fixed all issues preventing Tango 0.99.8 to compile with `sh build-tango.sh --verbose ldc'.
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Fri, 17 Apr 2009 14:38:29 +0200
parents 79758fd2f48a
children 7af860e4f403
line wrap: on
line diff
--- a/dmd/mtype.c	Fri Apr 17 03:01:43 2009 +0200
+++ b/dmd/mtype.c	Fri Apr 17 14:38:29 2009 +0200
@@ -109,6 +109,10 @@
 unsigned char Type::mangleChar[TMAX];
 StringTable Type::stringtable;
 
+#if IN_LLVM
+StringTable Type::deco_stringtable;
+#endif
+
 
 Type::Type(TY ty, Type *next)
 {
@@ -444,11 +448,23 @@
 	else
 	{
 	    sv->ptrvalue = this;
-	    
+
+            // we still need deco strings to be unique
+            // or Type::equals fails, which breaks a bunch of stuff,
+            // like covariant member function overloads.
 	    OutBuffer mangle;
 	    toDecoBuffer(&mangle, true);
-	    mangle.writeByte(0);
-	    deco = mem.strdup((char *)mangle.data);
+	    StringValue* sv2 = deco_stringtable.update((char *)mangle.data, mangle.offset);
+	    if (sv2->ptrvalue)
+	    {  Type* t2 = (Type *) sv2->ptrvalue;
+	       assert(t2->deco);
+	       deco = t2->deco;
+	    }
+	    else
+	    {
+	       sv2->ptrvalue = this;
+	       deco = (char *)sv2->lstring.string;
+	    }
 	    //printf("new value, deco = '%s' %p\n", t->deco, t->deco);
 	}
     }