changeset 1505:1e5a14691e77

Automated merge with http://hg.dsource.org/projects/ldc
author Robert Clipsham <robert@octarineparrot.com>
date Thu, 18 Jun 2009 15:44:18 +0100
parents cc5fee7836dc (current diff) 855f188aab7a (diff)
children 76936858d1c6
files gen/llvmhelpers.h
diffstat 5 files changed, 78 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/gen/declarations.cpp	Tue Jun 16 23:00:27 2009 +0200
+++ b/gen/declarations.cpp	Thu Jun 18 15:44:18 2009 +0100
@@ -96,7 +96,7 @@
     // global variable
 #if DMDV2
     // taken from dmd2/structs
-    if (isDataseg() || (storage_class & (STCconst | STCinvariant) && init))
+    if (isDataseg() || (storage_class & (STCconst | STCimmutable) && init))
 #else
     if (isDataseg())
 #endif
--- a/gen/llvmhelpers.cpp	Tue Jun 16 23:00:27 2009 +0200
+++ b/gen/llvmhelpers.cpp	Thu Jun 18 15:44:18 2009 +0100
@@ -1480,3 +1480,76 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////////////////
+
+Type * stripModifiers( Type * type )
+{
+#if DMDV2
+	Type *t = type;
+	while (t->mod)
+	{
+		switch (t->mod)
+		{
+			case MODconst:
+				t = type->cto;
+				break;
+			case MODshared:
+				t = type->sto;
+				break;
+			case MODinvariant:
+				t = type->ito;
+				break;
+			case MODshared | MODconst:
+				t = type->scto;
+				break;
+			default:
+				assert(0 && "Unhandled type modifier");
+		}
+
+		if (!t)
+		{
+			unsigned sz = type->sizeTy[type->ty];
+			t = (Type *)malloc(sz);
+			memcpy(t, type, sz);
+			t->mod = 0;
+			t->deco = NULL;
+			t->arrayof = NULL;
+			t->pto = NULL;
+			t->rto = NULL;
+			t->cto = NULL;
+			t->ito = NULL;
+			t->sto = NULL;
+			t->scto = NULL;
+			t->vtinfo = NULL;
+			t = t->merge();
+
+			t->fixTo(type);
+			switch (type->mod)
+			{
+			    case MODconst:
+				t->cto = type;
+				break;
+
+			    case MODinvariant:
+				t->ito = type;
+				break;
+
+			    case MODshared:
+				t->sto = type;
+				break;
+
+			    case MODshared | MODconst:
+				t->scto = type;
+				break;
+
+			    default:
+				assert(0);
+			}
+		}
+	}
+	return t;
+#else
+	return type;
+#endif
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
--- a/gen/llvmhelpers.h	Tue Jun 16 23:00:27 2009 +0200
+++ b/gen/llvmhelpers.h	Thu Jun 18 15:44:18 2009 +0100
@@ -171,4 +171,6 @@
 ///
 DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* arguments);
 
+Type* stripModifiers(Type* type);
+
 #endif
--- a/gen/todebug.cpp	Tue Jun 16 23:00:27 2009 +0200
+++ b/gen/todebug.cpp	Thu Jun 18 15:44:18 2009 +0100
@@ -408,7 +408,7 @@
 static llvm::DIGlobalVariable dwarfGlobalVariable(LLGlobalVariable* ll, VarDeclaration* vd)
 {
 #if DMDV2
-    assert(vd->isDataseg() || (vd->storage_class & (STCconst | STCinvariant) && vd->init));
+    assert(vd->isDataseg() || (vd->storage_class & (STCconst | STCimmutable) && vd->init));
 #else
     assert(vd->isDataseg());
 #endif
--- a/gen/tollvm.cpp	Tue Jun 16 23:00:27 2009 +0200
+++ b/gen/tollvm.cpp	Thu Jun 18 15:44:18 2009 +0100
@@ -54,9 +54,7 @@
 
 const LLType* DtoType(Type* t)
 {
-#if DMDV2
-    t = t->mutableOf();
-#endif
+    t = stripModifiers( t );
 
     if (t->irtype)
     {