DebuggerCallFrame.cpp [plain text]
#include "config.h"
#include "DebuggerCallFrame.h"
#include "JSFunction.h"
#include "CodeBlock.h"
#include "Interpreter.h"
#include "Operations.h"
#include "Parser.h"
namespace JSC {
String DebuggerCallFrame::functionName() const
{
if (!m_callFrame->codeBlock())
return String();
if (!m_callFrame->callee())
return String();
JSObject* function = m_callFrame->callee();
if (!function || !function->inherits(&JSFunction::s_info))
return String();
return jsCast<JSFunction*>(function)->name(m_callFrame);
}
String DebuggerCallFrame::calculatedFunctionName() const
{
if (!m_callFrame->codeBlock())
return String();
JSObject* function = m_callFrame->callee();
if (!function)
return String();
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 String& script, JSValue& exception) const
{
if (!m_callFrame->codeBlock())
return JSValue();
VM& vm = m_callFrame->vm();
EvalExecutable* eval = EvalExecutable::create(m_callFrame, m_callFrame->codeBlock()->unlinkedCodeBlock()->codeCacheForEval(), makeSource(script), m_callFrame->codeBlock()->isStrictMode());
if (vm.exception) {
exception = vm.exception;
vm.exception = JSValue();
}
JSValue result = vm.interpreter->execute(eval, m_callFrame, thisObject(), m_callFrame->scope());
if (vm.exception) {
exception = vm.exception;
vm.exception = JSValue();
}
ASSERT(result);
return result;
}
}