#define Local_h
#include "Handle.h"
-#include "JSGlobalData.h"
+#include "VM.h"
/*
A strongly referenced handle whose lifetime is temporary, limited to a given
public:
typedef typename Handle<T>::ExternalType ExternalType;
- Local(JSGlobalData&, ExternalType = ExternalType());
- Local(JSGlobalData&, Handle<T>);
+ Local(VM&, ExternalType = ExternalType());
+ Local(VM&, Handle<T>);
Local(const Local<T>&); // Adopting constructor. Used to return a Local to a calling function.
Local& operator=(ExternalType);
void set(ExternalType);
};
-template <typename T> inline Local<T>::Local(JSGlobalData& globalData, ExternalType value)
- : Handle<T>(globalData.allocateLocalHandle())
+template <typename T> inline Local<T>::Local(VM& vm, ExternalType value)
+ : Handle<T>(vm.heap.handleStack()->push())
{
set(value);
}
-template <typename T> inline Local<T>::Local(JSGlobalData& globalData, Handle<T> other)
- : Handle<T>(globalData.allocateLocalHandle())
+template <typename T> inline Local<T>::Local(VM& vm, Handle<T> other)
+ : Handle<T>(vm.heap.handleStack()->push())
{
set(other.get());
}
template <typename T> inline void Local<T>::set(ExternalType externalType)
{
ASSERT(slot());
- ASSERT(!HandleTypes<T>::toJSValue(externalType) || !HandleTypes<T>::toJSValue(externalType).isCell() || Heap::isMarked(HandleTypes<T>::toJSValue(externalType).asCell()));
*slot() = externalType;
}
template <typename T, unsigned inlineCapacity = 0> class LocalStack {
typedef typename Handle<T>::ExternalType ExternalType;
public:
- LocalStack(JSGlobalData& globalData)
- : m_globalData(&globalData)
+ LocalStack(VM& vm)
+ : m_vm(vm)
, m_count(0)
{
}
void push(ExternalType value)
{
if (m_count == m_stack.size())
- m_stack.append(Local<T>(*m_globalData, value));
+ m_stack.append(Local<T>(m_vm, value));
else
m_stack[m_count] = value;
m_count++;
unsigned size() const { return m_count; }
private:
- RefPtr<JSGlobalData> m_globalData;
+ VM& m_vm;
Vector<Local<T>, inlineCapacity> m_stack;
unsigned m_count;
};