diff dmd/CallExp.d @ 96:acd69f84627e

further work
author Trass3r
date Tue, 31 Aug 2010 02:12:15 +0200
parents 39648eb578f6
children ceda59b4d255
line wrap: on
line diff
--- a/dmd/CallExp.d	Mon Aug 30 23:08:44 2010 +0200
+++ b/dmd/CallExp.d	Tue Aug 31 02:12:15 2010 +0200
@@ -94,7 +94,7 @@
 		super(loc, TOK.TOKcall, CallExp.sizeof, e);
 		
 		auto arguments = new Expressions();
-	    if (earg1)
+		if (earg1)
 		{	
 			arguments.setDim(1);
 			arguments[0] = earg1;
@@ -778,7 +778,7 @@
 
 	override Expression optimize(int result)
 	{
-		//printf("CallExp::optimize(result = %d) %s\n", result, toChars());
+		// writef("CallExp::optimize(result = %d) %s\n", result, toChars());
 		Expression e = this;
 
 		// Optimize parameters
@@ -813,6 +813,19 @@
 				}
 			}
 		}
+		else if (e1.op == TOKdotvar && result & WANTinterpret)
+		{
+			DotVarExp dve = cast(DotVarExp) e1;
+			FuncDeclaration fd = dve.var.isFuncDeclaration();
+			if (fd)
+			{
+				Expression eresult = fd.interpret(null, arguments, dve.e1);
+				if (eresult && eresult != EXP_VOID_INTERPRET)
+					e = eresult;
+				else
+					error("cannot evaluate %s at compile time", toChars());
+			}
+		}
 
 		return e;
 	}
@@ -833,7 +846,7 @@
 			{   
 				// Member function call
 				if(pthis.op == TOKthis)
-					pthis = istate.localThis;	    
+					pthis = istate.localThis;
 				Expression eresult = fd.interpret(istate, arguments, pthis);
 				if (eresult)
 					e = eresult;
@@ -1034,7 +1047,7 @@
 version (DMDV2) {
 	override int isLvalue()
 	{
-		//    if (type.toBasetype().ty == Tstruct)
+		//	if (type.toBasetype().ty == Tstruct)
 		//	return 1;
 		Type tb = e1.type.toBasetype();
 		if (tb.ty == Tfunction && (cast(TypeFunction)tb).isref)