diff dmd/Expression.d @ 93:df6d0f967680

implemented a whole bunch of methods to make phobos 2.035 compile and some additional ones I came across
author Trass3r
date Mon, 30 Aug 2010 22:50:30 +0200
parents be2ab491772e
children ae5b11064a9a
line wrap: on
line diff
--- a/dmd/Expression.d	Mon Aug 30 23:43:38 2010 +0400
+++ b/dmd/Expression.d	Mon Aug 30 22:50:30 2010 +0200
@@ -42,6 +42,7 @@
 import dmd.TypeStruct;
 import dmd.CastExp;
 import dmd.Global;
+import dmd.GlobalExpressions;
 import dmd.Token;
 import dmd.TypeClass;
 import dmd.PtrExp;
@@ -324,7 +325,9 @@
 
     ulong toInteger()
 	{
-		assert(false);
+		//printf("Expression %s\n", Token.toChars(op));
+		error("Integer constant expression expected instead of %s", toChars());
+		return 0;
 	}
     
     ulong toUInteger()
@@ -335,17 +338,20 @@
     
     real toReal()
 	{
-		assert(false);
+		error("Floating point constant expression expected instead of %s", toChars());
+		return 0;
 	}
     
     real toImaginary()
 	{
-		assert(false);
+		error("Floating point constant expression expected instead of %s", toChars());
+		return 0;
 	}
     
     Complex!(real) toComplex()
 	{
-		assert(false);
+		error("Floating point constant expression expected instead of %s", toChars());
+		return Complex!real(0);
 	}
     
     void toCBuffer(OutBuffer buf, HdrGenState* hgs)
@@ -369,12 +375,21 @@
 	{
 		return 0;
 	}
-    
-    Expression toLvalue(Scope sc, Expression e)
+
+	/*******************************
+	 * Give error if we're not an lvalue.
+	 * If we can, convert expression to be an lvalue.
+	 */
+	Expression toLvalue(Scope sc, Expression e)
 	{
-		assert(false);
+		   if (!e)
+				e = this;
+			else if (!loc.filename)
+				loc = e.loc;
+			error("%s is not an lvalue", e.toChars());
+			return this;
 	}
-    
+
     Expression modifiableLvalue(Scope sc, Expression e)
 	{
 		//printf("Expression::modifiableLvalue() %s, type = %s\n", toChars(), type.toChars());
@@ -831,9 +846,16 @@
 		return this;
 	}
     
-    Expression interpret(InterState istate)
+	Expression interpret(InterState istate)
 	{
-		assert(false);
+version(LOG)
+{
+		writef("Expression::interpret() %s\n", toChars());
+		writef("type = %s\n", type.toChars());
+		dump(0);
+}
+		error("Cannot interpret %s at compile time", toChars());
+		return EXP_CANT_INTERPRET;
 	}
 
     int isConst()