diff dmd/IndexExp.d @ 79:43073c7c7769

updated to 2.035 also implemented a few missing functions still crashes in Import.importAll though
author Trass3r
date Mon, 30 Aug 2010 03:57:51 +0200
parents ef02e2e203c2
children 3482c73a991b
line wrap: on
line diff
--- a/dmd/IndexExp.d	Sun Aug 29 14:39:08 2010 +0100
+++ b/dmd/IndexExp.d	Mon Aug 30 03:57:51 2010 +0200
@@ -45,8 +45,6 @@
 import core.stdc.string;
 import core.stdc.stdio;
 
-extern (C) extern void exit(int);
-
 class IndexExp : BinExp
 {
 	VarDeclaration lengthVar;
@@ -150,9 +148,6 @@
 				TupleExp te;
 				TypeTuple tup;
 
-				printf("e1.op: %d\n", e1.op);
-				exit(-1);
-				
 				if (e1.op == TOKtuple)
 				{	
 					te = cast(TupleExp)e1;
@@ -299,12 +294,10 @@
 	{
 		elem* e;
 		elem* n1 = e1.toElem(irs);
-		elem* n2;
 		elem* eb = null;
-		Type t1;
 
 		//printf("IndexExp.toElem() %s\n", toChars());
-		t1 = e1.type.toBasetype();
+		Type t1 = e1.type.toBasetype();
 		if (t1.ty == Taarray)
 		{
 			// set to:
@@ -314,19 +307,23 @@
 			elem* keyti;
 			elem* ep;
 			int vsize = cast(int)taa.next.size();
-			elem* valuesize;
 			Symbol* s;
 
 			// n2 becomes the index, also known as the key
-			n2 = e2.toElem(irs);
+			elem* n2 = e2.toElem(irs);
 			if (tybasic(n2.Ety) == TYstruct || tybasic(n2.Ety) == TYarray)
 			{
 				n2 = el_una(OPstrpar, TYstruct, n2);
 				n2.Enumbytes = n2.E1.Enumbytes;
+				if (taa.index.ty == Tsarray)
+			    {
+					assert(e2.type.size() == taa.index.size());
+					n2.Enumbytes = cast(size_t) taa.index.size();
+			    }
 				//printf("numbytes = %d\n", n2.Enumbytes);
 				assert(n2.Enumbytes);
 			}
-			valuesize = el_long(TYuint, vsize);	// BUG: should be TYsize_t
+			elem* valuesize = el_long(TYuint, vsize);	// BUG: should be TYsize_t
 			//printf("valuesize: "); elem_print(valuesize);
 			if (modifiable)
 			{
@@ -344,17 +341,16 @@
 			//elem_print(keyti);
 			ep = el_params(n2, valuesize, keyti, n1, null);
 			e = el_bin(OPcall, TYnptr, el_var(s), ep);
+
 			if (global.params.useArrayBounds)
 			{
-				elem* n;
 				elem* ea;
 
-				n = el_same(&e);
+				elem* n = el_same(&e);
 
 				// Construct: ((e || ModuleAssert(line)),n)
-				Symbol* sassert;
-
-				sassert = irs.blx.module_.toModuleArray();
+				Symbol* sassert = irs.blx.module_.toModuleArray();
+				
 				ea = el_bin(OPcall,TYvoid,el_var(sassert),
 				el_long(TYint, loc.linnum));
 				e = el_bin(OPoror,TYvoid,e,ea);
@@ -366,10 +362,8 @@
 		}
 		else
 		{	
-			elem* einit;
-
-			einit = resolveLengthVar(lengthVar, &n1, t1);
-			n2 = e2.toElem(irs);
+			elem* einit = resolveLengthVar(lengthVar, &n1, t1);
+			elem* n2 = e2.toElem(irs);
 
 			if (global.params.useArrayBounds)
 			{