Changeset 47271 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Aug 14, 2009, 12:00:12 AM (16 years ago)
Author:
[email protected]
Message:

[ES5] Implement Array.isArray
https://bugs.webkit.org/show_bug.cgi?id=28296

Reviewed by Maciej Stachowiak

Add support for Array.isArray to the Array constructor

Location:
trunk/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r47269 r47271  
    77        * runtime/JSArray.h:
    88        (JSC::MarkStack::drain):
     9
     102009-08-13  Oliver Hunt  <[email protected]>
     11
     12        Reviewed by Maciej Stachowiak.
     13
     14        [ES5] Implement Array.isArray
     15        https://bugs.webkit.org/show_bug.cgi?id=28296
     16
     17        Add support for Array.isArray to the Array constructor
     18
     19        * runtime/ArrayConstructor.cpp:
     20        (JSC::ArrayConstructor::ArrayConstructor):
     21        (JSC::arrayConstructorIsArray):
     22        * runtime/ArrayConstructor.h:
     23        * runtime/CommonIdentifiers.h:
     24        * runtime/JSArray.h:
     25        (JSC::MarkStack::drain):
     26        * runtime/JSGlobalObject.cpp:
     27        (JSC::JSGlobalObject::reset):
    928
    10292009-08-13  Oliver Hunt  <[email protected]>
  • trunk/JavaScriptCore/runtime/ArrayConstructor.cpp

    r47239 r47271  
    3434
    3535ASSERT_CLASS_FITS_IN_CELL(ArrayConstructor);
     36   
     37static JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*, JSObject*, JSValue, const ArgList&);
    3638
    37 ArrayConstructor::ArrayConstructor(ExecState* exec, PassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype)
     39ArrayConstructor::ArrayConstructor(ExecState* exec, PassRefPtr<Structure> structure, ArrayPrototype* arrayPrototype, Structure* prototypeFunctionStructure)
    3840    : InternalFunction(&exec->globalData(), structure, Identifier(exec, arrayPrototype->classInfo()->className))
    3941{
     
    4345    // no. of arguments for constructor
    4446    putDirectWithoutTransition(exec->propertyNames().length, jsNumber(exec, 1), ReadOnly | DontEnum | DontDelete);
     47
     48    // ES5
     49    putDirectFunctionWithoutTransition(exec, new (exec) NativeFunctionWrapper(exec, prototypeFunctionStructure, 1, exec->propertyNames().isArray, arrayConstructorIsArray), DontEnum);
    4550}
    4651
     
    8489}
    8590
     91JSValue JSC_HOST_CALL arrayConstructorIsArray(ExecState*, JSObject*, JSValue, const ArgList& args)
     92{
     93    if (!args.at(0).isObject())
     94        return jsBoolean(false);
     95    return jsBoolean(asObject(args.at(0))->isObject(&JSArray::info));
     96}
     97
    8698} // namespace JSC
  • trunk/JavaScriptCore/runtime/ArrayConstructor.h

    r38440 r47271  
    3030    class ArrayConstructor : public InternalFunction {
    3131    public:
    32         ArrayConstructor(ExecState*, PassRefPtr<Structure>, ArrayPrototype*);
     32        ArrayConstructor(ExecState*, PassRefPtr<Structure>, ArrayPrototype*, Structure*);
    3333
    3434        virtual ConstructType getConstructData(ConstructData&);
  • trunk/JavaScriptCore/runtime/CommonIdentifiers.h

    r46963 r47271  
    4848    macro(index) \
    4949    macro(input) \
     50    macro(isArray) \
    5051    macro(isPrototypeOf) \
    5152    macro(length) \
  • trunk/JavaScriptCore/runtime/JSGlobalObject.cpp

    r47022 r47271  
    259259    JSCell* objectConstructor = new (exec) ObjectConstructor(exec, ObjectConstructor::createStructure(d()->functionPrototype), d()->objectPrototype, d()->prototypeFunctionStructure.get());
    260260    JSCell* functionConstructor = new (exec) FunctionConstructor(exec, FunctionConstructor::createStructure(d()->functionPrototype), d()->functionPrototype);
    261     JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype);
     261    JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, ArrayConstructor::createStructure(d()->functionPrototype), d()->arrayPrototype, d()->prototypeFunctionStructure.get());
    262262    JSCell* stringConstructor = new (exec) StringConstructor(exec, StringConstructor::createStructure(d()->functionPrototype), d()->prototypeFunctionStructure.get(), d()->stringPrototype);
    263263    JSCell* booleanConstructor = new (exec) BooleanConstructor(exec, BooleanConstructor::createStructure(d()->functionPrototype), d()->booleanPrototype);
Note: See TracChangeset for help on using the changeset viewer.