changeset 50:adf6f7f216ea

CondExp.toCBuffer IsExp.toCBuffer TemplateValueParameter.toCBuffer Dsymbol.search TemplateDeclaration.overloadInsert bug fixed
author korDen
date Sat, 21 Aug 2010 10:38:26 +0400
parents 0aa7d1437ada
children b7d29f613539
files dmd/CondExp.d dmd/Dsymbol.d dmd/IntegerExp.d dmd/IsExp.d dmd/PREC.d dmd/TemplateDeclaration.d dmd/TemplateValueParameter.d
diffstat 7 files changed, 96 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/dmd/CondExp.d	Sat Aug 21 07:53:20 2010 +0400
+++ b/dmd/CondExp.d	Sat Aug 21 10:38:26 2010 +0400
@@ -16,6 +16,7 @@
 import dmd.TOK;
 import dmd.TY;
 import dmd.WANT;
+import dmd.PREC;
 import dmd.Global;
 
 import dmd.backend.elem;
@@ -25,6 +26,8 @@
 import dmd.backend.TYM;
 import dmd.codegen.Util;
 
+import dmd.expression.Util;
+
 class CondExp : BinExp
 {
     Expression econd;
@@ -192,7 +195,11 @@
 
     void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		expToCBuffer(buf, hgs, econd, PREC_oror);
+		buf.writestring(" ? ");
+		expToCBuffer(buf, hgs, e1, PREC_expr);
+		buf.writestring(" : ");
+		expToCBuffer(buf, hgs, e2, PREC_cond);
 	}
 
     MATCH implicitConvTo(Type t)
--- a/dmd/Dsymbol.d	Sat Aug 21 07:53:20 2010 +0400
+++ b/dmd/Dsymbol.d	Sat Aug 21 10:38:26 2010 +0400
@@ -450,9 +450,19 @@
 		// Most Dsymbols aren't functions
 	}
 	
+	/*********************************************
+	 * Search for ident as member of s.
+	 * Input:
+	 *	flags:	1	don't find private members
+	 *		2	don't give error messages
+	 *		4	return null if ambiguous
+	 * Returns:
+	 *	null if not found
+	 */
     Dsymbol search(Loc loc, Identifier ident, int flags)
 	{
-		assert(false);
+		//printf("Dsymbol.search(this=%p,%s, ident='%s')\n", this, toChars(), ident.toChars());
+		return null;
 	}
 	
 	/***************************************
--- a/dmd/IntegerExp.d	Sat Aug 21 07:53:20 2010 +0400
+++ b/dmd/IntegerExp.d	Sat Aug 21 10:38:26 2010 +0400
@@ -473,7 +473,8 @@
 
 				case TY.Tuns64:
 				L4:
-					buf.printf("%juLU", v);
+					//buf.printf("%juLU", v);
+					buf.printf("%sLU", v);
 					break;
 
 				case TY.Tbit:
--- a/dmd/IsExp.d	Sat Aug 21 07:53:20 2010 +0400
+++ b/dmd/IsExp.d	Sat Aug 21 10:38:26 2010 +0400
@@ -28,6 +28,7 @@
 import dmd.MATCH;
 import dmd.TypePointer;
 import dmd.Argument;
+import dmd.Token;
 
 class IsExp : Expression
 {
@@ -336,7 +337,33 @@
 
 	void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		buf.writestring("is(");
+		targ.toCBuffer(buf, id, hgs);
+		if (tok2 != TOKreserved)
+		{
+			buf.printf(" %s %s", Token.toChars(tok), Token.toChars(tok2));
+		}
+		else if (tspec)
+		{
+			if (tok == TOKcolon)
+				buf.writestring(" : ");
+			else
+				buf.writestring(" == ");
+			tspec.toCBuffer(buf, null, hgs);
+		}
+version (DMDV2) {
+		if (parameters)
+		{	
+			// First parameter is already output, so start with second
+			for (int i = 1; i < parameters.dim; i++)
+			{
+				buf.writeByte(',');
+				TemplateParameter tp = cast(TemplateParameter)parameters.data[i];
+				tp.toCBuffer(buf, hgs);
+			}
+		}
+}
+		buf.writeByte(')');
 	}
 }
 
--- a/dmd/PREC.d	Sat Aug 21 07:53:20 2010 +0400
+++ b/dmd/PREC.d	Sat Aug 21 10:38:26 2010 +0400
@@ -28,4 +28,7 @@
     PREC_primary,
 }
 
-PREC precedence[TOK.TOKMAX];
\ No newline at end of file
+PREC precedence[TOK.TOKMAX];
+
+import dmd.EnumUtils;
+mixin(BringToCurrentScope!(PREC));
\ No newline at end of file
--- a/dmd/TemplateDeclaration.d	Sat Aug 21 07:53:20 2010 +0400
+++ b/dmd/TemplateDeclaration.d	Sat Aug 21 10:38:26 2010 +0400
@@ -252,48 +252,51 @@
 	 */
     bool overloadInsert(Dsymbol s)
 	{
+		TemplateDeclaration *pf;
 		TemplateDeclaration f;
 
 	version (LOG) {
-		printf("TemplateDeclaration.overloadInsert('%s')\n", s.toChars());
+		printf("TemplateDeclaration.overloadInsert('%.*s')\n", s.toChars());
 	}
 		f = s.isTemplateDeclaration();
 		if (!f)
 			return false;
 
-		for (TemplateDeclaration f2 = this; f2; f2 = f2.overnext)
+		TemplateDeclaration pthis = this;
+		for (pf = &pthis; *pf; pf = &(*pf).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;
+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];
+			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;
-		}
+				if (!p1.overloadMatch(p2))
+					goto Lcontinue;
+			}
 
