diff dmd/GotoDefaultStatement.d @ 68:ee3a9f34dc48

final bits of codegen implementation to compile Phobos
author korDen
date Tue, 24 Aug 2010 16:44:34 +0400
parents 4290d870944a
children 2e2a5c3f943a
line wrap: on
line diff
--- a/dmd/GotoDefaultStatement.d	Mon Aug 23 21:21:05 2010 +0400
+++ b/dmd/GotoDefaultStatement.d	Tue Aug 24 16:44:34 2010 +0400
@@ -11,6 +11,11 @@
 import dmd.IRState;
 import dmd.BE;
 
+import dmd.backend.block;
+import dmd.backend.Blockx;
+import dmd.backend.Util;
+import dmd.backend.BC;
+
 class GotoDefaultStatement : Statement
 {
     SwitchStatement sw;
@@ -52,6 +57,33 @@
 
     void toIR(IRState *irs)
 	{
-		assert(false);
+		block *b;
+		Blockx *blx = irs.blx;
+		block *bdest = irs.getDefaultBlock();
+
+		b = blx.curblock;
+
+		// The rest is equivalent to GotoStatement
+
+		// Adjust exception handler scope index if in different try blocks
+		if (b.Btry != bdest.Btry)
+		{
+		// Check that bdest is in an enclosing try block
+		for (block* bt = b.Btry; bt != bdest.Btry; bt = bt.Btry)
+		{
+			if (!bt)
+			{
+				//printf("b.Btry = %p, bdest.Btry = %p\n", b.Btry, bdest.Btry);
+				error("cannot goto into try block");
+				break;
+			}
+		}
+
+		//setScopeIndex(blx, b, bdest.Btry ? bdest.Btry.Bscope_index : -1);
+		}
+
+		list_append(&b.Bsucc,bdest);
+		incUsage(irs, loc);
+		block_next(blx,BCgoto,null);
 	}
 }
\ No newline at end of file