Mercurial > pymonkey
diff src/context.cpp @ 146:b1cf9decc36f
Added 'lineno' and 'pc' attributes to stack frame information.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sat, 29 Aug 2009 13:16:43 -0700 |
parents | 5d53f6293a81 |
children | ebc0ff767290 |
line wrap: on
line diff
--- a/src/context.cpp Fri Aug 28 22:46:07 2009 -0700 +++ b/src/context.cpp Sat Aug 29 13:16:43 2009 -0700 @@ -41,6 +41,7 @@ #include "utils.h" #include "jsdbgapi.h" +#include "jsscript.h" // This is the default JSOperationCallback for pymonkey-owned JS contexts, // when they've defined one in Python. @@ -140,20 +141,29 @@ while ((frame = JS_FrameIterator(self->cx, &iteratorp)) != NULL) { bool success = true; JSScript *script = JS_GetFrameScript(self->cx, frame); + unsigned int pc = 0; + unsigned int lineno = 0; PyObject *pyScript; - if (script) + if (script) { pyScript = (PyObject *) PYM_newJSScript(self, script); - else { + if (pyScript == NULL) + return NULL; + jsbytecode *pcByte = JS_GetFramePC(self->cx, frame); + pc = pcByte - script->code; + lineno = JS_PCToLineNumber(self->cx, script, pcByte); + } else { pyScript = Py_None; Py_INCREF(pyScript); } PyObject *frameDict = Py_BuildValue( - "{sO}", - "script", pyScript + "{sOsIsI}", + "script", pyScript, + "pc", pc, + "lineno", lineno ); - Py_XDECREF(pyScript); + Py_DECREF(pyScript); if (frameDict) { if (last) {