From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/JavaScriptCore/runtime/ArrayConstructor.h | 41 +++++++++++++++++------- 1 file changed, 30 insertions(+), 11 deletions(-) (limited to 'Source/JavaScriptCore/runtime/ArrayConstructor.h') diff --git a/Source/JavaScriptCore/runtime/ArrayConstructor.h b/Source/JavaScriptCore/runtime/ArrayConstructor.h index a6ac76ea4..6d6d45c8e 100644 --- a/Source/JavaScriptCore/runtime/ArrayConstructor.h +++ b/Source/JavaScriptCore/runtime/ArrayConstructor.h @@ -1,6 +1,6 @@ /* * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2007, 2008, 2011 Apple Inc. All rights reserved. + * Copyright (C) 2007-2008, 2011, 2016 Apple Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -18,25 +18,28 @@ * */ -#ifndef ArrayConstructor_h -#define ArrayConstructor_h +#pragma once #include "InternalFunction.h" +#include "ProxyObject.h" +#include "ThrowScope.h" namespace JSC { class ArrayAllocationProfile; class ArrayPrototype; class JSArray; +class GetterSetter; class ArrayConstructor : public InternalFunction { public: typedef InternalFunction Base; + static const unsigned StructureFlags = HasStaticPropertyTable | InternalFunction::StructureFlags; - static ArrayConstructor* create(VM& vm, Structure* structure, ArrayPrototype* arrayPrototype) + static ArrayConstructor* create(VM& vm, JSGlobalObject* globalObject, Structure* structure, ArrayPrototype* arrayPrototype, GetterSetter* speciesSymbol) { ArrayConstructor* constructor = new (NotNull, allocateCell(vm.heap)) ArrayConstructor(vm, structure); - constructor->finishCreation(vm, arrayPrototype); + constructor->finishCreation(vm, globalObject, arrayPrototype, speciesSymbol); return constructor; } @@ -48,19 +51,35 @@ public: } protected: - void finishCreation(VM&, ArrayPrototype*); - static const unsigned StructureFlags = OverridesGetOwnPropertySlot | InternalFunction::StructureFlags; + void finishCreation(VM&, JSGlobalObject*, ArrayPrototype*, GetterSetter* speciesSymbol); private: ArrayConstructor(VM&, Structure*); - static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); static ConstructType getConstructData(JSCell*, ConstructData&); static CallType getCallData(JSCell*, CallData&); }; -JSObject* constructArrayWithSizeQuirk(ExecState*, ArrayAllocationProfile*, JSGlobalObject*, JSValue); +JSValue constructArrayWithSizeQuirk(ExecState*, ArrayAllocationProfile*, JSGlobalObject*, JSValue length, JSValue prototype = JSValue()); -} // namespace JSC +EncodedJSValue JSC_HOST_CALL arrayConstructorPrivateFuncIsArrayConstructor(ExecState*); +EncodedJSValue JSC_HOST_CALL arrayConstructorPrivateFuncIsArraySlow(ExecState*); +bool isArraySlow(ExecState*, ProxyObject* argument); + +// ES6 7.2.2 +// https://tc39.github.io/ecma262/#sec-isarray +inline bool isArray(ExecState* exec, JSValue argumentValue) +{ + if (!argumentValue.isObject()) + return false; + + JSObject* argument = jsCast(argumentValue); + if (argument->type() == ArrayType || argument->type() == DerivedArrayType) + return true; -#endif // ArrayConstructor_h + if (argument->type() != ProxyObjectType) + return false; + return isArraySlow(exec, jsCast(argument)); +} + +} // namespace JSC -- cgit v1.2.1