JSPropertyNameIterator.h [plain text]
#ifndef JSPropertyNameIterator_h
#define JSPropertyNameIterator_h
#include "JSObject.h"
#include "JSString.h"
#include "Operations.h"
#include "PropertyNameArray.h"
namespace JSC {
class Identifier;
class JSObject;
class LLIntOffsetsExtractor;
class JSPropertyNameIterator : public JSCell {
friend class JIT;
public:
typedef JSCell Base;
static JSPropertyNameIterator* create(ExecState*, JSObject*);
static const bool needsDestruction = true;
static const bool hasImmortalStructure = true;
static void destroy(JSCell*);
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(CompoundType, OverridesVisitChildren), &s_info);
}
static void visitChildren(JSCell*, SlotVisitor&);
JSValue get(ExecState*, JSObject*, size_t i);
size_t size() { return m_jsStringsSize; }
void setCachedStructure(VM& vm, Structure* structure)
{
ASSERT(!m_cachedStructure);
ASSERT(structure);
m_cachedStructure.set(vm, this, structure);
}
Structure* cachedStructure() { return m_cachedStructure.get(); }
void setCachedPrototypeChain(VM& vm, StructureChain* cachedPrototypeChain) { m_cachedPrototypeChain.set(vm, this, cachedPrototypeChain); }
StructureChain* cachedPrototypeChain() { return m_cachedPrototypeChain.get(); }
static JS_EXPORTDATA const ClassInfo s_info;
protected:
void finishCreation(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, JSObject* object)
{
Base::finishCreation(exec->vm());
PropertyNameArrayData::PropertyNameVector& propertyNameVector = propertyNameArrayData->propertyNameVector();
for (size_t i = 0; i < m_jsStringsSize; ++i)
m_jsStrings[i].set(exec->vm(), this, jsOwnedString(exec, propertyNameVector[i].string()));
m_cachedStructureInlineCapacity = object->structure()->inlineCapacity();
}
private:
friend class LLIntOffsetsExtractor;
JSPropertyNameIterator(ExecState*, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlot);
WriteBarrier<Structure> m_cachedStructure;
WriteBarrier<StructureChain> m_cachedPrototypeChain;
uint32_t m_numCacheableSlots;
uint32_t m_jsStringsSize;
unsigned m_cachedStructureInlineCapacity;
OwnArrayPtr<WriteBarrier<Unknown> > m_jsStrings;
};
ALWAYS_INLINE JSPropertyNameIterator* Register::propertyNameIterator() const
{
return jsCast<JSPropertyNameIterator*>(jsValue().asCell());
}
inline JSPropertyNameIterator* StructureRareData::enumerationCache()
{
return m_enumerationCache.get();
}
inline void StructureRareData::setEnumerationCache(VM& vm, const Structure* owner, JSPropertyNameIterator* value)
{
m_enumerationCache.set(vm, owner, value);
}
}
#endif // JSPropertyNameIterator_h