static void _dumpJSDScript(JSDContext* jsdc, JSDScript* jsdscript, const char* leadingtext) { const char* name; JSString* fun; unsigned base; unsigned extent; char Buf[256]; size_t n; name = jsd_GetScriptFilename(jsdc, jsdscript); fun = jsd_GetScriptFunctionId(jsdc, jsdscript); base = jsd_GetScriptBaseLineNumber(jsdc, jsdscript); extent = jsd_GetScriptLineExtent(jsdc, jsdscript); n = size_t(snprintf(Buf, sizeof(Buf), "%sscript=%08X, %s, ", leadingtext, (unsigned) jsdscript->script, name ? name : "no URL")); if (n + 1 < sizeof(Buf)) { if (fun) { n += size_t(snprintf(Buf + n, sizeof(Buf) - n, "%s", "no fun")); } else { n += JS_PutEscapedFlatString(Buf + n, sizeof(Buf) - n, JS_ASSERT_STRING_IS_FLAT(fun), 0); Buf[sizeof(Buf) - 1] = '\0'; } if (n + 1 < sizeof(Buf)) snprintf(Buf + n, sizeof(Buf) - n, ", %d-%d\n", base, base + extent - 1); } OutputDebugString( Buf ); }
void jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj, JSAbstractFramePtr frame) { JSDObject* jsdobj; JS::RootedScript script(cx); JSDScript* jsdscript; const char* ctorURL; JSString* ctorNameStr; const char* ctorName; JSD_LOCK_OBJECTS(jsdc); jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj); if( jsdobj && !jsdobj->ctorURL ) { script = frame.script(); if( script ) { ctorURL = JS_GetScriptFilename(cx, script); if( ctorURL ) jsdobj->ctorURL = jsd_AddAtom(jsdc, ctorURL); JSD_LOCK_SCRIPTS(jsdc); jsdscript = jsd_FindOrCreateJSDScript(jsdc, cx, script, frame); JSD_UNLOCK_SCRIPTS(jsdc); if( jsdscript && (ctorNameStr = jsd_GetScriptFunctionId(jsdc, jsdscript)) ) { if( (ctorName = JS_EncodeString(cx, ctorNameStr)) ) { jsdobj->ctorName = jsd_AddAtom(jsdc, ctorName); JS_free(cx, (void *) ctorName); } } jsdobj->ctorLineno = JS_GetScriptBaseLineNumber(cx, script); } } TRACEOBJ(jsdc, jsdobj, 3); JSD_UNLOCK_OBJECTS(jsdc); }
JSD_GetScriptFunctionId(JSDContext* jsdc, JSDScript *jsdscript) { JSD_ASSERT_VALID_CONTEXT(jsdc); JSD_ASSERT_VALID_SCRIPT(jsdscript); return jsd_GetScriptFunctionId(jsdc, jsdscript); }