#ifndef JSNameScope_h
#define JSNameScope_h
#include "JSGlobalObject.h"
#include "JSVariableObject.h"
namespace JSC {
class JSNameScope : public JSVariableObject {
public:
typedef JSVariableObject Base;
static JSNameScope* create(ExecState* exec, const Identifier& identifier, JSValue value, unsigned attributes)
{
VM& vm = exec->vm();
JSNameScope* scopeObject = new (NotNull, allocateCell<JSNameScope>(vm.heap)) JSNameScope(vm, exec->lexicalGlobalObject(), exec->scope());
scopeObject->finishCreation(vm, identifier, value, attributes);
return scopeObject;
}
static JSNameScope* create(VM& vm, JSGlobalObject* globalObject, const Identifier& identifier, JSValue value, unsigned attributes, JSScope* next)
{
JSNameScope* scopeObject = new (NotNull, allocateCell<JSNameScope>(vm.heap)) JSNameScope(vm, globalObject, next);
scopeObject->finishCreation(vm, identifier, value, attributes);
return scopeObject;
}
static void visitChildren(JSCell*, SlotVisitor&);
static JSValue toThis(JSCell*, ExecState*, ECMAMode);
static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue proto) { return Structure::create(vm, globalObject, proto, TypeInfo(NameScopeObjectType, StructureFlags), info()); }
DECLARE_INFO;
protected:
void finishCreation(VM& vm, const Identifier& identifier, JSValue value, unsigned attributes)
{
Base::finishCreation(vm);
m_registerStore.set(vm, this, value);
symbolTable()->add(identifier.impl(), SymbolTableEntry(-1, attributes));
}
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | Base::StructureFlags;
private:
JSNameScope(VM& vm, JSGlobalObject* globalObject, JSScope* next)
: Base(
vm,
globalObject->nameScopeStructure(),
reinterpret_cast<Register*>(&m_registerStore + 1),
next
)
{
}
WriteBarrier<Unknown> m_registerStore;
};
}
#endif // JSNameScope_h