diff dmd/ComplexExp.d @ 174:af724d3510d7

lot os toCBuffer methods implemented moved shared Type.* stuff into Global
author korDen
date Sun, 10 Oct 2010 03:47:23 +0400
parents 010eb8f0e18d
children 94b6033c07f3
line wrap: on
line diff
--- a/dmd/ComplexExp.d	Sun Oct 10 01:55:35 2010 +0400
+++ b/dmd/ComplexExp.d	Sun Oct 10 03:47:23 2010 +0400
@@ -89,7 +89,7 @@
 		if (type != t)
 		{
 			if (type.iscomplex() && t.iscomplex())
-			{   
+			{
 				e = copy();
 				e.type = t;
 			}
@@ -114,7 +114,22 @@
 
 	override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		/* Print as:
+		 *  (re+imi)
+		 */
+version (IN_GCC) {
+		char buf1[sizeof(value) * 3 + 8 + 1];
+		char buf2[sizeof(value) * 3 + 8 + 1];
+		creall(value).format(buf1, sizeof(buf1));
+		cimagl(value).format(buf2, sizeof(buf2));
+		buf.printf("(%s+%si)", buf1, buf2);
+} else {
+		buf.writeByte('(');
+		floatToBuffer(buf, type, value.re);
+		buf.writeByte('+');
+		floatToBuffer(buf, type, value.im);
+		buf.writestring("i)");
+}
 	}
 
 	override void toMangleBuffer(OutBuffer buf)
@@ -126,7 +141,7 @@
 		r = toImaginary();
 		realToMangleBuffer(buf, r);
 	}
-	
+
 version (_DH) {
 	OutBuffer hexp;
 }
@@ -204,7 +219,7 @@
 		}
 		return el_const(ty, &c);
 	}
-	
+
 	static private char[6] zeropad;
 
 	override dt_t** toDt(dt_t** pdt)