ScriptCallStack.cpp [plain text]
#include "config.h"
#include "ScriptCallStack.h"
#include "InspectorValues.h"
namespace Inspector {
Ref<ScriptCallStack> ScriptCallStack::create()
{
return adoptRef(*new ScriptCallStack);
}
Ref<ScriptCallStack> ScriptCallStack::create(Vector<ScriptCallFrame>& frames)
{
return adoptRef(*new ScriptCallStack(frames));
}
ScriptCallStack::ScriptCallStack()
{
}
ScriptCallStack::ScriptCallStack(Vector<ScriptCallFrame>& frames)
{
m_frames.swap(frames);
}
ScriptCallStack::~ScriptCallStack()
{
}
const ScriptCallFrame& ScriptCallStack::at(size_t index) const
{
ASSERT(m_frames.size() > index);
return m_frames[index];
}
size_t ScriptCallStack::size() const
{
return m_frames.size();
}
const ScriptCallFrame* ScriptCallStack::firstNonNativeCallFrame() const
{
if (!m_frames.size())
return nullptr;
for (size_t i = 0; i < m_frames.size(); ++i) {
const ScriptCallFrame& frame = m_frames[i];
if (frame.sourceURL() != "[native code]")
return &frame;
}
return nullptr;
}
void ScriptCallStack::append(const ScriptCallFrame& frame)
{
m_frames.append(frame);
}
bool ScriptCallStack::isEqual(ScriptCallStack* o) const
{
if (!o)
return false;
size_t frameCount = o->m_frames.size();
if (frameCount != m_frames.size())
return false;
for (size_t i = 0; i < frameCount; ++i) {
if (!m_frames[i].isEqual(o->m_frames[i]))
return false;
}
return true;
}
Ref<Inspector::Protocol::Console::StackTrace> ScriptCallStack::buildInspectorArray() const
{
auto frames = Inspector::Protocol::Console::StackTrace::create();
for (size_t i = 0; i < m_frames.size(); i++)
frames->addItem(m_frames.at(i).buildInspectorObject());
return frames;
}
}