This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Google Summer of Code


I think I solved the problem, besides the stack size inconsistency
there was a missing return statement at the end of the switch bytecode,
and after each case. The code handling the numCases > 1 case
automatically inserts the return statements,  instead when numCases <=
1 they have to be inserted explicitly. 

I changed only few lines of code in SwitchState.java (see the
attachment). I compiled kawa with these changes and it seems to work.
Do you see some problem in this code?

Now I can start to look at the type-checking in InlineCalls.

Andrea  

--- Programmazione/Projects/Kawa/code/gnu/bytecode/SwitchState.java	2014-03-09 17:57:31.358834943 +0100
+++ Programmazione/Projects/Kawa/code_mod/gnu/bytecode/SwitchState.java	2014-04-13 17:05:06.886136667 +0200
@@ -183,7 +183,7 @@
   {
     if (outerTry != code.try_stack)
       throw new Error("exitSwitch cannot exit through a try");
-    code.emitGoto(after_label);
+    code.emitReturn();
   }
 
   /** Handle the end of the switch statement.
@@ -204,9 +204,13 @@
 	code.emitInvokeSpecial(con);
 	code.emitThrow();
       }
+    if (numCases <= 1)
+    	code.emitReturn();
     code.fixupChain(switch_label, after_label);
     if (numCases <= 1)
       {
+	if (code.getSP() == 1)	
+	    code.popType();
 	code.pushType(Type.intType);
 	if (numCases == 1)
 	  {

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]