зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1121935 - Add intrinsic for retrieving the original constructor for typed array instances. r=Waldo
This commit is contained in:
Родитель
28ffbe8fb9
Коммит
3a99d04c35
|
@ -766,6 +766,24 @@ js::intrinsic_IsConstructing(JSContext *cx, unsigned argc, Value *vp)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
intrinsic_ConstructorForTypedArray(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
MOZ_ASSERT(args.length() == 1);
|
||||
MOZ_ASSERT(args[0].isObject());
|
||||
MOZ_ASSERT(IsAnyTypedArray(&args[0].toObject()));
|
||||
|
||||
RootedObject object(cx, &args[0].toObject());
|
||||
JSProtoKey protoKey = StandardProtoKeyOrNull(object);
|
||||
MOZ_ASSERT(protoKey);
|
||||
RootedValue ctor(cx, cx->global()->getConstructor(protoKey));
|
||||
MOZ_ASSERT(ctor.isObject());
|
||||
|
||||
args.rval().set(ctor);
|
||||
return true;
|
||||
}
|
||||
|
||||
// The self-hosting global isn't initialized with the normal set of builtins.
|
||||
// Instead, individual C++-implemented functions that're required by
|
||||
// self-hosted code are defined as global functions. Accessing these
|
||||
|
@ -844,6 +862,7 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
|||
JS_FN("AssertionFailed", intrinsic_AssertionFailed, 1,0),
|
||||
JS_FN("MakeConstructible", intrinsic_MakeConstructible, 2,0),
|
||||
JS_FN("_IsConstructing", intrinsic_IsConstructing, 0,0),
|
||||
JS_FN("_ConstructorForTypedArray", intrinsic_ConstructorForTypedArray, 1,0),
|
||||
JS_FN("DecompileArg", intrinsic_DecompileArg, 2,0),
|
||||
JS_FN("RuntimeDefaultLocale", intrinsic_RuntimeDefaultLocale, 0,0),
|
||||
JS_FN("SubstringKernel", intrinsic_SubstringKernel, 3,0),
|
||||
|
|
Загрузка…
Ссылка в новой задаче