diff dmd/class.c @ 35:3cfcb944304e trunk

[svn r39] * Updated to DMD 1.022 with the exception of: Bugzilla 278: dmd.conf search path doesn't work This fix was causing crashes for me :/ So for it's the old behaviour
author lindquist
date Tue, 09 Oct 2007 06:21:30 +0200
parents c53b6e3fe49a
children 5acec6b2eef8
line wrap: on
line diff
--- a/dmd/class.c	Tue Oct 09 02:50:00 2007 +0200
+++ b/dmd/class.c	Tue Oct 09 06:21:30 2007 +0200
@@ -1,6 +1,6 @@
 
 // Compiler implementation of the D programming language
-// Copyright (c) 1999-2006 by Digital Mars
+// Copyright (c) 1999-2007 by Digital Mars
 // All Rights Reserved
 // written by Walter Bright
 // http://www.digitalmars.com
@@ -146,6 +146,20 @@
 		    Type::typeinfotypelist->error("%s", msg);
 		Type::typeinfotypelist = this;
 	    }
+
+#if V2
+	    if (id == Id::TypeInfo_Const)
+	    {	if (Type::typeinfoconst)
+		    Type::typeinfoconst->error("%s", msg);
+		Type::typeinfoconst = this;
+	    }
+
+	    if (id == Id::TypeInfo_Invariant)
+	    {	if (Type::typeinfoinvariant)
+		    Type::typeinfoinvariant->error("%s", msg);
+		Type::typeinfoinvariant = this;
+	    }
+#endif
 	}
 
 	if (id == Id::Object)
@@ -168,10 +182,6 @@
     }
 
     com = 0;
-#if 0
-    if (id == Id::IUnknown)		// IUnknown is the root of all COM objects
-	com = 1;
-#endif
     isauto = 0;
     isabstract = 0;
     isnested = 0;
@@ -249,6 +259,11 @@
     methods.setDim(0);
 #endif
 
+    if (sc->stc & STCdeprecated)
+    {	//printf("test1: %s is deprecated\n", toChars());
+	isdeprecated = 1;
+    }
+
     // Expand any tuples in baseclasses[]
     for (i = 0; i < baseclasses.dim; )
     {	BaseClass *b = (BaseClass *)baseclasses.data[i];
@@ -286,6 +301,17 @@
 	else
 	{
 	    tc = (TypeClass *)(tb);
+	    if (tc->sym->isDeprecated())
+	    {
+		if (!isDeprecated())
+		{
+		    // Deriving from deprecated class makes this one deprecated too
+		    isdeprecated = 1;
+
+		    tc->checkDeprecated(loc, sc);
+		}
+	    }
+
 	    if (tc->sym->isInterfaceDeclaration())
 		;
 	    else
@@ -340,6 +366,17 @@
 	}
 	else
 	{
+	    if (tc->sym->isDeprecated())
+	    {
+		if (!isDeprecated())
+		{
+		    // Deriving from deprecated class makes this one deprecated too
+		    isdeprecated = 1;
+
+		    tc->checkDeprecated(loc, sc);
+		}
+	    }
+
 	    // Check for duplicate interfaces
 	    for (size_t j = (baseClass ? 1 : 0); j < i; j++)
 	    {
@@ -480,8 +517,6 @@
 	isauto = 1;
     if (storage_class & STCabstract)
 	isabstract = 1;
-    if (storage_class & STCdeprecated)
-	isdeprecated = 1;
 
     sc = sc->push(this);
     sc->stc &= ~(STCfinal | STCauto | STCscope | STCstatic |
@@ -567,7 +602,7 @@
 	ctor->fbody = new CompoundStatement(0, new Statements());
 	members->push(ctor);
 	ctor->addMember(sc, this, 1);
-	*sc = scsave;
+	*sc = scsave;	// why? What about sc->nofree?
 	sc->offset = structsize;
 	ctor->semantic(sc);
 	defaultCtor = ctor;
@@ -754,6 +789,35 @@
     return s;
 }
 
+/**********************************************************
+ * fd is in the vtbl[] for this class.
+ * Return 1 if function is hidden (not findable through search).
+ */
+
+#if V2
+int isf(void *param, FuncDeclaration *fd)
+{
+    //printf("param = %p, fd = %p %s\n", param, fd, fd->toChars());
+    return param == fd;
+}
+
+int ClassDeclaration::isFuncHidden(FuncDeclaration *fd)
+{
+    //printf("ClassDeclaration::isFuncHidden(%s)\n", fd->toChars());
+    Dsymbol *s = search(0, fd->ident, 4|2);
+    if (!s)
+    {	//printf("not found\n");
+	/* Because, due to a hack, if there are multiple definitions
+	 * of fd->ident, NULL is returned.
+	 */
+	return 0;
+    }
+    FuncDeclaration *fdstart = s->toAlias()->isFuncDeclaration();
+    //printf("%s fdstart = %p\n", s->kind(), fdstart);
+    return !overloadApply(fdstart, &isf, fd);
+}
+#endif
+
 /****************
  * Find virtual function matching identifier and type.
  * Used to build virtual function tables for interface implementations.
@@ -802,7 +866,7 @@
 
 	// If this is an interface, and it derives from a COM interface,
 	// then this is a COM interface too.
-	if (b->base->isCOMclass())
+	if (b->base->isCOMinterface())
 	    com = 1;
 
 	vtblInterfaces->push(b);
@@ -818,6 +882,11 @@
     return com;
 }
 
+int ClassDeclaration::isCOMinterface()
+{
+    return 0;
+}
+
 
 /****************************************
  */
@@ -927,6 +996,11 @@
 	scope = NULL;
     }
 
+    if (sc->stc & STCdeprecated)
+    {
+	isdeprecated = 1;
+    }
+
     // Expand any tuples in baseclasses[]
     for (i = 0; i < baseclasses.dim; )
     {	BaseClass *b = (BaseClass *)baseclasses.data[0];
@@ -1044,7 +1118,7 @@
 
     sc = sc->push(this);
     sc->parent = this;
-    if (isCOMclass())
+    if (isCOMinterface())
 	sc->linkage = LINKwindows;
     sc->structalign = 8;
     structalign = sc->structalign;
@@ -1134,18 +1208,23 @@
 
 /****************************************
  * Determine if slot 0 of the vtbl[] is reserved for something else.
- * For class objects, yes, this is where the classinfo ptr goes.
+ * For class objects, yes, this is where the ClassInfo ptr goes.
  * For COM interfaces, no.
  * For non-COM interfaces, yes, this is where the Interface ptr goes.
  */
 
 int InterfaceDeclaration::vtblOffset()
 {
-    if (isCOMclass())
+    if (isCOMinterface())
 	return 0;
     return 1;
 }
 
+int InterfaceDeclaration::isCOMinterface()
+{
+    return com;
+}
+
 /*******************************************
  */