diff dmd/TemplateDeclaration.d @ 8:d42cd5917df4

wysiwyg strings, alias this, templates, TypeSlice implementation
author dkoroskin <>
date Mon, 14 Dec 2009 17:43:43 +0300
parents 10317f0c89a5
children 0aa7d1437ada
line wrap: on
line diff
--- a/dmd/TemplateDeclaration.d	Mon Dec 14 14:50:03 2009 +0300
+++ b/dmd/TemplateDeclaration.d	Mon Dec 14 17:43:43 2009 +0300
@@ -246,9 +246,55 @@
 		 */
 	}
 
+	/**********************************
+	 * Overload existing TemplateDeclaration 'this' with the new one 's'.
+	 * Return !=0 if successful; i.e. no conflict.
+	 */
     bool overloadInsert(Dsymbol s)
 	{
-		assert(false);
+		TemplateDeclaration f;
+
+	version (LOG) {
+		printf("TemplateDeclaration.overloadInsert('%s')\n", s.toChars());
+	}
+		f = s.isTemplateDeclaration();
+		if (!f)
+			return false;
+
+		for (TemplateDeclaration f2 = this; f2; f2 = f2.overnext)
+		{
+	static if (false) {
+		// Conflict if TemplateParameter's match
+		// Will get caught anyway later with TemplateInstance, but
+		// should check it now.
+		if (f.parameters.dim != f2.parameters.dim)
+			goto Lcontinue;
+
+		for (int i = 0; i < f.parameters.dim; i++)
+		{   
+			TemplateParameter p1 = cast(TemplateParameter)f.parameters.data[i];
+			TemplateParameter p2 = cast(TemplateParameter)f2.parameters.data[i];
+
+			if (!p1.overloadMatch(p2))
+				goto Lcontinue;
+		}
+
+	version (LOG) {
+		printf("\tfalse: conflict\n");
+	}
+		return false;
+
+		 Lcontinue:
+		;
+	}
+		}
+
+		f.overroot = this;
+		///*pf = f;
+	version (LOG) {
+		printf("\ttrue: no conflict\n");
+	}
+		return true;
 	}
 
     void toCBuffer(OutBuffer buf, HdrGenState* hgs)