diff spidermonkey-playground.cpp @ 13:d200a8158bd5

Fixed a bug in the throw hook, added a 'scopeChain' property to stack frames.
author Atul Varma <varmaa@toolness.com>
date Fri, 19 Jun 2009 15:25:32 -0700
parents e14f433f3a58
children 1d73446eef62
line wrap: on
line diff
--- a/spidermonkey-playground.cpp	Fri Jun 19 15:16:11 2009 -0700
+++ b/spidermonkey-playground.cpp	Fri Jun 19 15:25:32 2009 -0700
@@ -129,6 +129,7 @@
     jsval filenameVal = JSVAL_NULL;
     jsval lineNoVal = JSVAL_ZERO;
     jsval functionObjectVal = JSVAL_NULL;
+    jsval scopeChainVal = JSVAL_NULL;
 
     JSFunction *func = JS_GetFrameFunction(cx, frame);
     if (func) {
@@ -152,6 +153,9 @@
 
       JSObject *functionObject = JS_GetFrameFunctionObject(cx, frame);
       functionObjectVal = OBJECT_TO_JSVAL(functionObject);
+
+      JSObject *scopeChain = JS_GetFrameScopeChain(cx, frame);
+      scopeChainVal = OBJECT_TO_JSVAL(scopeChain);
     }
 
     JSObject *frameInfo = JS_NewObject(cx, NULL, NULL, NULL);
@@ -163,6 +167,8 @@
                       NULL, NULL, 0);
     JS_DefineProperty(cx, frameInfo, "functionObject", functionObjectVal,
                       NULL, NULL, 0);
+    JS_DefineProperty(cx, frameInfo, "scopeChain", scopeChainVal,
+                      NULL, NULL, 0);
 
     if (prevFrameInfo)
       JS_DefineProperty(cx, prevFrameInfo, "caller",
@@ -188,10 +194,15 @@
   jsval lastExceptionTraceback;
   jsval lastException;
 
+  jsval exception = *rval;
+  if (JS_IsExceptionPending(cx))
+    if (!JS_GetPendingException(cx, &exception))
+      printf("Getting exception failed.\n");
+
   if (!JS_GetProperty(cx, tcb_global, "lastException", &lastException))
     printf("Unable to retrieve last exception.");
 
-  if (lastException == *rval)
+  if (lastException == exception)
     // The same exception is just propagating through the stack; keep
     // our existing last-exception info.
     return JSTRAP_CONTINUE;
@@ -201,11 +212,6 @@
     lastExceptionTraceback = JSVAL_NULL;
   }
 
-  jsval exception = *rval;
-  if (JS_IsExceptionPending(cx))
-    if (!JS_GetPendingException(cx, &exception))
-      printf("Getting exception failed.\n");
-
   if (!JS_SetProperty(cx, tcb_global, "lastExceptionTraceback",
                       &lastExceptionTraceback) ||
       !JS_SetProperty(cx, tcb_global, "lastException", &exception))