Changeset 35022 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Jul 5, 2008, 10:26:58 PM (17 years ago)
Author:
[email protected]
Message:

2008-07-05 Sam Weinig <[email protected]>

Reviewed by Cameron Zwarich.

First step in broad cleanup effort.

[ File list elided ]

Location:
trunk/JavaScriptCore
Files:
43 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r35021 r35022  
     12008-07-05  Sam Weinig  <[email protected]>
     2
     3        Reviewed by Cameron Zwarich.
     4
     5        First step in broad cleanup effort.
     6
     7        [ File list elided ]
     8
    192008-07-05  Sam Weinig  <[email protected]>
    210
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r35021 r35022  
    10911091                                BC8F3CCF0DAF17BA00577A80 /* ConstructData.h */,
    10921092                                F692A8540255597D01FF60F7 /* create_hash_table */,
     1093                                BCD203450E17135E002C7E82 /* DateConstructor.cpp */,
     1094                                BCD203460E17135E002C7E82 /* DateConstructor.h */,
    10931095                                BC1166000E1997B1008066DD /* DateInstance.cpp */,
    10941096                                BC1166010E1997B1008066DD /* DateInstance.h */,
    1095                                 BCD203450E17135E002C7E82 /* DateConstructor.cpp */,
    1096                                 BCD203460E17135E002C7E82 /* DateConstructor.h */,
    10971097                                BCD203470E17135E002C7E82 /* DatePrototype.cpp */,
    10981098                                BCD203480E17135E002C7E82 /* DatePrototype.h */,
  • trunk/JavaScriptCore/VM/Machine.cpp

    r35016 r35022  
    27002700    JSActivation* activation = static_cast<JSActivation*>(callFrame[RegisterFile::OptionalCalleeActivation].u.jsValue);
    27012701    if (!activation) {
    2702         CodeBlock* codeBlock = &function->body->generatedCode();
    2703         activation = new (exec) JSActivation(function->body, callFrame + RegisterFile::CallFrameHeaderSize + codeBlock->numLocals);
     2702        CodeBlock* codeBlock = &function->m_body->generatedCode();
     2703        activation = new (exec) JSActivation(function->m_body, callFrame + RegisterFile::CallFrameHeaderSize + codeBlock->numLocals);
    27042704        callFrame[RegisterFile::OptionalCalleeActivation].u.jsValue = activation;
    27052705    }
  • trunk/JavaScriptCore/kjs/Arguments.cpp

    r35018 r35022  
    3636
    3737// ECMA 10.1.8
    38 Arguments::Arguments(ExecState* exec, JSFunction* func, const ArgList& args, JSActivation* act)
     38Arguments::Arguments(ExecState* exec, JSFunction* function, const ArgList& args, JSActivation* activation)
    3939    : JSObject(exec->lexicalGlobalObject()->objectPrototype())
    40     , _activationObject(act)
    41     , indexToNameMap(func, args)
     40    , m_activationObject(activation)
     41    , m_indexToNameMap(function, args)
    4242{
    43     putDirect(exec->propertyNames().callee, func, DontEnum);
     43    putDirect(exec->propertyNames().callee, function, DontEnum);
    4444    putDirect(exec, exec->propertyNames().length, args.size(), DontEnum);
    4545 
     
    4848    for (ArgList::const_iterator it = args.begin(); it != end; ++it, ++i) {
    4949        Identifier name = Identifier::from(exec, i);
    50         if (!indexToNameMap.isMapped(name))
     50        if (!m_indexToNameMap.isMapped(name))
    5151            putDirect(name, *it, DontEnum);
    5252    }
     
    5555void Arguments::mark()
    5656{
    57   JSObject::mark();
    58   if (_activationObject && !_activationObject->marked())
    59     _activationObject->mark();
     57    JSObject::mark();
     58    if (m_activationObject && !m_activationObject->marked())
     59        m_activationObject->mark();
    6060}
    6161
    6262JSValue* Arguments::mappedIndexGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
    6363{
    64   Arguments* thisObj = static_cast<Arguments*>(slot.slotBase());
    65   return thisObj->_activationObject->get(exec, thisObj->indexToNameMap[propertyName]);
     64      Arguments* thisObj = static_cast<Arguments*>(slot.slotBase());
     65      return thisObj->m_activationObject->get(exec, thisObj->m_indexToNameMap[propertyName]);
    6666}
    6767
    6868bool Arguments::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
    6969{
    70   if (indexToNameMap.isMapped(propertyName)) {
    71     slot.setCustom(this, mappedIndexGetter);
    72     return true;
    73   }
     70    if (m_indexToNameMap.isMapped(propertyName)) {
     71        slot.setCustom(this, mappedIndexGetter);
     72        return true;
     73    }
    7474
    75   return JSObject::getOwnPropertySlot(exec, propertyName, slot);
     75    return JSObject::getOwnPropertySlot(exec, propertyName, slot);
    7676}
    7777
    7878void Arguments::put(ExecState* exec, const Identifier& propertyName, JSValue* value)
    7979{
    80     if (indexToNameMap.isMapped(propertyName))
    81         _activationObject->put(exec, indexToNameMap[propertyName], value);
     80    if (m_indexToNameMap.isMapped(propertyName))
     81        m_activationObject->put(exec, m_indexToNameMap[propertyName], value);
    8282    else
    8383        JSObject::put(exec, propertyName, value);
     
    8686bool Arguments::deleteProperty(ExecState* exec, const Identifier& propertyName)
    8787{
    88   if (indexToNameMap.isMapped(propertyName)) {
    89     indexToNameMap.unMap(exec, propertyName);
    90     return true;
    91   } else {
     88    if (m_indexToNameMap.isMapped(propertyName)) {
     89        m_indexToNameMap.unMap(exec, propertyName);
     90        return true;
     91    }
     92
    9293    return JSObject::deleteProperty(exec, propertyName);
    93   }
    9494}
    9595
  • trunk/JavaScriptCore/kjs/Arguments.h

    r35016 r35022  
    3030namespace KJS {
    3131
    32   class JSActivation;
     32    class JSActivation;
    3333
    34   class Arguments : public JSObject {
    35   public:
    36     Arguments(ExecState*, JSFunction* func, const ArgList& args, JSActivation* act);
    37     virtual void mark();
    38     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    39     virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    40     virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    41     virtual const ClassInfo* classInfo() const { return &info; }
    42     static const ClassInfo info;
    43   private:
    44     static JSValue* mappedIndexGetter(ExecState*, const Identifier&, const PropertySlot& slot);
     34    class Arguments : public JSObject {
     35    public:
     36        Arguments(ExecState*, JSFunction*, const ArgList&, JSActivation*);
    4537
    46     JSActivation* _activationObject;
    47     mutable IndexToNameMap indexToNameMap;
    48   };
     38        virtual void mark();
     39
     40        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     41        virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
     42        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     43
     44        virtual const ClassInfo* classInfo() const { return &info; }
     45        static const ClassInfo info;
     46
     47    private:
     48        static JSValue* mappedIndexGetter(ExecState*, const Identifier&, const PropertySlot& slot);
     49
     50        JSActivation* m_activationObject;
     51        mutable IndexToNameMap m_indexToNameMap;
     52    };
    4953
    5054} // namespace KJS
  • trunk/JavaScriptCore/kjs/ArrayConstructor.cpp

    r34876 r35022  
    3232namespace KJS {
    3333
    34 ArrayConstructor::ArrayConstructor(ExecState* exec, FunctionPrototype* funcProto, ArrayPrototype* arrayProto)
    35     : InternalFunction(funcProto, Identifier(exec, arrayProto->classInfo()->className))
     34ArrayConstructor::ArrayConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ArrayPrototype* arrayPrototype)
     35    : InternalFunction(functionPrototype, Identifier(exec, arrayPrototype->classInfo()->className))
    3636{
    3737    // ECMA 15.4.3.1 Array.prototype
    38     putDirect(exec->propertyNames().prototype, arrayProto, DontEnum|DontDelete|ReadOnly);
     38    putDirect(exec->propertyNames().prototype, arrayPrototype, DontEnum | DontDelete | ReadOnly);
    3939
    4040    // no. of arguments for constructor
     
    8181}
    8282
    83 }
     83} // namespace KJS
  • trunk/JavaScriptCore/kjs/ArrayConstructor.h

    r34901 r35022  
    2626namespace KJS {
    2727
    28   class ArrayPrototype;
    29   class FunctionPrototype;
     28    class ArrayPrototype;
     29    class FunctionPrototype;
    3030
    31   class ArrayConstructor : public InternalFunction {
    32   public:
    33     ArrayConstructor(ExecState*, FunctionPrototype*, ArrayPrototype*);
    34     virtual ConstructType getConstructData(ConstructData&);
    35     virtual CallType getCallData(CallData&);
    36   };
     31    class ArrayConstructor : public InternalFunction {
     32    public:
     33        ArrayConstructor(ExecState*, FunctionPrototype*, ArrayPrototype*);
     34
     35        virtual ConstructType getConstructData(ConstructData&);
     36        virtual CallType getCallData(CallData&);
     37    };
    3738
    3839} // namespace KJS
  • trunk/JavaScriptCore/kjs/ArrayPrototype.cpp

    r34876 r35022  
    2929#include "lookup.h"
    3030#include "operations.h"
     31#include <algorithm>
    3132#include <wtf/Assertions.h>
    3233#include <wtf/HashSet.h>
    33 #include <algorithm> // for std::min
    3434
    3535namespace KJS {
     
    9090
    9191// ECMA 15.4.4
    92 ArrayPrototype::ArrayPrototype(ExecState*, ObjectPrototype* objProto)
    93     : JSArray(objProto, 0)
     92ArrayPrototype::ArrayPrototype(ExecState*, ObjectPrototype* objectPrototype)
     93    : JSArray(objectPrototype, 0)
    9494{
    9595}
     
    775775}
    776776
    777 }
     777} // namespace KJS
  • trunk/JavaScriptCore/kjs/ArrayPrototype.h

    r34843 r35022  
    2727namespace KJS {
    2828
    29  class ArrayPrototype : public JSArray {
    30   public:
    31     ArrayPrototype(ExecState*, ObjectPrototype*);
     29    class ArrayPrototype : public JSArray {
     30    public:
     31        ArrayPrototype(ExecState*, ObjectPrototype*);
    3232
    33     bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    34     virtual const ClassInfo* classInfo() const { return &info; }
    35     static const ClassInfo info;
    36   };
     33        bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     34
     35        virtual const ClassInfo* classInfo() const { return &info; }
     36        static const ClassInfo info;
     37    };
    3738
    3839} // namespace KJS
  • trunk/JavaScriptCore/kjs/BooleanConstructor.h

    r34901 r35022  
    2929    class FunctionPrototype;
    3030
    31     /**
    32      * @internal
    33      *
    34      * The initial value of the the global variable's "Boolean" property
    35      */
    3631    class BooleanConstructor : public InternalFunction {
    3732    public:
    3833        BooleanConstructor(ExecState*, FunctionPrototype*, BooleanPrototype*);
     34
    3935    private:
    4036        virtual ConstructType getConstructData(ConstructData&);
  • trunk/JavaScriptCore/kjs/BooleanObject.cpp

    r34843 r35022  
    2626const ClassInfo BooleanObject::info = { "Boolean", 0, 0, 0 };
    2727
    28 BooleanObject::BooleanObject(JSObject* proto)
    29     : JSWrapperObject(proto)
     28BooleanObject::BooleanObject(JSObject* prototype)
     29    : JSWrapperObject(prototype)
    3030{
    3131}
  • trunk/JavaScriptCore/kjs/BooleanObject.h

    r34843 r35022  
    2828    class BooleanObject : public JSWrapperObject {
    2929    public:
    30         BooleanObject(JSObject* proto);
     30        BooleanObject(JSObject* prototype);
    3131
    3232        virtual const ClassInfo* classInfo() const { return &info; }
  • trunk/JavaScriptCore/kjs/BooleanPrototype.h

    r34855 r35022  
    2929    class ObjectPrototype;
    3030
    31     /**
    32      * @internal
    33      *
    34      * The initial value of Boolean.prototype (and thus all objects created
    35      * with the Boolean constructor
    36      */
    3731    class BooleanPrototype : public BooleanObject {
    3832    public:
  • trunk/JavaScriptCore/kjs/ClassInfo.h

    r35007 r35022  
    2828namespace KJS {
    2929
    30   struct HashEntry;
    31   struct HashTable;
     30    struct HashEntry;
     31    struct HashTable;
    3232
    33   /**
    34    * Class Information
    35    */
    36   struct ClassInfo {
    37     /**
    38      * A string denoting the class name. Example: "Window".
    39      */
    40     const char* className;
    41     /**
    42      * Pointer to the class information of the base class.
    43      * 0L if there is none.
    44      */
    45     const ClassInfo* parentClass;
    46     /**
    47      * Static hash-table of properties.
    48      * For classes that can be used from multiple threads, it is accessed via a getter function that would typically return a pointer to thread-specific value.
    49      */
    50     const HashTable* propHashTable(ExecState* exec) const
    51     {
    52         if (classPropHashTableGetterFunction)
    53             return classPropHashTableGetterFunction(exec);
    54         return staticPropHashTable;
    55     }
     33    struct ClassInfo {
     34        /**
     35         * A string denoting the class name. Example: "Window".
     36         */
     37        const char* className;
    5638
    57     const HashTable* staticPropHashTable;
    58     typedef const HashTable* (*ClassPropHashTableGetterFunction)(ExecState*);
    59     const ClassPropHashTableGetterFunction classPropHashTableGetterFunction;
    60   };
     39        /**
     40         * Pointer to the class information of the base class.
     41         * 0L if there is none.
     42         */
     43        const ClassInfo* parentClass;
     44        /**
     45         * Static hash-table of properties.
     46         * For classes that can be used from multiple threads, it is accessed via a getter function that would typically return a pointer to thread-specific value.
     47         */
     48        const HashTable* propHashTable(ExecState* exec) const
     49        {
     50            if (classPropHashTableGetterFunction)
     51                return classPropHashTableGetterFunction(exec);
     52            return staticPropHashTable;
     53        }
     54
     55        const HashTable* staticPropHashTable;
     56        typedef const HashTable* (*ClassPropHashTableGetterFunction)(ExecState*);
     57        const ClassPropHashTableGetterFunction classPropHashTableGetterFunction;
     58    };
    6159
    6260} // namespace KJS
  • trunk/JavaScriptCore/kjs/CollectorHeapIntrospector.h

    r34824 r35022  
    3030#define CollectorHeapIntrospector_h
    3131
     32#include "Assertions.h"
    3233#include <malloc/malloc.h>
    33 #include "Assertions.h"
    3434
    3535namespace KJS {
    3636
    37 struct CollectorHeap;
    38    
    39 class CollectorHeapIntrospector {
    40 public:
    41     static void init(CollectorHeap*, CollectorHeap*);
    42     static kern_return_t enumerate(task_t, void* context, unsigned typeMask, vm_address_t zoneAddress, memory_reader_t, vm_range_recorder_t);
    43     static size_t goodSize(malloc_zone_t*, size_t size) { return size; }
    44     static boolean_t check(malloc_zone_t*) { return true; }
    45     static void  print(malloc_zone_t*, boolean_t) { }
    46     static void log(malloc_zone_t*, void*) { }
    47     static void forceLock(malloc_zone_t*) { }
    48     static void forceUnlock(malloc_zone_t*) { }
    49     static void statistics(malloc_zone_t*, malloc_statistics_t*);
     37    struct CollectorHeap;
     38       
     39    class CollectorHeapIntrospector {
     40    public:
     41        static void init(CollectorHeap*, CollectorHeap*);
     42        static kern_return_t enumerate(task_t, void* context, unsigned typeMask, vm_address_t zoneAddress, memory_reader_t, vm_range_recorder_t);
     43        static size_t goodSize(malloc_zone_t*, size_t size) { return size; }
     44        static boolean_t check(malloc_zone_t*) { return true; }
     45        static void  print(malloc_zone_t*, boolean_t) { }
     46        static void log(malloc_zone_t*, void*) { }
     47        static void forceLock(malloc_zone_t*) { }
     48        static void forceUnlock(malloc_zone_t*) { }
     49        static void statistics(malloc_zone_t*, malloc_statistics_t*);
    5050
    51 private:
    52     CollectorHeapIntrospector(CollectorHeap*, CollectorHeap*);
    53     static size_t size(malloc_zone_t*, const void*) { return 0; }
    54     static void* zoneMalloc(malloc_zone_t*, size_t) { LOG_ERROR("malloc is not supported"); return 0; }
    55     static void* zoneCalloc(malloc_zone_t*, size_t, size_t) { LOG_ERROR("calloc is not supported"); return 0; }
    56     static void* zoneRealloc(malloc_zone_t*, void*, size_t) { LOG_ERROR("realloc is not supported"); return 0; }
    57     static void* zoneValloc(malloc_zone_t*, size_t) { LOG_ERROR("valloc is not supported"); return 0; }
    58     static void zoneDestroy(malloc_zone_t*) { }
     51    private:
     52        CollectorHeapIntrospector(CollectorHeap*, CollectorHeap*);
    5953
    60     static void zoneFree(malloc_zone_t*, void* ptr)
    61     {
    62         // Due to <rdar://problem/5671357> zoneFree may be called by the system free even if the pointer
    63         // is not in this zone.  When this happens, the pointer being freed was not allocated by any
    64         // zone so we need to print a useful error for the application developer.
    65         malloc_printf("*** error for object %p: pointer being freed was not allocated\n", ptr);
    66     }
     54        static size_t size(malloc_zone_t*, const void*) { return 0; }
     55        static void* zoneMalloc(malloc_zone_t*, size_t) { LOG_ERROR("malloc is not supported"); return 0; }
     56        static void* zoneCalloc(malloc_zone_t*, size_t, size_t) { LOG_ERROR("calloc is not supported"); return 0; }
     57        static void* zoneRealloc(malloc_zone_t*, void*, size_t) { LOG_ERROR("realloc is not supported"); return 0; }
     58        static void* zoneValloc(malloc_zone_t*, size_t) { LOG_ERROR("valloc is not supported"); return 0; }
     59        static void zoneDestroy(malloc_zone_t*) { }
    6760
    68     malloc_zone_t m_zone;
    69     CollectorHeap* m_primaryHeap;
    70     CollectorHeap* m_numberHeap;
    71 };
     61        static void zoneFree(malloc_zone_t*, void* ptr)
     62        {
     63            // Due to <rdar://problem/5671357> zoneFree may be called by the system free even if the pointer
     64            // is not in this zone.  When this happens, the pointer being freed was not allocated by any
     65            // zone so we need to print a useful error for the application developer.
     66            malloc_printf("*** error for object %p: pointer being freed was not allocated\n", ptr);
     67        }
    7268
    73 }
     69        malloc_zone_t m_zone;
     70        CollectorHeap* m_primaryHeap;
     71        CollectorHeap* m_numberHeap;
     72    };
     73
     74} // namespace KJS
    7475
    7576#endif // CollectorHeapIntrospector_h
  • trunk/JavaScriptCore/kjs/CommonIdentifiers.h

    r34843 r35022  
    1919 */
    2020
    21 #ifndef KJS_COMMON_IDENTIFIERS_H
    22 #define KJS_COMMON_IDENTIFIERS_H
     21#ifndef CommonIdentifiers_h
     22#define CommonIdentifiers_h
    2323
    2424#include "identifier.h"
     
    8282#undef KJS_IDENTIFIER_DECLARE_PROPERTY_NAME_GLOBAL
    8383    };
     84
    8485} // namespace KJS
    8586
    86 #endif // KJS_COMMON_IDENTIFIERS_H
    87 
     87#endif // CommonIdentifiers_h
  • trunk/JavaScriptCore/kjs/DateConstructor.cpp

    r35018 r35022  
    5050static JSValue* dateUTC(ExecState*, JSObject*, JSValue*, const ArgList&);
    5151
    52 DateConstructor::DateConstructor(ExecState* exec, FunctionPrototype* funcProto, DatePrototype* dateProto)
    53   : InternalFunction(funcProto, Identifier(exec, dateProto->classInfo()->className))
     52DateConstructor::DateConstructor(ExecState* exec, FunctionPrototype* functionPrototype, DatePrototype* datePrototype)
     53    : InternalFunction(functionPrototype, Identifier(exec, datePrototype->classInfo()->className))
    5454{
    55   putDirect(exec->propertyNames().prototype, dateProto, DontEnum|DontDelete|ReadOnly);
    56   putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 1, exec->propertyNames().parse, dateParse), DontEnum);
    57   putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
    58   putDirectFunction(new (exec) PrototypeFunction(exec, funcProto, 0, exec->propertyNames().now, dateNow), DontEnum);
    59   putDirect(exec, exec->propertyNames().length, 7, ReadOnly | DontEnum | DontDelete);
     55      putDirect(exec->propertyNames().prototype, datePrototype, DontEnum|DontDelete|ReadOnly);
     56
     57      putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 1, exec->propertyNames().parse, dateParse), DontEnum);
     58      putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 7, exec->propertyNames().UTC, dateUTC), DontEnum);
     59      putDirectFunction(new (exec) PrototypeFunction(exec, functionPrototype, 0, exec->propertyNames().now, dateNow), DontEnum);
     60
     61      putDirect(exec, exec->propertyNames().length, 7, ReadOnly | DontEnum | DontDelete);
    6062}
    6163
     
    6365static JSObject* constructDate(ExecState* exec, JSObject*, const ArgList& args)
    6466{
    65   int numArgs = args.size();
     67    int numArgs = args.size();
    6668
    67   double value;
     69    double value;
    6870
    69   if (numArgs == 0) { // new Date() ECMA 15.9.3.3
    70     value = getCurrentUTCTime();
    71   } else if (numArgs == 1) {
    72     if (args[0]->isObject(&DateInstance::info))
    73       value = static_cast<DateInstance*>(args[0])->internalNumber();
    74     else {
    75       JSValue* primitive = args[0]->toPrimitive(exec);
    76       if (primitive->isString())
    77         value = parseDate(primitive->getString());
    78       else
    79         value = primitive->toNumber(exec);
     71    if (numArgs == 0) // new Date() ECMA 15.9.3.3
     72        value = getCurrentUTCTime();
     73    else if (numArgs == 1) {
     74        if (args[0]->isObject(&DateInstance::info))
     75            value = static_cast<DateInstance*>(args[0])->internalNumber();
     76        else {
     77            JSValue* primitive = args[0]->toPrimitive(exec);
     78            if (primitive->isString())
     79                value = parseDate(primitive->getString());
     80            else
     81                value = primitive->toNumber(exec);
     82        }
     83    } else {
     84        if (isnan(args[0]->toNumber(exec))
     85                || isnan(args[1]->toNumber(exec))
     86                || (numArgs >= 3 && isnan(args[2]->toNumber(exec)))
     87                || (numArgs >= 4 && isnan(args[3]->toNumber(exec)))
     88                || (numArgs >= 5 && isnan(args[4]->toNumber(exec)))
     89                || (numArgs >= 6 && isnan(args[5]->toNumber(exec)))
     90                || (numArgs >= 7 && isnan(args[6]->toNumber(exec))))
     91            value = NaN;
     92        else {
     93          GregorianDateTime t;
     94          int year = args[0]->toInt32(exec);
     95          t.year = (year >= 0 && year <= 99) ? year : year - 1900;
     96          t.month = args[1]->toInt32(exec);
     97          t.monthDay = (numArgs >= 3) ? args[2]->toInt32(exec) : 1;
     98          t.hour = args[3]->toInt32(exec);
     99          t.minute = args[4]->toInt32(exec);
     100          t.second = args[5]->toInt32(exec);
     101          t.isDST = -1;
     102          double ms = (numArgs >= 7) ? args[6]->toNumber(exec) : 0;
     103          value = gregorianDateTimeToMS(t, ms, false);
     104        }
    80105    }
    81   } else {
    82     if (isnan(args[0]->toNumber(exec))
    83         || isnan(args[1]->toNumber(exec))
    84         || (numArgs >= 3 && isnan(args[2]->toNumber(exec)))
    85         || (numArgs >= 4 && isnan(args[3]->toNumber(exec)))
    86         || (numArgs >= 5 && isnan(args[4]->toNumber(exec)))
    87         || (numArgs >= 6 && isnan(args[5]->toNumber(exec)))
    88         || (numArgs >= 7 && isnan(args[6]->toNumber(exec)))) {
    89       value = NaN;
    90     } else {
    91       GregorianDateTime t;
    92       int year = args[0]->toInt32(exec);
    93       t.year = (year >= 0 && year <= 99) ? year : year - 1900;
    94       t.month = args[1]->toInt32(exec);
    95       t.monthDay = (numArgs >= 3) ? args[2]->toInt32(exec) : 1;
    96       t.hour = args[3]->toInt32(exec);
    97       t.minute = args[4]->toInt32(exec);
    98       t.second = args[5]->toInt32(exec);
    99       t.isDST = -1;
    100       double ms = (numArgs >= 7) ? args[6]->toNumber(exec) : 0;
    101       value = gregorianDateTimeToMS(t, ms, false);
    102     }
    103   }
    104  
    105   DateInstance* ret = new (exec) DateInstance(exec->lexicalGlobalObject()->datePrototype());
    106   ret->setInternalValue(jsNumber(exec, timeClip(value)));
    107   return ret;
     106
     107    DateInstance* ret = new (exec) DateInstance(exec->lexicalGlobalObject()->datePrototype());
     108    ret->setInternalValue(jsNumber(exec, timeClip(value)));
     109    return ret;
    108110}
    109111
     
    149151            || (n >= 5 && isnan(args[4]->toNumber(exec)))
    150152            || (n >= 6 && isnan(args[5]->toNumber(exec)))
    151             || (n >= 7 && isnan(args[6]->toNumber(exec)))) {
     153            || (n >= 7 && isnan(args[6]->toNumber(exec))))
    152154        return jsNaN(exec);
    153     }
    154155
    155156    GregorianDateTime t;
  • trunk/JavaScriptCore/kjs/DateConstructor.h

    r34901 r35022  
    2929    class FunctionPrototype;
    3030
    31     /**
    32      * @internal
    33      *
    34      * The initial value of the the global variable's "Date" property
    35      */
    3631    class DateConstructor : public InternalFunction {
    3732    public:
    3833        DateConstructor(ExecState*, FunctionPrototype*, DatePrototype*);
     34
    3935    private:
    4036        virtual ConstructType getConstructData(ConstructData&);
  • trunk/JavaScriptCore/kjs/DateInstance.cpp

    r34897 r35022  
    3838const ClassInfo DateInstance::info = {"Date", 0, 0, 0};
    3939
    40 DateInstance::DateInstance(JSObject *proto)
    41   : JSWrapperObject(proto)
    42   , m_cache(0)
     40DateInstance::DateInstance(JSObject* prototype)
     41    : JSWrapperObject(prototype)
     42    , m_cache(0)
    4343{
    4444}
     
    7272}
    7373
    74 bool DateInstance::getTime(GregorianDateTime &t, int &offset) const
     74bool DateInstance::getTime(GregorianDateTime& t, int& offset) const
    7575{
    7676    double milli = internalNumber();
     
    8383}
    8484
    85 bool DateInstance::getUTCTime(GregorianDateTime &t) const
     85bool DateInstance::getUTCTime(GregorianDateTime& t) const
    8686{
    8787    double milli = internalNumber();
     
    9393}
    9494
    95 bool DateInstance::getTime(double &milli, int &offset) const
     95bool DateInstance::getTime(double& milli, int& offset) const
    9696{
    9797    milli = internalNumber();
     
    105105}
    106106
    107 bool DateInstance::getUTCTime(double &milli) const
     107bool DateInstance::getUTCTime(double& milli) const
    108108{
    109109    milli = internalNumber();
  • trunk/JavaScriptCore/kjs/DateInstance.h

    r34897 r35022  
    4141        bool getTime(double& milliseconds, int& offset) const;
    4242        bool getUTCTime(double& milliseconds) const;
    43        
     43
    4444        static const ClassInfo info;
    4545
  • trunk/JavaScriptCore/kjs/DatePrototype.cpp

    r34897 r35022  
    123123}
    124124
    125 static UString formatLocaleDate(ExecState *exec, double time, bool includeDate, bool includeTime, const ArgList& args)
     125static UString formatLocaleDate(ExecState* exec, double time, bool includeDate, bool includeTime, const ArgList& args)
    126126{
    127127    CFDateFormatterStyle dateStyle = (includeDate ? kCFDateFormatterLongStyle : kCFDateFormatterNoStyle);
     
    138138        dateStyle = styleFromArgString(arg0String, dateStyle);
    139139        timeStyle = styleFromArgString(args[1]->toString(exec), timeStyle);
    140     } else if (includeDate && !args[0]->isUndefined()) {
     140    } else if (includeDate && !args[0]->isUndefined())
    141141        dateStyle = styleFromArgString(arg0String, dateStyle);
    142     } else if (includeTime && !args[0]->isUndefined()) {
     142    else if (includeTime && !args[0]->isUndefined())
    143143        timeStyle = styleFromArgString(arg0String, timeStyle);
    144     }
    145144
    146145    CFLocaleRef locale = CFLocaleCopyCurrent();
     
    185184    int year = gdt.year + 1900;
    186185    bool yearNeedsOffset = year < 1900 || year > 2038;
    187     if (yearNeedsOffset) {
     186    if (yearNeedsOffset)
    188187        localTM.tm_year = equivalentYearForDST(year) - 1900;
    189      }
    190188 
    191189    // Do the formatting
    192     const int bufsize=128;
     190    const int bufsize = 128;
    193191    char timebuffer[bufsize];
    194192    size_t ret = strftime(timebuffer, bufsize, formatStrings[format], &localTM);
    195193 
    196     if ( ret == 0 )
     194    if (ret == 0)
    197195        return jsString(exec, "");
    198196 
     
    292290    return ok;
    293291}
    294 
    295 
    296 
    297 
    298292
    299293const ClassInfo DatePrototype::info = {"Date", &DateInstance::info, 0, ExecState::dateTable};
     
    350344// ECMA 15.9.4
    351345
    352 DatePrototype::DatePrototype(ExecState* exec, ObjectPrototype* objectProto)
    353     : DateInstance(objectProto)
     346DatePrototype::DatePrototype(ExecState* exec, ObjectPrototype* objectPrototype)
     347    : DateInstance(objectPrototype)
    354348{
    355349    setInternalValue(jsNaN(exec));
  • trunk/JavaScriptCore/kjs/DatePrototype.h

    r34897 r35022  
    2828    class ObjectPrototype;
    2929
    30     /**
    31      * @internal
    32      *
    33      * The initial value of Date.prototype (and thus all objects created
    34      * with the Date constructor
    35      */
    3630    class DatePrototype : public DateInstance {
    3731    public:
    38         DatePrototype(ExecState *, ObjectPrototype *);
    39         virtual bool getOwnPropertySlot(ExecState *, const Identifier &, PropertySlot&);
    40         virtual const ClassInfo *classInfo() const { return &info; }
     32        DatePrototype(ExecState*, ObjectPrototype*);
     33
     34        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     35
     36        virtual const ClassInfo* classInfo() const { return &info; }
    4137        static const ClassInfo info;
    4238    };
  • trunk/JavaScriptCore/kjs/Error.cpp

    r35008 r35022  
    3434namespace KJS {
    3535
    36 JSObject* Error::create(ExecState* exec, ErrorType errtype, const UString& message,
    37     int lineno, int sourceId, const UString& sourceURL)
     36JSObject* Error::create(ExecState* exec, ErrorType type, const UString& message, int lineNumber, int sourceId, const UString& sourceURL)
    3837{
    39   JSObject* cons;
    40   const char* name;
    41   switch (errtype) {
    42   case EvalError:
    43     cons = exec->lexicalGlobalObject()->evalErrorConstructor();
    44     name = "Evaluation error";
    45     break;
    46   case RangeError:
    47     cons = exec->lexicalGlobalObject()->rangeErrorConstructor();
    48     name = "Range error";
    49     break;
    50   case ReferenceError:
    51     cons = exec->lexicalGlobalObject()->referenceErrorConstructor();
    52     name = "Reference error";
    53     break;
    54   case SyntaxError:
    55     cons = exec->lexicalGlobalObject()->syntaxErrorConstructor();
    56     name = "Syntax error";
    57     break;
    58   case TypeError:
    59     cons = exec->lexicalGlobalObject()->typeErrorConstructor();
    60     name = "Type error";
    61     break;
    62   case URIError:
    63     cons = exec->lexicalGlobalObject()->URIErrorConstructor();
    64     name = "URI error";
    65     break;
    66   default:
    67     cons = exec->lexicalGlobalObject()->errorConstructor();
    68     name = "Error";
    69     break;
    70   }
     38    JSObject* constructor;
     39    const char* name;
     40    switch (type) {
     41        case EvalError:
     42            constructor = exec->lexicalGlobalObject()->evalErrorConstructor();
     43            name = "Evaluation error";
     44            break;
     45        case RangeError:
     46            constructor = exec->lexicalGlobalObject()->rangeErrorConstructor();
     47            name = "Range error";
     48            break;
     49        case ReferenceError:
     50            constructor = exec->lexicalGlobalObject()->referenceErrorConstructor();
     51            name = "Reference error";
     52            break;
     53        case SyntaxError:
     54            constructor = exec->lexicalGlobalObject()->syntaxErrorConstructor();
     55            name = "Syntax error";
     56            break;
     57        case TypeError:
     58            constructor = exec->lexicalGlobalObject()->typeErrorConstructor();
     59            name = "Type error";
     60            break;
     61        case URIError:
     62            constructor = exec->lexicalGlobalObject()->URIErrorConstructor();
     63            name = "URI error";
     64            break;
     65        default:
     66            constructor = exec->lexicalGlobalObject()->errorConstructor();
     67            name = "Error";
     68            break;
     69    }
    7170
    72   ArgList args;
    73   if (message.isEmpty())
    74     args.append(jsString(exec, name));
    75   else
    76     args.append(jsString(exec, message));
    77   ConstructData constructData;
    78   ConstructType constructType = cons->getConstructData(constructData);
    79   JSObject* err = construct(exec, cons, constructType, constructData, args);
     71    ArgList args;
     72    if (message.isEmpty())
     73        args.append(jsString(exec, name));
     74    else
     75        args.append(jsString(exec, message));
     76    ConstructData constructData;
     77    ConstructType constructType = constructor->getConstructData(constructData);
     78    JSObject* error = construct(exec, constructor, constructType, constructData, args);
    8079
    81   if (lineno != -1)
    82     err->put(exec, Identifier(exec, "line"), jsNumber(exec, lineno));
    83   if (sourceId != -1)
    84     err->put(exec, Identifier(exec, "sourceId"), jsNumber(exec, sourceId));
     80    if (lineNumber != -1)
     81        error->put(exec, Identifier(exec, "line"), jsNumber(exec, lineNumber));
     82    if (sourceId != -1)
     83        error->put(exec, Identifier(exec, "sourceId"), jsNumber(exec, sourceId));
     84    if (!sourceURL.isNull())
     85        error->put(exec, Identifier(exec, "sourceURL"), jsString(exec, sourceURL));
    8586
    86   if(!sourceURL.isNull())
    87     err->put(exec, Identifier(exec, "sourceURL"), jsString(exec, sourceURL));
    88  
    89   return err;
     87    return error;
    9088}
    9189
    92 JSObject *Error::create(ExecState *exec, ErrorType type, const char *message)
     90JSObject* Error::create(ExecState* exec, ErrorType type, const char* message)
    9391{
    9492    return create(exec, type, message, -1, -1, NULL);
    9593}
    9694
    97 JSObject *throwError(ExecState *exec, ErrorType type)
     95JSObject* throwError(ExecState* exec, ErrorType type)
    9896{
    99     JSObject *error = Error::create(exec, type, UString(), -1, -1, NULL);
     97    JSObject* error = Error::create(exec, type, UString(), -1, -1, NULL);
    10098    exec->setException(error);
    10199    return error;
    102100}
    103101
    104 JSObject *throwError(ExecState *exec, ErrorType type, const UString &message)
     102JSObject* throwError(ExecState* exec, ErrorType type, const UString& message)
    105103{
    106     JSObject *error = Error::create(exec, type, message, -1, -1, NULL);
     104    JSObject* error = Error::create(exec, type, message, -1, -1, NULL);
    107105    exec->setException(error);
    108106    return error;
    109107}
    110108
    111 JSObject *throwError(ExecState *exec, ErrorType type, const char *message)
     109JSObject* throwError(ExecState* exec, ErrorType type, const char* message)
    112110{
    113     JSObject *error = Error::create(exec, type, message, -1, -1, NULL);
     111    JSObject* error = Error::create(exec, type, message, -1, -1, NULL);
    114112    exec->setException(error);
    115113    return error;
    116114}
    117115
    118 JSObject *throwError(ExecState *exec, ErrorType type, const UString &message, int line, int sourceId, const UString &sourceURL)
     116JSObject* throwError(ExecState* exec, ErrorType type, const UString& message, int line, int sourceId, const UString& sourceURL)
    119117{
    120     JSObject *error = Error::create(exec, type, message, line, sourceId, sourceURL);
     118    JSObject* error = Error::create(exec, type, message, line, sourceId, sourceURL);
    121119    exec->setException(error);
    122120    return error;
  • trunk/JavaScriptCore/kjs/Error.h

    r35007 r35022  
    2626namespace KJS {
    2727
    28   class ExecState;
    29   class JSObject;
    30   class UString;
     28    class ExecState;
     29    class JSObject;
     30    class UString;
    3131
    32   /**
    33    * Types of Native Errors available. For custom errors, GeneralError
    34    * should be used.
    35    */
    36   enum ErrorType { GeneralError   = 0,
    37                    EvalError      = 1,
    38                    RangeError     = 2,
    39                    ReferenceError = 3,
    40                    SyntaxError    = 4,
    41                    TypeError      = 5,
    42                    URIError       = 6};
     32    /**
     33     * Types of Native Errors available. For custom errors, GeneralError
     34     * should be used.
     35     */
     36    enum ErrorType {
     37        GeneralError   = 0,
     38        EvalError      = 1,
     39        RangeError     = 2,
     40        ReferenceError = 3,
     41        SyntaxError    = 4,
     42        TypeError      = 5,
     43        URIError       = 6
     44    };
    4345
    44   /**
    45    * @short Factory methods for error objects.
    46    */
    47   class Error {
    48   public:
    49     /**
    50      * Factory method for error objects.
    51      *
    52      * @param exec The current execution state
    53      * @param errtype Type of error.
    54      * @param message Optional error message.
    55      * @param lineNumber Optional line number.
    56      * @param sourceId Optional source id.
    57      * @param sourceURL Optional source URL.
    58      */
    59     static JSObject *create(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString &sourceURL);
    60     static JSObject *create(ExecState *, ErrorType, const char *message);
    61   };
     46    class Error {
     47    public:
     48        static JSObject* create(ExecState*, ErrorType, const UString& message, int lineNumber, int sourceId, const UString& sourceURL);
     49        static JSObject* create(ExecState*, ErrorType, const char* message);
     50    };
    6251
    63 JSObject *throwError(ExecState *, ErrorType, const UString &message, int lineNumber, int sourceId, const UString &sourceURL);
    64 JSObject *throwError(ExecState *, ErrorType, const UString &message);
    65 JSObject *throwError(ExecState *, ErrorType, const char *message);
    66 JSObject *throwError(ExecState *, ErrorType);
     52    JSObject* throwError(ExecState*, ErrorType, const UString& message, int lineNumber, int sourceId, const UString& sourceURL);
     53    JSObject* throwError(ExecState*, ErrorType, const UString& message);
     54    JSObject* throwError(ExecState*, ErrorType, const char* message);
     55    JSObject* throwError(ExecState*, ErrorType);
    6756
    6857} // namespace KJS
  • trunk/JavaScriptCore/kjs/ErrorConstructor.cpp

    r34876 r35022  
    3030namespace KJS {
    3131
    32 ErrorConstructor::ErrorConstructor(ExecState* exec, FunctionPrototype* funcProto, ErrorPrototype* errorProto)
    33     : InternalFunction(funcProto, Identifier(exec, errorProto->classInfo()->className))
     32ErrorConstructor::ErrorConstructor(ExecState* exec, FunctionPrototype* functionPrototype, ErrorPrototype* errorPrototype)
     33    : InternalFunction(functionPrototype, Identifier(exec, errorPrototype->classInfo()->className))
    3434{
    3535    // ECMA 15.11.3.1 Error.prototype
    36     putDirect(exec->propertyNames().prototype, errorProto, DontEnum|DontDelete|ReadOnly);
    37     putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete|ReadOnly|DontEnum);
     36    putDirect(exec->propertyNames().prototype, errorPrototype, DontEnum | DontDelete | ReadOnly);
     37    putDirect(exec->propertyNames().length, jsNumber(exec, 1), DontDelete | ReadOnly | DontEnum);
    3838}
    3939
  • trunk/JavaScriptCore/kjs/FunctionConstructor.h

    r34901 r35022  
    3030    class FunctionPrototype;
    3131
    32     /**
    33      * @internal
    34      *
    35      * The initial value of the the global variable's "Function" property
    36      */
    3732    class FunctionConstructor : public InternalFunction {
    3833    public:
    3934        FunctionConstructor(ExecState*, FunctionPrototype*);
     35
    4036    private:
    4137        virtual ConstructType getConstructData(ConstructData&);
  • trunk/JavaScriptCore/kjs/FunctionPrototype.cpp

    r35020 r35022  
    6666    if (function->inherits(&JSFunction::info)) {
    6767        JSFunction* fi = static_cast<JSFunction*>(thisValue);
    68         return jsString(exec, "function " + fi->functionName().ustring() + "(" + fi->body->paramString() + ") " + fi->body->toSourceString());
     68        return jsString(exec, "function " + fi->functionName().ustring() + "(" + fi->m_body->paramString() + ") " + fi->m_body->toSourceString());
    6969    }
    7070
  • trunk/JavaScriptCore/kjs/FunctionPrototype.h

    r34901 r35022  
    2828namespace KJS {
    2929
    30     /**
    31      * @internal
    32      *
    33      * The initial value of Function.prototype (and thus all objects created
    34      * with the Function constructor)
    35      */
    3630    class FunctionPrototype : public InternalFunction {
    3731    public:
    3832        FunctionPrototype(ExecState*);
     33
    3934    private:
    4035        virtual CallType getCallData(CallData&);
  • trunk/JavaScriptCore/kjs/GetterSetter.h

    r35007 r35022  
    2828namespace KJS {
    2929
    30   class JSObject;
     30    class JSObject;
    3131
    32   // This is an internal value object which stores getter and setter functions
    33   // for a property.
    34   class GetterSetter : public JSCell {
    35   public:
    36     JSType type() const { return GetterSetterType; }
    37      
    38     GetterSetter() : m_getter(0), m_setter(0) { }
    39      
    40     virtual void mark();
    41      
    42     JSObject* getter() const { return m_getter; }
    43     void setGetter(JSObject* getter) { m_getter = getter; }
    44     JSObject* setter() const { return m_setter; }
    45     void setSetter(JSObject* setter) { m_setter = setter; }
    46      
    47   private:
    48     virtual JSValue* toPrimitive(ExecState*, JSType preferred) const;
    49     virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
    50     virtual bool toBoolean(ExecState*) const;
    51     virtual double toNumber(ExecState*) const;
    52     virtual UString toString(ExecState*) const;
    53     virtual JSObject* toObject(ExecState*) const;
     32    // This is an internal value object which stores getter and setter functions
     33    // for a property.
     34    class GetterSetter : public JSCell {
     35    public:
     36        GetterSetter()
     37            : m_getter(0)
     38            , m_setter(0)
     39        {
     40        }
    5441
    55     JSObject* m_getter;
    56     JSObject* m_setter; 
    57   };
    58  
     42        JSType type() const { return GetterSetterType; }
     43
     44        virtual void mark();
     45
     46        JSObject* getter() const { return m_getter; }
     47        void setGetter(JSObject* getter) { m_getter = getter; }
     48        JSObject* setter() const { return m_setter; }
     49        void setSetter(JSObject* setter) { m_setter = setter; }
     50
     51    private:
     52        virtual JSValue* toPrimitive(ExecState*, JSType preferred) const;
     53        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
     54        virtual bool toBoolean(ExecState*) const;
     55        virtual double toNumber(ExecState*) const;
     56        virtual UString toString(ExecState*) const;
     57        virtual JSObject* toObject(ExecState*) const;
     58
     59        JSObject* m_getter;
     60        JSObject* m_setter; 
     61    };
     62
    5963} // namespace KJS
    6064
  • trunk/JavaScriptCore/kjs/GlobalEvalFunction.h

    r35016 r35022  
    2929namespace KJS {
    3030
    31   class ExecState;
    32   class FunctionPrototype;
    33   class JSGlobalObject;
     31    class ExecState;
     32    class FunctionPrototype;
     33    class JSGlobalObject;
    3434
    3535    class GlobalEvalFunction : public PrototypeFunction {
  • trunk/JavaScriptCore/kjs/IndexToNameMap.cpp

    r35021 r35022  
    4242
    4343IndexToNameMap::IndexToNameMap(JSFunction* func, const ArgList& args)
     44    : m_size(args.size())
     45    , m_map(new Identifier[args.size()])
    4446{
    45   _map = new Identifier[args.size()];
    46   this->size = args.size();
    47  
    48   unsigned i = 0;
    49   ArgList::const_iterator end = args.end();
    50   for (ArgList::const_iterator it = args.begin(); it != end; ++i, ++it)
    51     _map[i] = func->getParameterName(i); // null if there is no corresponding parameter
     47    unsigned i = 0;
     48    ArgList::const_iterator end = args.end();
     49    for (ArgList::const_iterator it = args.begin(); it != end; ++i, ++it)
     50        m_map[i] = func->getParameterName(i); // null if there is no corresponding parameter
    5251}
    5352
    5453IndexToNameMap::~IndexToNameMap()
    5554{
    56   delete [] _map;
     55    delete [] m_map;
    5756}
    5857
    5958bool IndexToNameMap::isMapped(const Identifier& index) const
    6059{
    61   bool indexIsNumber;
    62   unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber);
    63  
    64   if (!indexIsNumber)
    65     return false;
    66  
    67   if (indexAsNumber >= size)
    68     return false;
     60    bool indexIsNumber;
     61    unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber);
    6962
    70   if (_map[indexAsNumber].isNull())
    71     return false;
    72  
    73   return true;
     63    if (!indexIsNumber)
     64        return false;
     65
     66    if (indexAsNumber >= m_size)
     67        return false;
     68
     69    if (m_map[indexAsNumber].isNull())
     70        return false;
     71
     72    return true;
    7473}
    7574
    7675void IndexToNameMap::unMap(ExecState* exec, const Identifier& index)
    7776{
    78   bool indexIsNumber;
    79   unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber);
     77    bool indexIsNumber;
     78    unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber);
    8079
    81   ASSERT(indexIsNumber && indexAsNumber < size);
    82  
    83   _map[indexAsNumber] = exec->propertyNames().nullIdentifier;
     80    ASSERT(indexIsNumber && indexAsNumber < m_size);
     81
     82    m_map[indexAsNumber] = exec->propertyNames().nullIdentifier;
    8483}
    8584
    8685Identifier& IndexToNameMap::operator[](const Identifier& index)
    8786{
    88   bool indexIsNumber;
    89   unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber);
     87    bool indexIsNumber;
     88    unsigned indexAsNumber = index.toStrictUInt32(&indexIsNumber);
    9089
    91   ASSERT(indexIsNumber && indexAsNumber < size);
    92  
    93   return _map[indexAsNumber];
     90    ASSERT(indexIsNumber && indexAsNumber < m_size);
     91
     92    return m_map[indexAsNumber];
    9493}
    9594
  • trunk/JavaScriptCore/kjs/IndexToNameMap.h

    r35016 r35022  
    2727namespace KJS {
    2828
    29   class ArgList;
    30   class ExecState;
    31   class Identifier;
    32   class JSFunction;
     29    class ArgList;
     30    class ExecState;
     31    class Identifier;
     32    class JSFunction;
    3333
    34   class IndexToNameMap {
    35   public:
    36     IndexToNameMap(JSFunction*, const ArgList&);
    37     ~IndexToNameMap();
    38    
    39     Identifier& operator[](const Identifier& index);
    40     bool isMapped(const Identifier& index) const;
    41     void unMap(ExecState* exec, const Identifier& index);
    42    
    43   private:
    44     unsigned size;
    45     Identifier* _map;
    46   };
     34    class IndexToNameMap {
     35    public:
     36        IndexToNameMap(JSFunction*, const ArgList&);
     37        ~IndexToNameMap();
     38
     39        Identifier& operator[](const Identifier& index);
     40        bool isMapped(const Identifier& index) const;
     41        void unMap(ExecState* exec, const Identifier& index);
     42
     43    private:
     44        unsigned m_size;
     45        Identifier* m_map; // FIMXE: this should be an OwnArrayPtr
     46    };
    4747
    4848} // namespace KJS
  • trunk/JavaScriptCore/kjs/InitializeThreading.cpp

    r34977 r35022  
    7272}
    7373
    74 }
     74} // namespace KJS
  • trunk/JavaScriptCore/kjs/InitializeThreading.h

    r32808 r35022  
    3838}
    3939
    40 #endif
     40#endif // KJS_InitializeThreading_h
  • trunk/JavaScriptCore/kjs/InternalFunction.h

    r34901 r35022  
    2525#define InternalFunction_h
    2626
     27#include "JSObject.h"
    2728#include "identifier.h"
    28 #include "JSObject.h"
    2929
    3030namespace KJS {
    3131
    32   class FunctionPrototype;
     32    class FunctionPrototype;
    3333
    34   class InternalFunction : public JSObject {
    35   public:
    36     static const ClassInfo info;
    37     virtual const ClassInfo* classInfo() const { return &info; }
    38     const Identifier& functionName() const { return m_name; }
     34    class InternalFunction : public JSObject {
     35    public:
     36        virtual const ClassInfo* classInfo() const { return &info; }
     37        static const ClassInfo info;
    3938
    40   protected:
    41     InternalFunction();
    42     InternalFunction(FunctionPrototype*, const Identifier&);
     39        const Identifier& functionName() const { return m_name; }
    4340
    44   private:
    45     virtual CallType getCallData(CallData&) = 0;
    46     virtual bool implementsHasInstance() const;
     41    protected:
     42        InternalFunction();
     43        InternalFunction(FunctionPrototype*, const Identifier&);
    4744
    48     Identifier m_name;
    49   };
     45    private:
     46        virtual CallType getCallData(CallData&) = 0;
     47        virtual bool implementsHasInstance() const;
     48
     49        Identifier m_name;
     50    };
    5051
    5152} // namespace KJS
  • trunk/JavaScriptCore/kjs/JSActivation.h

    r34906 r35022  
    3939   
    4040    class JSActivation : public JSVariableObject {
    41     typedef JSVariableObject Base;
     41        typedef JSVariableObject Base;
    4242    public:
    4343        JSActivation(PassRefPtr<FunctionBodyNode>, Register*);
  • trunk/JavaScriptCore/kjs/JSArray.cpp

    r34985 r35022  
    834834}
    835835
    836 }
     836} // namespace KJS
  • trunk/JavaScriptCore/kjs/JSArray.h

    r34964 r35022  
    2727namespace KJS {
    2828
    29   typedef HashMap<unsigned, JSValue*> SparseArrayValueMap;
     29    typedef HashMap<unsigned, JSValue*> SparseArrayValueMap;
    3030
    31   struct ArrayStorage {
    32       unsigned m_vectorLength;
    33       unsigned m_numValuesInVector;
    34       SparseArrayValueMap* m_sparseValueMap;
    35       void* lazyCreationData; // A JSArray subclass can use this to fill the vector lazily.
    36       JSValue* m_vector[1];
    37   };
     31    struct ArrayStorage {
     32        unsigned m_vectorLength;
     33        unsigned m_numValuesInVector;
     34        SparseArrayValueMap* m_sparseValueMap;
     35        void* lazyCreationData; // A JSArray subclass can use this to fill the vector lazily.
     36        JSValue* m_vector[1];
     37    };
    3838
    39   class JSArray : public JSObject {
    40   public:
    41     JSArray(JSValue* prototype, unsigned initialLength);
    42     JSArray(JSObject* prototype, const ArgList& initialValues);
    43     virtual ~JSArray();
     39    class JSArray : public JSObject {
     40    public:
     41        JSArray(JSValue* prototype, unsigned initialLength);
     42        JSArray(JSObject* prototype, const ArgList& initialValues);
     43        virtual ~JSArray();
    4444
    45     virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    46     virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
    47     virtual void put(ExecState*, unsigned propertyName, JSValue*); // FIXME: Make protected and add setItem.
     45        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     46        virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
     47        virtual void put(ExecState*, unsigned propertyName, JSValue*); // FIXME: Make protected and add setItem.
    4848
    49     static const ClassInfo info;
     49        static const ClassInfo info;
    5050
    51     unsigned getLength() const { return m_length; }
    52     void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
     51        unsigned getLength() const { return m_length; }
     52        void setLength(unsigned); // OK to use on new arrays, but not if it might be a RegExpMatchArray.
    5353
    54     void sort(ExecState*);
    55     void sort(ExecState*, JSValue* compareFunction, CallType, const CallData&);
     54        void sort(ExecState*);
     55        void sort(ExecState*, JSValue* compareFunction, CallType, const CallData&);
    5656
    57     bool canGetIndex(unsigned i) { return i < m_fastAccessCutoff; }
    58     JSValue* getIndex(unsigned i)
    59     {
    60         ASSERT(canGetIndex(i));
    61         return m_storage->m_vector[i];
    62     }
     57        bool canGetIndex(unsigned i) { return i < m_fastAccessCutoff; }
     58        JSValue* getIndex(unsigned i)
     59        {
     60            ASSERT(canGetIndex(i));
     61            return m_storage->m_vector[i];
     62        }
    6363
    64     bool canSetIndex(unsigned i) { return i < m_fastAccessCutoff; }
    65     JSValue* setIndex(unsigned i, JSValue* v)
    66     {
    67         ASSERT(canSetIndex(i));
    68         return m_storage->m_vector[i] = v;
    69     }
     64        bool canSetIndex(unsigned i) { return i < m_fastAccessCutoff; }
     65        JSValue* setIndex(unsigned i, JSValue* v)
     66        {
     67            ASSERT(canSetIndex(i));
     68            return m_storage->m_vector[i] = v;
     69        }
    7070
    71   protected:
    72     virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    73     virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    74     virtual bool deleteProperty(ExecState*, unsigned propertyName);
    75     virtual void getPropertyNames(ExecState*, PropertyNameArray&);
    76     virtual void mark();
     71    protected:
     72        virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
     73        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     74        virtual bool deleteProperty(ExecState*, unsigned propertyName);
     75        virtual void getPropertyNames(ExecState*, PropertyNameArray&);
     76        virtual void mark();
    7777
    78     void* lazyCreationData();
    79     void setLazyCreationData(void*);
     78        void* lazyCreationData();
     79        void setLazyCreationData(void*);
    8080
    81   private:
    82     virtual const ClassInfo* classInfo() const { return &info; }
     81    private:
     82        virtual const ClassInfo* classInfo() const { return &info; }
    8383
    84     static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
     84        static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
    8585
    86     bool getOwnPropertySlotSlowCase(ExecState*, unsigned propertyName, PropertySlot&);
    87     void putSlowCase(ExecState*, unsigned propertyName, JSValue*);
     86        bool getOwnPropertySlotSlowCase(ExecState*, unsigned propertyName, PropertySlot&);
     87        void putSlowCase(ExecState*, unsigned propertyName, JSValue*);
    8888
    89     bool increaseVectorLength(unsigned newLength);
    90    
    91     unsigned compactForSorting();
     89        bool increaseVectorLength(unsigned newLength);
     90       
     91        unsigned compactForSorting();
    9292
    93     enum ConsistencyCheckType { NormalConsistencyCheck, DestructorConsistencyCheck, SortConsistencyCheck };
    94     void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
     93        enum ConsistencyCheckType { NormalConsistencyCheck, DestructorConsistencyCheck, SortConsistencyCheck };
     94        void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
    9595
    96     unsigned m_length;
    97     unsigned m_fastAccessCutoff;
    98     ArrayStorage* m_storage;
    99   };
     96        unsigned m_length;
     97        unsigned m_fastAccessCutoff;
     98        ArrayStorage* m_storage;
     99    };
    100100
    101   JSArray* constructEmptyArray(ExecState*);
    102   JSArray* constructEmptyArray(ExecState*, unsigned initialLength);
    103   JSArray* constructArray(ExecState*, JSValue* singleItemValue);
    104   JSArray* constructArray(ExecState*, const ArgList& values);
     101    JSArray* constructEmptyArray(ExecState*);
     102    JSArray* constructEmptyArray(ExecState*, unsigned initialLength);
     103    JSArray* constructArray(ExecState*, JSValue* singleItemValue);
     104    JSArray* constructArray(ExecState*, const ArgList& values);
    105105
    106106} // namespace KJS
    107107
    108 #endif
     108#endif // JSArray_h
  • trunk/JavaScriptCore/kjs/JSCell.h

    r34964 r35022  
    2929namespace KJS {
    3030
    31 class JSCell : public JSValue {
    32     friend class Heap;
    33     friend class GetterSetter;
    34     friend class JSObject;
    35     friend class JSPropertyNameIterator;
    36     friend class JSValue;
    37     friend class JSNumberCell;
    38     friend class JSString;
    39     friend class Machine;
    40 private:
    41     JSCell();
    42     virtual ~JSCell();
    43 
    44 public:
    45     // Querying the type.
    46     virtual JSType type() const = 0;
    47     bool isNumber() const;
    48     bool isString() const;
    49     bool isObject() const;
    50     bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.
    51 
    52     // Extracting the value.
    53     bool getNumber(double&) const;
    54     double getNumber() const; // NaN if not a number
    55     bool getString(UString&) const;
    56     UString getString() const; // null string if not a string
    57     JSObject* getObject(); // NULL if not an object
    58     const JSObject* getObject() const; // NULL if not an object
    59    
    60     virtual CallType getCallData(CallData&);
    61     virtual ConstructType getConstructData(ConstructData&);
    62 
    63     // Extracting integer values.
    64     virtual bool getUInt32(uint32_t&) const;
    65     virtual bool getTruncatedInt32(int32_t&) const;
    66     virtual bool getTruncatedUInt32(uint32_t&) const;
    67 
    68     // Basic conversions.
    69     virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const = 0;
    70     virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&) = 0;
    71     virtual bool toBoolean(ExecState*) const = 0;
    72     virtual double toNumber(ExecState*) const = 0;
    73     virtual UString toString(ExecState*) const = 0;
    74     virtual JSObject* toObject(ExecState*) const = 0;
    75 
    76     // Garbage collection.
    77     void* operator new(size_t, ExecState*);
    78     void* operator new(size_t, void* placementNewDestination) { return placementNewDestination; }
    79     virtual void mark();
    80     bool marked() const;
    81 
    82     // Object operations, with the toObject operation included.
    83     virtual const ClassInfo* classInfo() const;
    84     virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    85     virtual void put(ExecState*, unsigned propertyName, JSValue*);
    86     virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    87     virtual bool deleteProperty(ExecState*, unsigned propertyName);
    88 
    89     virtual JSObject* toThisObject(ExecState*) const;
    90     virtual UString toThisString(ExecState*) const;
    91     virtual JSString* toThisJSString(ExecState*);
    92     virtual JSValue* getJSNumber();
    93     void* vptr() { return *reinterpret_cast<void**>(this); }
    94 
    95 private:
    96     // Base implementation, but for non-object classes implements getPropertySlot.
    97     virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
    98     virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
    99 };
    100 
    101 inline JSCell::JSCell()
    102 {
    103 }
    104 
    105 inline JSCell::~JSCell()
    106 {
    107 }
    108 
    109 inline bool JSCell::isNumber() const
    110 {
    111     return type() == NumberType;
    112 }
    113 
    114 inline bool JSCell::isString() const
    115 {
    116     return type() == StringType;
    117 }
    118 
    119 inline bool JSCell::isObject() const
    120 {
    121     return type() == ObjectType;
    122 }
    123 
    124 inline bool JSCell::marked() const
    125 {
    126     return Heap::isCellMarked(this);
    127 }
    128 
    129 inline void JSCell::mark()
    130 {
    131     return Heap::markCell(this);
    132 }
    133 
    134 ALWAYS_INLINE JSCell* JSValue::asCell()
    135 {
    136     ASSERT(!JSImmediate::isImmediate(this));
    137     return static_cast<JSCell*>(this);
    138 }
    139 
    140 ALWAYS_INLINE const JSCell* JSValue::asCell() const
    141 {
    142     ASSERT(!JSImmediate::isImmediate(this));
    143     return static_cast<const JSCell*>(this);
    144 }
    145 
    146 
    147 // --- JSValue inlines ----------------------------
    148 
    149 inline bool JSValue::isNumber() const
    150 {
    151     return JSImmediate::isNumber(this) || (!JSImmediate::isImmediate(this) && asCell()->isNumber());
    152 }
    153 
    154 inline bool JSValue::isString() const
    155 {
    156     return !JSImmediate::isImmediate(this) && asCell()->isString();
    157 }
    158 
    159 inline bool JSValue::isObject() const
    160 {
    161     return !JSImmediate::isImmediate(this) && asCell()->isObject();
    162 }
    163 
    164 inline bool JSValue::getNumber(double& v) const
    165 {
    166     if (JSImmediate::isImmediate(this)) {
    167         v = JSImmediate::toDouble(this);
    168         return true;
    169     }
    170     return asCell()->getNumber(v);
    171 }
    172 
    173 inline double JSValue::getNumber() const
    174 {
    175     return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->getNumber();
    176 }
    177 
    178 inline bool JSValue::getString(UString& s) const
    179 {
    180     return !JSImmediate::isImmediate(this) && asCell()->getString(s);
    181 }
    182 
    183 inline UString JSValue::getString() const
    184 {
    185     return JSImmediate::isImmediate(this) ? UString() : asCell()->getString();
    186 }
    187 
    188 inline JSObject *JSValue::getObject()
    189 {
    190     return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject();
    191 }
    192 
    193 inline const JSObject *JSValue::getObject() const
    194 {
    195     return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject();
    196 }
    197 
    198 inline CallType JSValue::getCallData(CallData& callData)
    199 {
    200     return JSImmediate::isImmediate(this) ? CallTypeNone : asCell()->getCallData(callData);
    201 }
    202 
    203 inline ConstructType JSValue::getConstructData(ConstructData& constructData)
    204 {
    205     return JSImmediate::isImmediate(this) ? ConstructTypeNone : asCell()->getConstructData(constructData);
    206 }
    207 
    208 ALWAYS_INLINE bool JSValue::getUInt32(uint32_t& v) const
    209 {
    210     return JSImmediate::isImmediate(this) ? JSImmediate::getUInt32(this, v) : asCell()->getUInt32(v);
    211 }
    212 
    213 ALWAYS_INLINE bool JSValue::getTruncatedInt32(int32_t& v) const
    214 {
    215     return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedInt32(this, v) : asCell()->getTruncatedInt32(v);
    216 }
    217 
    218 inline bool JSValue::getTruncatedUInt32(uint32_t& v) const
    219 {
    220     return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedUInt32(this, v) : asCell()->getTruncatedUInt32(v);
    221 }
    222 
    223 inline void JSValue::mark()
    224 {
    225     ASSERT(!JSImmediate::isImmediate(this)); // callers should check !marked() before calling mark()
    226     asCell()->mark();
    227 }
    228 
    229 inline bool JSValue::marked() const
    230 {
    231     return JSImmediate::isImmediate(this) || asCell()->marked();
    232 }
    233 
    234 inline JSType JSValue::type() const
    235 {
    236     return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : asCell()->type();
    237 }
    238 
    239 inline JSValue* JSValue::toPrimitive(ExecState* exec, JSType preferredType) const
    240 {
    241     return JSImmediate::isImmediate(this) ? const_cast<JSValue*>(this) : asCell()->toPrimitive(exec, preferredType);
    242 }
    243 
    244 inline bool JSValue::getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value)
    245 {
    246     if (JSImmediate::isImmediate(this)) {
    247         number = JSImmediate::toDouble(this);
    248         value = this;
    249         return true;
    250     }
    251     return asCell()->getPrimitiveNumber(exec, number, value);
    252 }
    253 
    254 inline bool JSValue::toBoolean(ExecState *exec) const
    255 {
    256     return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(exec);
    257 }
    258 
    259 ALWAYS_INLINE double JSValue::toNumber(ExecState *exec) const
    260 {
    261     return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->toNumber(exec);
    262 }
    263 
    264 inline UString JSValue::toString(ExecState *exec) const
    265 {
    266     return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : asCell()->toString(exec);
    267 }
    268 
    269 inline JSObject* JSValue::toObject(ExecState* exec) const
    270 {
    271     return JSImmediate::isImmediate(this) ? JSImmediate::toObject(this, exec) : asCell()->toObject(exec);
    272 }
    273 
    274 inline JSObject* JSValue::toThisObject(ExecState* exec) const
    275 {
    276     if (UNLIKELY(JSImmediate::isImmediate(this)))
    277         return JSImmediate::toObject(this, exec);
    278     return asCell()->toThisObject(exec);
    279 }
    280 
    281 inline UString JSValue::toThisString(ExecState* exec) const
    282 {
    283     return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : asCell()->toThisString(exec);
    284 }
    285 
    286 inline JSValue* JSValue::getJSNumber()
    287 {
    288 
    289     return JSImmediate::isNumber(this) ? this : (JSImmediate::isImmediate(this) ? 0 : asCell()->getJSNumber());
    290 }
     31    class JSCell : public JSValue {
     32        friend class Heap;
     33        friend class GetterSetter;
     34        friend class JSObject;
     35        friend class JSPropertyNameIterator;
     36        friend class JSValue;
     37        friend class JSNumberCell;
     38        friend class JSString;
     39        friend class Machine;
     40    private:
     41        JSCell();
     42        virtual ~JSCell();
     43
     44    public:
     45        // Querying the type.
     46        virtual JSType type() const = 0;
     47        bool isNumber() const;
     48        bool isString() const;
     49        bool isObject() const;
     50        bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.
     51
     52        // Extracting the value.
     53        bool getNumber(double&) const;
     54        double getNumber() const; // NaN if not a number
     55        bool getString(UString&) const;
     56        UString getString() const; // null string if not a string
     57        JSObject* getObject(); // NULL if not an object
     58        const JSObject* getObject() const; // NULL if not an object
     59       
     60        virtual CallType getCallData(CallData&);
     61        virtual ConstructType getConstructData(ConstructData&);
     62
     63        // Extracting integer values.
     64        virtual bool getUInt32(uint32_t&) const;
     65        virtual bool getTruncatedInt32(int32_t&) const;
     66        virtual bool getTruncatedUInt32(uint32_t&) const;
     67
     68        // Basic conversions.
     69        virtual JSValue* toPrimitive(ExecState*, JSType preferredType = UnspecifiedType) const = 0;
     70        virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*&) = 0;
     71        virtual bool toBoolean(ExecState*) const = 0;
     72        virtual double toNumber(ExecState*) const = 0;
     73        virtual UString toString(ExecState*) const = 0;
     74        virtual JSObject* toObject(ExecState*) const = 0;
     75
     76        // Garbage collection.
     77        void* operator new(size_t, ExecState*);
     78        void* operator new(size_t, void* placementNewDestination) { return placementNewDestination; }
     79        virtual void mark();
     80        bool marked() const;
     81
     82        // Object operations, with the toObject operation included.
     83        virtual const ClassInfo* classInfo() const;
     84        virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
     85        virtual void put(ExecState*, unsigned propertyName, JSValue*);
     86        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     87        virtual bool deleteProperty(ExecState*, unsigned propertyName);
     88
     89        virtual JSObject* toThisObject(ExecState*) const;
     90        virtual UString toThisString(ExecState*) const;
     91        virtual JSString* toThisJSString(ExecState*);
     92        virtual JSValue* getJSNumber();
     93        void* vptr() { return *reinterpret_cast<void**>(this); }
     94
     95    private:
     96        // Base implementation, but for non-object classes implements getPropertySlot.
     97        virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
     98        virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
     99    };
     100
     101    inline JSCell::JSCell()
     102    {
     103    }
     104
     105    inline JSCell::~JSCell()
     106    {
     107    }
     108
     109    inline bool JSCell::isNumber() const
     110    {
     111        return type() == NumberType;
     112    }
     113
     114    inline bool JSCell::isString() const
     115    {
     116        return type() == StringType;
     117    }
     118
     119    inline bool JSCell::isObject() const
     120    {
     121        return type() == ObjectType;
     122    }
     123
     124    inline bool JSCell::marked() const
     125    {
     126        return Heap::isCellMarked(this);
     127    }
     128
     129    inline void JSCell::mark()
     130    {
     131        return Heap::markCell(this);
     132    }
     133
     134    ALWAYS_INLINE JSCell* JSValue::asCell()
     135    {
     136        ASSERT(!JSImmediate::isImmediate(this));
     137        return static_cast<JSCell*>(this);
     138    }
     139
     140    ALWAYS_INLINE const JSCell* JSValue::asCell() const
     141    {
     142        ASSERT(!JSImmediate::isImmediate(this));
     143        return static_cast<const JSCell*>(this);
     144    }
     145
     146
     147    // --- JSValue inlines ----------------------------
     148
     149    inline bool JSValue::isNumber() const
     150    {
     151        return JSImmediate::isNumber(this) || (!JSImmediate::isImmediate(this) && asCell()->isNumber());
     152    }
     153
     154    inline bool JSValue::isString() const
     155    {
     156        return !JSImmediate::isImmediate(this) && asCell()->isString();
     157    }
     158
     159    inline bool JSValue::isObject() const
     160    {
     161        return !JSImmediate::isImmediate(this) && asCell()->isObject();
     162    }
     163
     164    inline bool JSValue::getNumber(double& v) const
     165    {
     166        if (JSImmediate::isImmediate(this)) {
     167            v = JSImmediate::toDouble(this);
     168            return true;
     169        }
     170        return asCell()->getNumber(v);
     171    }
     172
     173    inline double JSValue::getNumber() const
     174    {
     175        return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->getNumber();
     176    }
     177
     178    inline bool JSValue::getString(UString& s) const
     179    {
     180        return !JSImmediate::isImmediate(this) && asCell()->getString(s);
     181    }
     182
     183    inline UString JSValue::getString() const
     184    {
     185        return JSImmediate::isImmediate(this) ? UString() : asCell()->getString();
     186    }
     187
     188    inline JSObject* JSValue::getObject()
     189    {
     190        return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject();
     191    }
     192
     193    inline const JSObject* JSValue::getObject() const
     194    {
     195        return JSImmediate::isImmediate(this) ? 0 : asCell()->getObject();
     196    }
     197
     198    inline CallType JSValue::getCallData(CallData& callData)
     199    {
     200        return JSImmediate::isImmediate(this) ? CallTypeNone : asCell()->getCallData(callData);
     201    }
     202
     203    inline ConstructType JSValue::getConstructData(ConstructData& constructData)
     204    {
     205        return JSImmediate::isImmediate(this) ? ConstructTypeNone : asCell()->getConstructData(constructData);
     206    }
     207
     208    ALWAYS_INLINE bool JSValue::getUInt32(uint32_t& v) const
     209    {
     210        return JSImmediate::isImmediate(this) ? JSImmediate::getUInt32(this, v) : asCell()->getUInt32(v);
     211    }
     212
     213    ALWAYS_INLINE bool JSValue::getTruncatedInt32(int32_t& v) const
     214    {
     215        return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedInt32(this, v) : asCell()->getTruncatedInt32(v);
     216    }
     217
     218    inline bool JSValue::getTruncatedUInt32(uint32_t& v) const
     219    {
     220        return JSImmediate::isImmediate(this) ? JSImmediate::getTruncatedUInt32(this, v) : asCell()->getTruncatedUInt32(v);
     221    }
     222
     223    inline void JSValue::mark()
     224    {
     225        ASSERT(!JSImmediate::isImmediate(this)); // callers should check !marked() before calling mark()
     226        asCell()->mark();
     227    }
     228
     229    inline bool JSValue::marked() const
     230    {
     231        return JSImmediate::isImmediate(this) || asCell()->marked();
     232    }
     233
     234    inline JSType JSValue::type() const
     235    {
     236        return JSImmediate::isImmediate(this) ? JSImmediate::type(this) : asCell()->type();
     237    }
     238
     239    inline JSValue* JSValue::toPrimitive(ExecState* exec, JSType preferredType) const
     240    {
     241        return JSImmediate::isImmediate(this) ? const_cast<JSValue*>(this) : asCell()->toPrimitive(exec, preferredType);
     242    }
     243
     244    inline bool JSValue::getPrimitiveNumber(ExecState* exec, double& number, JSValue*& value)
     245    {
     246        if (JSImmediate::isImmediate(this)) {
     247            number = JSImmediate::toDouble(this);
     248            value = this;
     249            return true;
     250        }
     251        return asCell()->getPrimitiveNumber(exec, number, value);
     252    }
     253
     254    inline bool JSValue::toBoolean(ExecState* exec) const
     255    {
     256        return JSImmediate::isImmediate(this) ? JSImmediate::toBoolean(this) : asCell()->toBoolean(exec);
     257    }
     258
     259    ALWAYS_INLINE double JSValue::toNumber(ExecState* exec) const
     260    {
     261        return JSImmediate::isImmediate(this) ? JSImmediate::toDouble(this) : asCell()->toNumber(exec);
     262    }
     263
     264    inline UString JSValue::toString(ExecState* exec) const
     265    {
     266        return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : asCell()->toString(exec);
     267    }
     268
     269    inline JSObject* JSValue::toObject(ExecState* exec) const
     270    {
     271        return JSImmediate::isImmediate(this) ? JSImmediate::toObject(this, exec) : asCell()->toObject(exec);
     272    }
     273
     274    inline JSObject* JSValue::toThisObject(ExecState* exec) const
     275    {
     276        if (UNLIKELY(JSImmediate::isImmediate(this)))
     277            return JSImmediate::toObject(this, exec);
     278        return asCell()->toThisObject(exec);
     279    }
     280
     281    inline UString JSValue::toThisString(ExecState* exec) const
     282    {
     283        return JSImmediate::isImmediate(this) ? JSImmediate::toString(this) : asCell()->toThisString(exec);
     284    }
     285
     286    inline JSValue* JSValue::getJSNumber()
     287    {
     288
     289        return JSImmediate::isNumber(this) ? this : (JSImmediate::isImmediate(this) ? 0 : asCell()->getJSNumber());
     290    }
    291291
    292292} // namespace KJS
  • trunk/JavaScriptCore/kjs/JSFunction.cpp

    r35016 r35022  
    4242const ClassInfo JSFunction::info = { "Function", &InternalFunction::info, 0, 0 };
    4343
    44 JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* b, ScopeChainNode* scopeChain)
    45   : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
    46   , body(b)
    47   , _scope(scopeChain)
     44JSFunction::JSFunction(ExecState* exec, const Identifier& name, FunctionBodyNode* body, ScopeChainNode* scopeChainNode)
     45    : InternalFunction(exec->lexicalGlobalObject()->functionPrototype(), name)
     46    , m_body(body)
     47    , m_scopeChain(scopeChainNode)
    4848{
    4949}
     
    5252{
    5353    InternalFunction::mark();
    54     body->mark();
    55     _scope.mark();
     54    m_body->mark();
     55    m_scopeChain.mark();
    5656}
    5757
    5858CallType JSFunction::getCallData(CallData& callData)
    5959{
    60     callData.js.functionBody = body.get();
    61     callData.js.scopeChain = _scope.node();
     60    callData.js.functionBody = m_body.get();
     61    callData.js.scopeChain = m_scopeChain.node();
    6262    return CallTypeJS;
    6363}
     
    6565JSValue* JSFunction::call(ExecState* exec, JSValue* thisValue, const ArgList& args)
    6666{
    67     return exec->machine()->execute(body.get(), exec, this, thisValue->toThisObject(exec), args, _scope.node(), exec->exceptionSlot());
     67    return exec->machine()->execute(m_body.get(), exec, this, thisValue->toThisObject(exec), args, m_scopeChain.node(), exec->exceptionSlot());
    6868}
    6969
     
    8383{
    8484    JSFunction* thisObj = static_cast<JSFunction*>(slot.slotBase());
    85     return jsNumber(exec, thisObj->body->parameters().size());
     85    return jsNumber(exec, thisObj->m_body->parameters().size());
    8686}
    8787
     
    129129const Identifier& JSFunction::getParameterName(int index)
    130130{
    131     Vector<Identifier>& parameters = body->parameters();
     131    Vector<Identifier>& parameters = m_body->parameters();
    132132
    133     if (static_cast<size_t>(index) >= body->parameters().size())
    134         return _scope.globalObject()->globalData()->propertyNames->nullIdentifier;
     133    if (static_cast<size_t>(index) >= m_body->parameters().size())
     134        return m_scopeChain.globalObject()->globalData()->propertyNames->nullIdentifier;
    135135 
    136136    const Identifier& name = parameters[index];
     
    138138    // Are there any subsequent parameters with the same name?
    139139    size_t size = parameters.size();
    140     for (size_t i = index + 1; i < size; ++i)
     140    for (size_t i = index + 1; i < size; ++i) {
    141141        if (parameters[i] == name)
    142             return _scope.globalObject()->globalData()->propertyNames->nullIdentifier;
     142            return m_scopeChain.globalObject()->globalData()->propertyNames->nullIdentifier;
     143    }
    143144
    144145    return name;
     
    148149ConstructType JSFunction::getConstructData(ConstructData& constructData)
    149150{
    150     constructData.js.functionBody = body.get();
    151     constructData.js.scopeChain = _scope.node();
     151    constructData.js.functionBody = m_body.get();
     152    constructData.js.scopeChain = m_scopeChain.node();
    152153    return ConstructTypeJS;
    153154}
     
    164165    JSObject* thisObj = new (exec) JSObject(proto);
    165166
    166     JSValue* result = exec->machine()->execute(body.get(), exec, this, thisObj, args, _scope.node(), exec->exceptionSlot());
     167    JSValue* result = exec->machine()->execute(m_body.get(), exec, this, thisObj, args, m_scopeChain.node(), exec->exceptionSlot());
    167168    if (exec->hadException() || !result->isObject())
    168169        return thisObj;
  • trunk/JavaScriptCore/kjs/JSFunction.h

    r35016 r35022  
    3333namespace KJS {
    3434
    35   class FunctionBodyNode;
    36   class FunctionPrototype;
    37   class JSActivation;
    38   class JSGlobalObject;
     35    class FunctionBodyNode;
     36    class FunctionPrototype;
     37    class JSActivation;
     38    class JSGlobalObject;
    3939
    40   class JSFunction : public InternalFunction {
    41   public:
    42     JSFunction(ExecState*, const Identifier&, FunctionBodyNode*, ScopeChainNode*);
     40    class JSFunction : public InternalFunction {
     41    public:
     42        JSFunction(ExecState*, const Identifier&, FunctionBodyNode*, ScopeChainNode*);
    4343
    44     virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
    45     virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
    46     virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
     44        virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
     45        virtual void put(ExecState*, const Identifier& propertyName, JSValue*);
     46        virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
    4747
    48     JSObject* construct(ExecState*, const ArgList&);
    49     JSValue* call(ExecState*, JSValue* thisValue, const ArgList&);
     48        JSObject* construct(ExecState*, const ArgList&);
     49        JSValue* call(ExecState*, JSValue* thisValue, const ArgList&);
    5050
    51     // Note: Returns a null identifier for any parameters that will never get set
    52     // due to a later parameter with the same name.
    53     const Identifier& getParameterName(int index);
     51        // Note: Returns a null identifier for any parameters that will never get set
     52        // due to a later parameter with the same name.
     53        const Identifier& getParameterName(int index);
    5454
    55     static const ClassInfo info;
     55        void setScope(const ScopeChain& scopeChain) { m_scopeChain = scopeChain; }
     56        ScopeChain& scope() { return m_scopeChain; }
    5657
    57     RefPtr<FunctionBodyNode> body;
     58        virtual void mark();
    5859
    59     void setScope(const ScopeChain& s) { _scope = s; }
    60     ScopeChain& scope() { return _scope; }
     60        static const ClassInfo info;
    6161
    62     virtual void mark();
     62        // FIXME: This should be private
     63        RefPtr<FunctionBodyNode> m_body;
    6364
    64   private:
    65     virtual const ClassInfo* classInfo() const { return &info; }
    66     virtual ConstructType getConstructData(ConstructData&);
    67     virtual CallType getCallData(CallData&);
     65    private:
     66        virtual const ClassInfo* classInfo() const { return &info; }
    6867
    69     ScopeChain _scope;
     68        virtual ConstructType getConstructData(ConstructData&);
     69        virtual CallType getCallData(CallData&);
    7070
    71     static JSValue* argumentsGetter(ExecState*, const Identifier&, const PropertySlot&);
    72     static JSValue* callerGetter(ExecState*, const Identifier&, const PropertySlot&);
    73     static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
    74   };
     71        static JSValue* argumentsGetter(ExecState*, const Identifier&, const PropertySlot&);
     72        static JSValue* callerGetter(ExecState*, const Identifier&, const PropertySlot&);
     73        static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
     74
     75        ScopeChain m_scopeChain;
     76    };
    7577
    7678} // namespace kJS
  • trunk/JavaScriptCore/kjs/completion.h

    r34578 r35022  
    2727namespace KJS {
    2828
    29   class JSValue;
     29    class JSValue;
    3030
    31   enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted };
     31    enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted };
    3232
    33   /**
    34    * Completion objects are used to convey the return status and value
    35    * from functions.
    36    *
    37    * See JSFunction::execute()
    38    *
    39    * @see JSFunction
    40    *
    41    * @short Handle for a Completion type.
    42    */
    43   class Completion {
    44   public:
    45     Completion(ComplType type = Normal, JSValue* value = 0)
    46         : m_type(type), m_value(value) { }
     33    /*
     34     * Completion objects are used to convey the return status and value
     35     * from functions.
     36     */
     37    class Completion {
     38    public:
     39        Completion(ComplType type = Normal, JSValue* value = 0)
     40            : m_type(type)
     41            , m_value(value)
     42        {
     43        }
    4744
    48     ComplType complType() const { return m_type; }
    49     JSValue* value() const { return m_value; }
    50     void setValue(JSValue* v) { m_value = v; }
    51     bool isValueCompletion() const { return !!m_value; }
     45        ComplType complType() const { return m_type; }
     46        JSValue* value() const { return m_value; }
     47        void setValue(JSValue* v) { m_value = v; }
     48        bool isValueCompletion() const { return !!m_value; }
    5249
    53   private:
    54     ComplType m_type;
    55     JSValue* m_value;
    56   };
     50    private:
     51        ComplType m_type;
     52        JSValue* m_value;
     53    };
    5754
    58 }
     55} // namespace KJS
    5956
    60 #endif
     57#endif // KJS_COMPLETION_H
  • trunk/JavaScriptCore/profiler/Profiler.cpp

    r34901 r35022  
    161161        name = AnonymousFunction;
    162162
    163     return CallIdentifier(name, functionImp->body->sourceURL(), functionImp->body->lineNo());
     163    return CallIdentifier(name, functionImp->m_body->sourceURL(), functionImp->m_body->lineNo());
    164164}
    165165
Note: See TracChangeset for help on using the changeset viewer.