#pragma once
#include "JSGlobalObject.h"
#include "JSObject.h"
#include "JSScope.h"
namespace JSC {
class JSGlobalObject;
class LLIntOffsetsExtractor;
class JSCallee : public JSNonFinalObject {
friend class JIT;
#if ENABLE(DFG_JIT)
friend class DFG::SpeculativeJIT;
friend class DFG::JITCompiler;
#endif
friend class VM;
public:
using Base = JSNonFinalObject;
static constexpr unsigned StructureFlags = Base::StructureFlags | ImplementsHasInstance | ImplementsDefaultHasInstance;
template<typename CellType, SubspaceAccess>
static IsoSubspace* subspaceFor(VM& vm)
{
return &vm.calleeSpace;
}
static JSCallee* create(VM& vm, JSGlobalObject* globalObject, JSScope* scope)
{
JSCallee* callee = new (NotNull, allocateCell<JSCallee>(vm.heap)) JSCallee(vm, scope, globalObject->calleeStructure());
callee->finishCreation(vm);
return callee;
}
JSScope* scope()
{
return m_scope.get();
}
JSScope* scopeUnchecked()
{
return m_scope.get();
}
void setScope(VM& vm, JSScope* scope)
{
m_scope.set(vm, this, scope);
}
DECLARE_EXPORT_INFO;
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
ASSERT(globalObject);
return Structure::create(vm, globalObject, prototype, TypeInfo(JSCalleeType, StructureFlags), info());
}
static inline ptrdiff_t offsetOfScopeChain()
{
return OBJECT_OFFSETOF(JSCallee, m_scope);
}
protected:
JS_EXPORT_PRIVATE JSCallee(VM&, JSGlobalObject*, Structure*);
JSCallee(VM&, JSScope*, Structure*);
void finishCreation(VM&);
using Base::finishCreation;
static void visitChildren(JSCell*, SlotVisitor&);
private:
friend class LLIntOffsetsExtractor;
WriteBarrier<JSScope> m_scope;
};
}