From: <zy...@us...> - 2009-02-07 21:26:34
|
Revision: 6022 http://jython.svn.sourceforge.net/jython/?rev=6022&view=rev Author: zyasoft Date: 2009-02-07 21:26:31 +0000 (Sat, 07 Feb 2009) Log Message: ----------- Fixed control flow by pushing the wrapped Why onto the stack (instead of its string representation from the earliest version of this code). Modified Paths: -------------- branches/pbcvm/src/org/python/core/PyBytecode.java Modified: branches/pbcvm/src/org/python/core/PyBytecode.java =================================================================== --- branches/pbcvm/src/org/python/core/PyBytecode.java 2009-02-07 18:14:33 UTC (rev 6021) +++ branches/pbcvm/src/org/python/core/PyBytecode.java 2009-02-07 21:26:31 UTC (rev 6022) @@ -706,9 +706,16 @@ if (why == Why.RETURN || why == Why.CONTINUE) { retval = stack.pop(); } - } else if ((v instanceof PyStackException) || (v instanceof PyString)) { + } else if (v instanceof PyStackException) { ts.exception = ((PyStackException) v).exception; why = Why.RERAISE; + + } else if (v instanceof PyString) { + if (debug) { + System.err.println("ts.exception=" + ts.exception + ", v=" + v); +// ts.exception = new PyException(v); // XXX - what do I do about string exceptions??!!! + } + why = Why.RERAISE; } else if (v != Py.None) { throw Py.SystemError("'finally' pops bad exception"); } @@ -1059,15 +1066,6 @@ case Opcode.MAKE_CLOSURE: { PyCode code = (PyCode) stack.pop(); PyObject[] closure_cells = ((PySequenceList) (stack.pop())).getArray(); -// PyObject[] closure_cells = new PyCell[src_closure_cells.length]; -// for (int i = 0; i < src_closure_cells.length; i++) { -// PyCell cell = new PyCell(); -// cell.ob_ref = src_closure_cells[i]; -// closure_cells[i] = cell; -// } -//// for (int i = 0; i < src_closure_cells.length; i++) { -//// closure_cells[i] = f.getclosure(i); -//// } PyObject[] defaults = stack.popN(oparg); PyFunction func = new PyFunction(f.f_globals, defaults, code, closure_cells); stack.push(func); @@ -1144,13 +1142,12 @@ stack.push(exc.traceback); stack.push(exc.value); stack.push(new PyStackException(exc)); // instead of stack.push(exc.type);, like CPython -// stack.dup(); // x3 to conform with CPython's calling convention, which -// stack.dup(); // stores the type, val, tb separately on the stack } else { if (why == Why.RETURN || why == Why.CONTINUE) { stack.push(retval); } - stack.push(Py.newString(why.name())); // XXX - hack! + // FIGURE OUT THE FLOW HERE, in test_optparse2 + stack.push(new PyStackWhy(why)); } why = Why.NOT; next_instr = b.b_handler; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |