Bug 1254893 - Add a .format property on Debugger.Script. (r=jimb)

This commit is contained in:
Shu-yu Guo 2016-03-11 21:43:21 -08:00
Родитель 9cca2b6184
Коммит a9256459dd
3 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -128,6 +128,9 @@ from its prototype:
: This is `true` if this script's code is ECMAScript strict mode code, and
`false` otherwise.
`format`
: If the script is WebAssembly, this is `"wasm"`. Otherwise, this is `"js"`.
## Function Properties of the Debugger.Script Prototype Object
The functions described below may only be called with a `this` value

Просмотреть файл

@ -144,6 +144,7 @@
macro(isExtensible, isExtensible, "isExtensible") \
macro(iteratorIntrinsic, iteratorIntrinsic, "__iterator__") \
macro(join, join, "join") \
macro(js, js, "js") \
macro(keys, keys, "keys") \
macro(label, label, "label") \
macro(lastIndex, lastIndex, "lastIndex") \
@ -269,6 +270,7 @@
macro(var, var, "var") \
macro(variable, variable, "variable") \
macro(void0, void0, "(void 0)") \
macro(wasm, wasm, "wasm") \
macro(watch, watch, "watch") \
macro(WeakSet_add, WeakSet_add, "WeakSet_add") \
macro(weekday, weekday, "weekday") \

Просмотреть файл

@ -5289,6 +5289,25 @@ DebuggerScript_getGlobal(JSContext* cx, unsigned argc, Value* vp)
return true;
}
class DebuggerScriptGetFormatMatcher
{
const JSAtomState& names_;
public:
explicit DebuggerScriptGetFormatMatcher(const JSAtomState& names) : names_(names) { }
using ReturnType = JSAtom*;
ReturnType match(HandleScript script) { return names_.js; }
ReturnType match(Handle<WasmModuleObject*> wasmModule) { return names_.wasm; }
};
static bool
DebuggerScript_getFormat(JSContext* cx, unsigned argc, Value* vp)
{
THIS_DEBUGSCRIPT_REFERENT(cx, argc, vp, "(get format)", args, obj, referent);
DebuggerScriptGetFormatMatcher matcher(cx->names());
args.rval().setString(referent.match(matcher));
return true;
}
static bool
DebuggerScript_getChildScripts(JSContext* cx, unsigned argc, Value* vp)
{
@ -6205,6 +6224,7 @@ static const JSPropertySpec DebuggerScript_properties[] = {
JS_PSG("sourceStart", DebuggerScript_getSourceStart, 0),
JS_PSG("sourceLength", DebuggerScript_getSourceLength, 0),
JS_PSG("global", DebuggerScript_getGlobal, 0),
JS_PSG("format", DebuggerScript_getFormat, 0),
JS_PS_END
};