-	version (LOG) {
-		printf("\tfalse: conflict\n");
-	}
-		return false;
+version (LOG) {
+			printf("\tfalse: conflict\n");
+}
+			return false;
 
-		 Lcontinue:
+Lcontinue:
 		;
-	}
+}
 		}
 
 		f.overroot = this;
-		///*pf = f;
+		*pf = f;
 	version (LOG) {
 		printf("\ttrue: no conflict\n");
 	}
+	
 		return true;
 	}
 
@@ -304,7 +307,9 @@
 
     string kind()
 	{
-		assert(false);
+		return (onemember && onemember.isAggregateDeclaration())
+			? onemember.kind()
+			: "template";
 	}
 
     string toChars()
@@ -339,7 +344,7 @@
 	{
 		assert(false);
 	}
-
+	
 //    void toDocBuffer(OutBuffer *buf);
 
 	/***************************************
@@ -359,7 +364,7 @@
 		int dedtypes_dim = dedtypes.dim;
 
 	version (LOGM) {
-		printf("\n+TemplateDeclaration.matchWithInstance(this = %s, ti = %s, flag = %d)\n", toChars(), ti.toChars(), flag);
+		printf("\n+TemplateDeclaration.matchWithInstance(this = %.*s, ti = %.*s, flag = %d)\n", toChars(), ti.toChars(), flag);
 	}
 
 	static if (false) {
@@ -376,9 +381,9 @@
 		if (ti.tiargs.dim > parameters_dim && !variadic)
 		{
 	version (LOGM) {
-		printf(" no match: more arguments than parameters\n");
+			printf(" no match: more arguments than parameters\n");
 	}
-		return MATCHnomatch;
+			return MATCHnomatch;
 		}
 
 		assert(dedtypes_dim == parameters_dim);
--- a/dmd/TemplateValueParameter.d	Sat Aug 21 07:53:20 2010 +0400
+++ b/dmd/TemplateValueParameter.d	Sat Aug 21 10:38:26 2010 +0400
@@ -111,7 +111,17 @@
 
     void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		valType.toCBuffer(buf, ident, hgs);
+		if (specValue)
+		{
+			buf.writestring(" : ");
+			specValue.toCBuffer(buf, hgs);
+		}
+		if (defaultValue)
+		{
+			buf.writestring(" = ");
+			defaultValue.toCBuffer(buf, hgs);
+		}
 	}
 
     Object specialization()