Nice/src/gnu/expr LambdaExp.java,1.27,1.28

Daniel Bonniot <[email protected]>
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/src/gnu/expr
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10410/src/gnu/expr

Modified Files:
	LambdaExp.java 
Log Message:
Revert to revision 1.26 since the case of falsely reachable points because
of 'assert false' is handled in the more general case by
stdlib/nice/lang/inline/Assert.java revision 1.8.


Index: LambdaExp.java
===================================================================
RCS file: /cvsroot/nice/Nice/src/gnu/expr/LambdaExp.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** LambdaExp.java	25 Dec 2004 15:51:44 -0000	1.27
--- LambdaExp.java	20 Feb 2005 13:20:03 -0000	1.28
***************
*** 482,510 ****
        {
  	if (comp.method.reachableHere()
  	    && (! Compilation.usingTailCalls
  		|| isModuleBody() || isClassMethod() || isHandlingTailCalls()))
!           {
!             /* If there is a value to return, or the method returns void,
!                then emit a return.
!             */
!             if (code.SP > 0 || comp.method.getReturnType().isVoid())
!               code.emitReturn();
!             else
!               /*
!                 This can happen for unreachable code, like after an
!                 'assert false' in a non-void method.
! 
!                 It can also be because reachableHere is not computed properly.
!               */
!               {
!                 // Throw an error explaining the situation.
!                 ClassType error = ClassType.make("java.lang.Error");
!                 code.emitNew(error);
!                 code.emitDup();
!                 code.emitPushString("Invalid location reached. Enable assertion checking to get more precise information");
!                 code.emitInvokeSpecial(error.getDeclaredMethod("<init>", new Type[]{Type.string_type}));
!                 code.emitThrow();
!               }
!           }
  	code.popScope();        // Undoes enterScope in allocParameters
        }
--- 482,493 ----
        {
  	if (comp.method.reachableHere()
+ 	    /* Work-around since reachableHere is not computed properly:
+ 	       Only return if the method is void or if there is a value
+ 	       on the stack.
+ 	    */
+ 	    && (code.SP > 0 || comp.method.getReturnType().isVoid())
  	    && (! Compilation.usingTailCalls
  		|| isModuleBody() || isClassMethod() || isHandlingTailCalls()))
! 	  code.emitReturn();
  	code.popScope();        // Undoes enterScope in allocParameters
        }



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.