From: <zy...@us...> - 2009-01-27 02:59:52
|
Revision: 5987 http://jython.svn.sourceforge.net/jython/?rev=5987&view=rev Author: zyasoft Date: 2009-01-27 01:45:48 +0000 (Tue, 27 Jan 2009) Log Message: ----------- Fixed raising of exceptions and PyStack.rot Modified Paths: -------------- branches/pbcvm/Tools/pbcvm/extract.py branches/pbcvm/src/org/python/core/PyBytecode.java Modified: branches/pbcvm/Tools/pbcvm/extract.py =================================================================== --- branches/pbcvm/Tools/pbcvm/extract.py 2009-01-26 18:11:57 UTC (rev 5986) +++ branches/pbcvm/Tools/pbcvm/extract.py 2009-01-27 01:45:48 UTC (rev 5987) @@ -62,7 +62,6 @@ functions.append(("%s.%s" % (classname, methodname), method)) return functions -# what if we are passed a builtin? need to identify that signature def extract_code_obj(f_or_code): if inspect.iscode(f_or_code): code = f_or_code @@ -91,12 +90,10 @@ co_consts.append(extract_def(const)) else: co_consts.append(repr(const)) - values.append("["+', '.join(co_consts)+"]") - elif attr == 'co_lnotab': - values.append(repr(None)) + values.append((attr, "["+', '.join(co_consts)+"]")) else: - values.append(repr(getattr(code, attr))) - _codeobjs[code] = "PyBytecode(\n" + ',\n'.join([' '* 4 + v for v in values])+")" + values.append((attr, repr(getattr(code, attr)))) + _codeobjs[code] = "PyBytecode(\n" + ',\n'.join([' '* 4 + v + ' # ' + attr for (attr, v) in values])+")" return "_codeobjs[%r]" % (name,) Modified: branches/pbcvm/src/org/python/core/PyBytecode.java =================================================================== --- branches/pbcvm/src/org/python/core/PyBytecode.java 2009-01-26 18:11:57 UTC (rev 5986) +++ branches/pbcvm/src/org/python/core/PyBytecode.java 2009-01-27 01:45:48 UTC (rev 5987) @@ -17,8 +17,8 @@ } return opname; } - private boolean debug = false; + public PyObject _debug(int maxCount) { debug = maxCount > 0; this.maxCount = maxCount; @@ -66,7 +66,6 @@ co_code = codestring.toCharArray(); co_lnotab = null; // ignore } - private static final String[] __members__ = { "co_name", "co_argcount", "co_varnames", "co_filename", "co_firstlineno", @@ -173,15 +172,6 @@ } } - private static Why do_raise(ThreadState ts, PyObject type, PyObject value, PyTraceback traceback) { - PyException pye = type == null ? ts.exception : new PyException(type, value, traceback); - if (traceback == null) { - return Why.EXCEPTION; - } else { - return Why.RERAISE; - } - } - private static String stringify_blocks(PyFrame f) { if (f.f_exits == null || f.f_blockstate[0] == 0) { return "[]"; @@ -635,22 +625,22 @@ PyTraceback tb = (PyTraceback) (stack.pop()); PyObject value = stack.pop(); PyObject type = stack.pop(); - why = do_raise(ts, type, value, tb); + PyException.doRaise(type, value, tb); break; } case 2: { PyObject value = stack.pop(); PyObject type = stack.pop(); - why = do_raise(ts, type, value, null); + PyException.doRaise(type, value, null); break; } case 1: { PyObject type = stack.pop(); - why = do_raise(ts, type, null, null); + PyException.doRaise(type, null, null); break; } case 0: - why = do_raise(ts, null, null, null); + PyException.doRaise(null, null, null); break; default: throw Py.SystemError("bad RAISE_VARARGS oparg"); @@ -798,6 +788,7 @@ case Opcode.BUILD_MAP: stack.push(new PyDictionary()); + break; case Opcode.LOAD_ATTR: stack.push(stack.pop().__getattr__(co_names[oparg])); @@ -1073,6 +1064,7 @@ while (why != Why.NOT && blocksLeft(f)) { PyTryBlock b = popBlock(f); +// System.err.println("Processing block: " + b); assert (why != Why.YIELD); if (b.b_type == Opcode.SETUP_LOOP && why == Why.CONTINUE) { pushBlock(f, b); @@ -1282,7 +1274,9 @@ void rot(int n) { int end = stack.size(); List<PyObject> lastN = stack.subList(end - n, end); - Collections.rotate(lastN, n); +// System.err.print("rot(" + n + "): " + lastN.toString() + " -> "); + Collections.rotate(lastN, n - 1); +// System.err.println("rot(" + n + "): " + lastN.toString()); } int size() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |