Ignore:
Timestamp:
Oct 16, 2009, 7:31:42 PM (16 years ago)
Author:
[email protected]
Message:

Roll out r49717 as it broke the build.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSPropertyNameIterator.h

    r49717 r49726  
    3232#include "JSObject.h"
    3333#include "JSString.h"
    34 #include "Operations.h"
    3534#include "PropertyNameArray.h"
    3635
     
    4140
    4241    class JSPropertyNameIterator : public JSCell {
    43         friend class JIT;
     42    public:
     43        static JSPropertyNameIterator* create(ExecState*, JSValue);
    4444
    45     public:
    46         static JSPropertyNameIterator* create(ExecState*, JSObject*);
     45        virtual ~JSPropertyNameIterator();
     46
     47        virtual void markChildren(MarkStack&);
     48
     49        JSValue next(ExecState*);
     50        void invalidate();
    4751       
    4852        static PassRefPtr<Structure> createStructure(JSValue prototype)
     
    5054            return Structure::create(prototype, TypeInfo(CompoundType, OverridesMarkChildren));
    5155        }
     56    private:
     57        JSPropertyNameIterator(ExecState*);
     58        JSPropertyNameIterator(ExecState*, JSObject*, PassRefPtr<PropertyNameArrayData> propertyNameArrayData);
    5259
    53         virtual void markChildren(MarkStack&);
    54 
    55         JSValue get(ExecState*, JSObject*, size_t i);
    56         size_t size() { return m_jsStringsSize; }
    57 
    58         void setCachedStructure(Structure* structure) { m_cachedStructure = structure; }
    59         Structure* cachedStructure() { return m_cachedStructure; }
    60 
    61         void setCachedPrototypeChain(NonNullPassRefPtr<StructureChain> cachedPrototypeChain) { m_cachedPrototypeChain = cachedPrototypeChain; }
    62         StructureChain* cachedPrototypeChain() { return m_cachedPrototypeChain.get(); }
    63 
    64     private:
    65         JSPropertyNameIterator(ExecState*, PropertyNameArrayData* propertyNameArrayData);
    66 
    67         Structure* m_cachedStructure;
    68         RefPtr<StructureChain> m_cachedPrototypeChain;
    69         size_t m_jsStringsSize;
    70         OwnArrayPtr<JSValue> m_jsStrings;
     60        JSObject* m_object;
     61        RefPtr<PropertyNameArrayData> m_data;
     62        PropertyNameArrayData::const_iterator m_position;
     63        PropertyNameArrayData::const_iterator m_end;
    7164    };
    7265
    73 inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, PropertyNameArrayData* propertyNameArrayData)
     66inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec)
    7467    : JSCell(exec->globalData().propertyNameIteratorStructure.get())
    75     , m_cachedStructure(0)
    76     , m_jsStringsSize(propertyNameArrayData->propertyNameVector().size())
    77     , m_jsStrings(new JSValue[m_jsStringsSize])
     68    , m_object(0)
     69    , m_position(0)
     70    , m_end(0)
    7871{
    79     PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArrayData->propertyNameVector();
    80     for (size_t i = 0; i < m_jsStringsSize; ++i)
    81         m_jsStrings[i] = jsOwnedString(exec, propertyNameVector[i].ustring());
    8272}
    8373
    84 inline void Structure::setEnumerationCache(JSPropertyNameIterator* enumerationCache)
     74inline JSPropertyNameIterator::JSPropertyNameIterator(ExecState* exec, JSObject* object, PassRefPtr<PropertyNameArrayData> propertyNameArrayData)
     75    : JSCell(exec->globalData().propertyNameIteratorStructure.get())
     76    , m_object(object)
     77    , m_data(propertyNameArrayData)
     78    , m_position(m_data->begin())
     79    , m_end(m_data->end())
    8580{
    86     ASSERT(!isDictionary());
    87     m_enumerationCache = enumerationCache;
     81}
     82
     83inline JSPropertyNameIterator* JSPropertyNameIterator::create(ExecState* exec, JSValue v)
     84{
     85    if (v.isUndefinedOrNull())
     86        return new (exec) JSPropertyNameIterator(exec);
     87
     88    JSObject* o = v.toObject(exec);
     89    PropertyNameArray propertyNames(exec);
     90    o->getPropertyNames(exec, propertyNames);
     91    return new (exec) JSPropertyNameIterator(exec, o, propertyNames.releaseData());
     92}
     93
     94inline JSValue JSPropertyNameIterator::next(ExecState* exec)
     95{
     96    if (m_position == m_end)
     97        return JSValue();
     98
     99    if (m_data->cachedStructure() == m_object->structure() && m_data->cachedPrototypeChain() == m_object->structure()->prototypeChain(exec))
     100        return jsOwnedString(exec, (*m_position++).ustring());
     101
     102    do {
     103        if (m_object->hasProperty(exec, *m_position))
     104            return jsOwnedString(exec, (*m_position++).ustring());
     105        m_position++;
     106    } while (m_position != m_end);
     107
     108    return JSValue();
    88109}
    89110
Note: See TracChangeset for help on using the changeset viewer.