diff dmd/AssertExp.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 25ede4f66bda
children e3afd1303184
line wrap: on
line diff
--- a/dmd/AssertExp.d	Sun Oct 10 01:55:35 2010 +0400
+++ b/dmd/AssertExp.d	Sun Oct 10 03:47:23 2010 +0400
@@ -17,6 +17,7 @@
 import dmd.Global;
 import dmd.InvariantDeclaration;
 import dmd.TOK;
+import dmd.PREC;
 import dmd.TY;
 import dmd.TypeClass;
 import dmd.Module;
@@ -34,6 +35,8 @@
 import dmd.backend.SC;
 import dmd.backend.FL;
 
+import dmd.expression.Util;
+
 import core.stdc.string;
 import std.string : toStringz;
 
@@ -81,7 +84,7 @@
 			fd.hasReturnExp |= 4;
 
 			if (!global.params.useAssert)
-			{   
+			{
 				Expression e = new HaltExp(loc);
 				e = e.semantic(sc);
 				return e;
@@ -112,7 +115,14 @@
 }
 	override void toCBuffer(OutBuffer buf, HdrGenState* hgs)
 	{
-		assert(false);
+		buf.writestring("assert(");
+		expToCBuffer(buf, hgs, e1, PREC.PREC_assign);
+		if (msg)
+		{
+			buf.writeByte(',');
+			expToCBuffer(buf, hgs, msg, PREC_assign);
+		}
+		buf.writeByte(')');
 	}
 
 	override int inlineCost(InlineCostState* ics)
@@ -137,7 +147,7 @@
 			msg = msg.inlineScan(iss);
 		return this;
 	}
-	
+
 	static private void* castToVoid(int i)
 	{
 		return cast(void*)i;
@@ -188,7 +198,7 @@
 				 * to a #line directive.
 				 */
 				if (loc.filename && (msg || loc.filename != mname))
-				{	
+				{
 					elem* efilename;
 
 					/* Cache values.
@@ -224,7 +234,7 @@
 					efilename = el_var(assertexp_sfilename);
 
 					if (msg)
-					{   
+					{
 						elem* emsg = msg.toElem(irs);
 						ea = el_var(rtlsym[RTLSYM_DASSERT_MSG]);
 						ea = el_bin(OPcall, TYvoid, ea, el_params(el_long(TYint, loc.linnum), efilename, emsg, null));
@@ -245,7 +255,7 @@
 			}
 		}
 		else
-		{	
+		{
 			// BUG: should replace assert(0); with a HLT instruction
 			e = el_long(TYint, 0);
 		}