diff dmd2/func.c @ 847:356e65836fb5

Merged DMD 2.021 frontend. Removed generated files from dmd/dmd2 dirs.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sat, 13 Dec 2008 16:14:37 +0100
parents f04dde6e882c
children 063ba84a965f
line wrap: on
line diff
--- a/dmd2/func.c	Sat Dec 13 13:15:31 2008 +0100
+++ b/dmd2/func.c	Sat Dec 13 16:14:37 2008 +0100
@@ -685,24 +685,36 @@
 		Type *thandle = ad->handle;
 		if (storage_class & STCconst || type->isConst())
 		{
+#if STRUCTTHISREF
+		    thandle = thandle->constOf();
+#else
 		    if (thandle->ty == Tclass)
 			thandle = thandle->constOf();
 		    else
 		    {	assert(thandle->ty == Tpointer);
 			thandle = thandle->nextOf()->constOf()->pointerTo();
 		    }
+#endif
 		}
 		else if (storage_class & STCinvariant || type->isInvariant())
 		{
+#if STRUCTTHISREF
+		    thandle = thandle->invariantOf();
+#else
 		    if (thandle->ty == Tclass)
 			thandle = thandle->invariantOf();
 		    else
 		    {	assert(thandle->ty == Tpointer);
 			thandle = thandle->nextOf()->invariantOf()->pointerTo();
 		    }
+#endif
 		}
 		v = new ThisDeclaration(thandle);
 		v->storage_class |= STCparameter;
+#if STRUCTTHISREF
+		if (thandle->ty == Tstruct)
+		    v->storage_class |= STCref;
+#endif
 		v->semantic(sc2);
 		if (!sc2->insert(v))
 		    assert(0);
@@ -950,8 +962,12 @@
 		}
 		else
 		{   // Call invariant virtually
-		    ThisExp *v = new ThisExp(0);
+		    Expression *v = new ThisExp(0);
 		    v->type = vthis->type;
+#if STRUCTTHISREF
+		    if (ad->isStructDeclaration())
+			v = v->addressOf(sc);
+#endif
 		    e = new AssertExp(0, v);
 		}
 		if (e)
@@ -1214,8 +1230,12 @@
 		}
 		else
 		{   // Call invariant virtually
-		    ThisExp *v = new ThisExp(0);
+		    Expression *v = new ThisExp(0);
 		    v->type = vthis->type;
+#if STRUCTTHISREF
+		    if (ad->isStructDeclaration())
+			v = v->addressOf(sc);
+#endif
 		    Expression *se = new StringExp(0, (char *)"null this");
 		    se = se->semantic(sc);
 		    se->type = Type::tchar->arrayOf();
@@ -2017,15 +2037,16 @@
 
 int FuncDeclaration::isFinal()
 {
+    ClassDeclaration *cd;
 #if 0
     printf("FuncDeclaration::isFinal(%s)\n", toChars());
     printf("%p %d %d %d %d\n", isMember(), isStatic(), protection == PROTprivate, isCtorDeclaration(), linkage != LINKd);
     printf("result is %d\n",
 	isMember() &&
 	!(isStatic() || protection == PROTprivate || protection == PROTpackage) &&
-	toParent()->isClassDeclaration());
+	(cd = toParent()->isClassDeclaration()) != NULL &&
+	cd->storage_class & STCfinal);
 #endif
-    ClassDeclaration *cd;
     return isMember() &&
 	(Declaration::isFinal() ||
 	 ((cd = toParent()->isClassDeclaration()) != NULL && cd->storage_class & STCfinal));
@@ -2331,6 +2352,10 @@
 	assert(tret);
     }
     type = new TypeFunction(arguments, tret, varargs, LINKd);
+#if STRUCTTHISREF
+    if (ad && ad->isStructDeclaration())
+	((TypeFunction *)type)->isref = 1;
+#endif
     if (!originalType)
 	originalType = type;
 
@@ -2857,10 +2882,11 @@
 {
     if (global.params.useUnitTests)
     {
-	Type *tret;
-
 	type = new TypeFunction(NULL, Type::tvoid, FALSE, LINKd);
-	FuncDeclaration::semantic(sc);
+	Scope *sc2 = sc->push();
+	sc2->linkage = LINKd;
+	FuncDeclaration::semantic(sc2);
+	sc2->pop();
     }
 
     // We're going to need ModuleInfo even if the unit tests are not