From: <zy...@us...> - 2008-08-09 05:36:19
|
Revision: 5114 http://jython.svn.sourceforge.net/jython/?rev=5114&view=rev Author: zyasoft Date: 2008-08-09 05:36:17 +0000 (Sat, 09 Aug 2008) Log Message: ----------- Reordered code to test for raising exceptions thrown into a generator, fixing test cases in test_contextlib, test_generators, and test_with. Modified Paths: -------------- branches/asm/src/org/python/compiler/ClassFile.java branches/asm/src/org/python/compiler/CodeCompiler.java branches/asm/src/org/python/compiler/Module.java Modified: branches/asm/src/org/python/compiler/ClassFile.java =================================================================== --- branches/asm/src/org/python/compiler/ClassFile.java 2008-08-09 00:37:11 UTC (rev 5113) +++ branches/asm/src/org/python/compiler/ClassFile.java 2008-08-09 05:36:17 UTC (rev 5114) @@ -48,9 +48,7 @@ this.interfaces = new String[0]; this.access = access; - //XXX: can we do better than ASM for computing MAXS? cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - methodVisitors = Collections.synchronizedList(new ArrayList()); fieldVisitors = Collections.synchronizedList(new ArrayList()); } Modified: branches/asm/src/org/python/compiler/CodeCompiler.java =================================================================== --- branches/asm/src/org/python/compiler/CodeCompiler.java 2008-08-09 00:37:11 UTC (rev 5113) +++ branches/asm/src/org/python/compiler/CodeCompiler.java 2008-08-09 05:36:17 UTC (rev 5114) @@ -552,7 +552,15 @@ throw new ParseException("'yield' outside function", node); } - saveLocals(); + 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); @@ -560,6 +568,7 @@ getNone(); } setLastI(++yield_count); + saveLocals(); code.areturn(); Label restart = new Label(); @@ -568,10 +577,10 @@ restoreLocals(); loadFrame(); - code.invokevirtual("org/python/core/PyFrame", "getGeneratorInput", "()" + $obj); + code.invokevirtual("org/python/core/PyFrame", "checkGeneratorInput", "()" + $obj); code.dup(); code.instanceof_("org/python/core/PyException"); - Label done = new Label(); + done = new Label(); code.ifeq(done); code.checkcast("java/lang/Throwable"); code.athrow(); Modified: branches/asm/src/org/python/compiler/Module.java =================================================================== --- branches/asm/src/org/python/compiler/Module.java 2008-08-09 00:37:11 UTC (rev 5113) +++ branches/asm/src/org/python/compiler/Module.java 2008-08-09 05:36:17 UTC (rev 5114) @@ -437,19 +437,7 @@ if (scope.generator) { c.label(genswitch); - // throw any exception that was sent into this generator c.aload(1); - c.invokevirtual("org/python/core/PyFrame", "checkGeneratorInput", "()" + $obj); - c.dup(); - c.instanceof_("org/python/core/PyException"); - Label done = new Label(); - c.ifeq(done); - c.checkcast("java/lang/Throwable"); - c.athrow(); - c.label(done); - - c.pop(); - c.aload(1); c.getfield("org/python/core/PyFrame", "f_lasti", "I"); Label[] yields = new Label[compiler.yields.size()+1]; @@ -458,7 +446,6 @@ yields[i] = (Label) compiler.yields.elementAt(i-1); } c.tableswitch(0, yields.length - 1, start, yields); - // XXX: Generate an error } // !classdef only This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |