Bug 903419 part 1. Change js::GetErrorTypeName to take a JSRuntime, not a JSContext. r=luke

This commit is contained in:
Boris Zbarsky 2013-08-29 00:30:06 -04:00
parent 147ce0c04a
commit 18cd0e8414
4 changed files with 18 additions and 6 deletions

View File

@ -509,7 +509,7 @@ NS_ScriptErrorReporter(JSContext *cx,
const PRUnichar* m = static_cast<const PRUnichar*>(report->ucmessage);
if (m) {
const PRUnichar* n = static_cast<const PRUnichar*>
(js::GetErrorTypeName(cx, report->exnType));
(js::GetErrorTypeName(JS_GetRuntime(cx), report->exnType));
if (n) {
msg.Assign(n);
msg.AppendLiteral(": ");

View File

@ -193,14 +193,26 @@ TypeName(JSType type, JSContext *cx)
}
inline Handle<PropertyName*>
ClassName(JSProtoKey key, ExclusiveContext *cx)
ClassName(JSProtoKey key, JSAtomState &atomState)
{
JS_ASSERT(key < JSProto_LIMIT);
JS_STATIC_ASSERT(offsetof(JSAtomState, Null) +
JSProto_LIMIT * sizeof(FixedHeapPtr<PropertyName>) <=
sizeof(JSAtomState));
JS_STATIC_ASSERT(JSProto_Null == 0);
return (&cx->names().Null)[key];
return (&atomState.Null)[key];
}
inline Handle<PropertyName*>
ClassName(JSProtoKey key, JSRuntime *rt)
{
return ClassName(key, rt->atomState);
}
inline Handle<PropertyName*>
ClassName(JSProtoKey key, ExclusiveContext *cx)
{
return ClassName(key, cx->names());
}
} // namespace js

View File

@ -872,7 +872,7 @@ js_GetLocalizedErrorMessage(JSContext* cx, void *userRef, const char *locale,
}
JS_FRIEND_API(const jschar*)
js::GetErrorTypeName(JSContext* cx, int16_t exnType)
js::GetErrorTypeName(JSRuntime* rt, int16_t exnType)
{
/*
* JSEXN_INTERNALERR returns null to prevent that "InternalError: "
@ -884,7 +884,7 @@ js::GetErrorTypeName(JSContext* cx, int16_t exnType)
return NULL;
}
JSProtoKey key = GetExceptionProtoKey(exnType);
return ClassName(key, cx)->chars();
return ClassName(key, rt)->chars();
}
#if defined ( DEBUG_mccabe ) && defined ( PRINTNAMES )

View File

@ -713,7 +713,7 @@ CastToJSFreeOp(FreeOp *fop)
* Returns NULL for invalid arguments and JSEXN_INTERNALERR
*/
extern JS_FRIEND_API(const jschar*)
GetErrorTypeName(JSContext* cx, int16_t exnType);
GetErrorTypeName(JSRuntime* rt, int16_t exnType);
#ifdef DEBUG
extern JS_FRIEND_API(unsigned)