DebuggerCallFrame.cpp [plain text]
#include "config.h"
#include "DebuggerCallFrame.h"
#include "JSFunction.h"
#include "CodeBlock.h"
#include "Interpreter.h"
#include "Parser.h"
namespace JSC {
const UString* DebuggerCallFrame::functionName() const
{
if (!m_callFrame->codeBlock())
return 0;
if (!m_callFrame->callee())
return 0;
JSObject* function = m_callFrame->callee();
if (!function || !function->inherits(&JSFunction::s_info))
return 0;
return &jsCast<JSFunction*>(function)->name(m_callFrame);
}
UString DebuggerCallFrame::calculatedFunctionName() const
{
if (!m_callFrame->codeBlock())
return UString();
JSObject* function = m_callFrame->callee();
if (!function)
return UString();
return getCalculatedDisplayName(m_callFrame, function);
}
DebuggerCallFrame::Type DebuggerCallFrame::type() const
{
if (m_callFrame->callee())
return FunctionType;
return ProgramType;
}
JSObject* DebuggerCallFrame::thisObject() const
{
CodeBlock* codeBlock = m_callFrame->codeBlock();
if (!codeBlock)
return 0;
JSValue thisValue = m_callFrame->uncheckedR(codeBlock->thisRegister()).jsValue();
if (!thisValue.isObject())
return 0;
return asObject(thisValue);
}
JSValue DebuggerCallFrame::evaluate(const UString& script, JSValue& exception) const
{
if (!m_callFrame->codeBlock())
return JSValue();
JSGlobalData& globalData = m_callFrame->globalData();
EvalExecutable* eval = EvalExecutable::create(m_callFrame, makeSource(script), m_callFrame->codeBlock()->isStrictMode());
if (globalData.exception) {
exception = globalData.exception;
globalData.exception = JSValue();
}
JSValue result = globalData.interpreter->execute(eval, m_callFrame, thisObject(), m_callFrame->scopeChain());
if (globalData.exception) {
exception = globalData.exception;
globalData.exception = JSValue();
}
ASSERT(result);
return result;
}
}