JavaScriptCallFrame.cpp [plain text]
#include "config.h"
#if ENABLE(JAVASCRIPT_DEBUGGER)
#include "JavaScriptCallFrame.h"
#include "JSDOMBinding.h"
#include "JSDOMWindowBase.h"
#include <debugger/DebuggerCallFrame.h>
#include <runtime/Completion.h>
#include <runtime/JSCJSValue.h>
#include <runtime/JSGlobalObject.h>
#include <runtime/JSLock.h>
#include <runtime/JSObject.h>
#include <wtf/text/WTFString.h>
using namespace JSC;
namespace WebCore {
JavaScriptCallFrame::JavaScriptCallFrame(const DebuggerCallFrame& debuggerCallFrame, PassRefPtr<JavaScriptCallFrame> caller, intptr_t sourceID, const TextPosition& textPosition)
: m_debuggerCallFrame(debuggerCallFrame)
, m_caller(caller)
, m_sourceID(sourceID)
, m_textPosition(textPosition)
, m_isValid(true)
{
}
JavaScriptCallFrame* JavaScriptCallFrame::caller()
{
return m_caller.get();
}
JSC::JSScope* JavaScriptCallFrame::scopeChain() const
{
ASSERT(m_isValid);
if (!m_isValid)
return 0;
return m_debuggerCallFrame.scope();
}
JSC::JSGlobalObject* JavaScriptCallFrame::dynamicGlobalObject() const
{
ASSERT(m_isValid);
if (!m_isValid)
return 0;
return m_debuggerCallFrame.dynamicGlobalObject();
}
String JavaScriptCallFrame::functionName() const
{
ASSERT(m_isValid);
if (!m_isValid)
return String();
String functionName = m_debuggerCallFrame.calculatedFunctionName();
if (functionName.isEmpty())
return String();
return functionName;
}
DebuggerCallFrame::Type JavaScriptCallFrame::type() const
{
ASSERT(m_isValid);
if (!m_isValid)
return DebuggerCallFrame::ProgramType;
return m_debuggerCallFrame.type();
}
JSObject* JavaScriptCallFrame::thisObject() const
{
ASSERT(m_isValid);
if (!m_isValid)
return 0;
return m_debuggerCallFrame.thisObject();
}
ExecState* JavaScriptCallFrame::exec() const
{
ASSERT(m_isValid);
if (!m_isValid)
return 0;
return m_debuggerCallFrame.callFrame();
}
JSValue JavaScriptCallFrame::evaluate(const String& script, JSValue& exception) const
{
ASSERT(m_isValid);
if (!m_isValid)
return jsNull();
JSLockHolder lock(m_debuggerCallFrame.callFrame());
return m_debuggerCallFrame.evaluate(script, exception);
}
}
#endif // ENABLE(JAVASCRIPT_DEBUGGER)