changeset 32:81796b717a39

A few bad cast fixed. TODO: either get rid of dyncast(), or derive all objects from intermediate supertype.
author korDen
date Tue, 18 May 2010 17:51:46 +0400
parents 9364afc02cf5
children e0a36abe1184
files dlib/CrashHandler.d dmd/Tuple.d dmd/TupleDeclaration.d dmd/TupleExp.d setupenv.bat
diffstat 5 files changed, 24 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/dlib/CrashHandler.d	Tue Apr 13 21:26:45 2010 +0100
+++ b/dlib/CrashHandler.d	Tue May 18 17:51:46 2010 +0400
@@ -31,6 +31,7 @@
 version(Windows) {
 	import win32.windows;
 	import win32.psapi;
+	import std.windows.syserror;
 	//import sys.windows.Memory;
 	//import dlib.Module;
 	import dbg.image.PE;
@@ -208,8 +209,13 @@
 						imageList = image;
 						baseAddress = cast(size_t)mbi.AllocationBase;
 
+//						printf("%d\n", baseAddress);
+
 						len = GetModuleFileNameA(cast(HMODULE)baseAddress, buffer.ptr, buffer.length);
 						moduleName = buffer[0 .. len].idup;
+						if (len == 0) {
+							MessageBox(HANDLE.init, moduleName.ptr, sysErrorString(GetLastError()).ptr, 0);
+						}
 
 						exeModule = new PEImage(moduleName);
 						rvaOffset = baseAddress + exeModule.codeOffset;
--- a/dmd/Tuple.d	Tue Apr 13 21:26:45 2010 +0100
+++ b/dmd/Tuple.d	Tue May 18 17:51:46 2010 +0400
@@ -1,6 +1,7 @@
 module dmd.Tuple;
 
 import dmd.ArrayTypes;
+import dmd.DYNCAST;
 
 class Tuple
 {
@@ -11,7 +12,7 @@
 		objects = new Objects();
 	}
 
-	int dyncast()
+	DYNCAST dyncast()
 	{
 		assert(false);
 	}
--- a/dmd/TupleDeclaration.d	Tue Apr 13 21:26:45 2010 +0100
+++ b/dmd/TupleDeclaration.d	Tue May 18 17:51:46 2010 +0400
@@ -54,9 +54,10 @@
 			/* It's only a type tuple if all the Object's are types
 			 */
 			for (size_t i = 0; i < objects.dim; i++)
-			{   Dsymbol o = cast(Dsymbol)objects.data[i];
+			{   
+				Object o = cast(Object)objects.data[i];
 
-				if (o.dyncast() != DYNCAST.DYNCAST_TYPE)
+				if (cast(Type)o is null)
 				{
 					//printf("\tnot[%d], %p, %d\n", i, o, o->dyncast());
 					return null;
@@ -93,11 +94,13 @@
 	{
 		//printf("TupleDeclaration::needThis(%s)\n", toChars());
 		for (size_t i = 0; i < objects.dim; i++)
-		{   Dsymbol o = cast(Dsymbol)objects.data[i];
-			if (o.dyncast() == DYNCAST.DYNCAST_EXPRESSION)
-			{   Expression e = cast(Expression)o;
+		{   
+			Object o = cast(Object)objects.data[i];
+			if (auto e = cast(Expression)o)
+			{
 				if (e.op == TOKdsymbol)
-				{	DsymbolExp ve = cast(DsymbolExp)e;
+				{	
+					DsymbolExp ve = cast(DsymbolExp)e;
 					Declaration d = ve.s.isDeclaration();
 					if (d && d.needThis())
 					{
--- a/dmd/TupleExp.d	Tue Apr 13 21:26:45 2010 +0100
+++ b/dmd/TupleExp.d	Tue May 18 17:51:46 2010 +0400
@@ -87,28 +87,26 @@
 
 		exps.reserve(tup.objects.dim);
 		for (size_t i = 0; i < tup.objects.dim; i++)
-		{   Dsymbol o = cast(Dsymbol)tup.objects.data[i];
-			if (o.dyncast() == DYNCAST.DYNCAST_EXPRESSION)
+		{   
+			Object o = cast(Object)tup.objects.data[i];
+			if (auto e = cast(Expression)o)
 			{
-				Expression e = cast(Expression)o;
 				e = e.syntaxCopy();
 				exps.push(cast(void*)e);
 			}
-			else if (o.dyncast() == DYNCAST.DYNCAST_DSYMBOL)
+			else if (auto s = cast(Dsymbol)o)
 			{
-				Dsymbol s = cast(Dsymbol)o;
 				Expression e = new DsymbolExp(loc, s);
 				exps.push(cast(void*)e);
 			}
-			else if (o.dyncast() == DYNCAST.DYNCAST_TYPE)
+			else if (auto t = cast(Type)o)
 			{
-				Type t = cast(Type)o;
 				Expression e = new TypeExp(loc, t);
 				exps.push(cast(void*)e);
 			}
 			else
 			{
-				error("%s is not an expression", o.toChars());
+				error("%s is not an expression", o.toString());
 			}
 		}
 	}
--- a/setupenv.bat	Tue Apr 13 21:26:45 2010 +0100
+++ b/setupenv.bat	Tue May 18 17:51:46 2010 +0400
@@ -1,1 +1,1 @@
-set path=c:\dm\bin;c:\dmd_2.031\windows\bin;%PATH%
\ No newline at end of file
+set path=c:\dm\bin;c:\dmd_2.046\windows\bin;%PATH%
\ No newline at end of file