From: <zy...@us...> - 2008-08-10 19:52:55
|
Revision: 5132 http://jython.svn.sourceforge.net/jython/?rev=5132&view=rev Author: zyasoft Date: 2008-08-10 19:52:51 +0000 (Sun, 10 Aug 2008) Log Message: ----------- After a more careful reading of PEP 342: need to emit bytecode for getGeneratorInput and possible raising exception before any yields; and after each yield point. This one-line change fixes test_contextlib Modified Paths: -------------- branches/asm/src/org/python/compiler/CodeCompiler.java Modified: branches/asm/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/asm/src/org/python/compiler/CodeCompiler.java 2008-08-10 15:31:52 UTC (rev 5131) +++ branches/asm/src/org/python/compiler/CodeCompiler.java 2008-08-10 19:52:51 UTC (rev 5132) @@ -552,15 +552,17 @@ throw new ParseException("'yield' outside function", node); } - loadFrame(); - code.invokevirtual("org/python/core/PyFrame", "getGeneratorInput", "()" + $obj); - code.dup(); - code.instanceof_("org/python/core/PyException"); - Label done = new Label(); - code.ifeq(done); - code.checkcast("java/lang/Throwable"); - code.athrow(); - code.label(done); + if (yield_count == 0) { + loadFrame(); + code.invokevirtual("org/python/core/PyFrame", "getGeneratorInput", "()" + $obj); + code.dup(); + code.instanceof_("org/python/core/PyException"); + Label done = new Label(); + code.ifeq(done); + code.checkcast("java/lang/Throwable"); + code.athrow(); + code.label(done); + } if (node.value != null) { visit(node.value); @@ -577,14 +579,14 @@ restoreLocals(); loadFrame(); - code.invokevirtual("org/python/core/PyFrame", "checkGeneratorInput", "()" + $obj); + code.invokevirtual("org/python/core/PyFrame", "getGeneratorInput", "()" + $obj); code.dup(); code.instanceof_("org/python/core/PyException"); - done = new Label(); - code.ifeq(done); + Label done2 = new Label(); + code.ifeq(done2); code.checkcast("java/lang/Throwable"); code.athrow(); - code.label(done); + code.label(done2); code.checkcast("org/python/core/PyObject"); return null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |