String StackVisitor::Frame::functionName() const { String traceLine; switch (codeType()) { case CodeType::Wasm: traceLine = makeString(m_wasmFunctionIndexOrName); break; case CodeType::Eval: traceLine = "eval code"_s; break; case CodeType::Module: traceLine = "module code"_s; break; case CodeType::Native: { JSCell* callee = this->callee().asCell(); if (callee) traceLine = getCalculatedDisplayName(callFrame()->vm(), jsCast<JSObject*>(callee)).impl(); break; } case CodeType::Function: traceLine = getCalculatedDisplayName(callFrame()->vm(), jsCast<JSObject*>(this->callee().asCell())).impl(); break; case CodeType::Global: traceLine = "global code"_s; break; } return traceLine.isNull() ? emptyString() : traceLine; }
String StackVisitor::Frame::functionName() { String traceLine; JSObject* callee = this->callee(); switch (codeType()) { case CodeType::Eval: traceLine = ASCIILiteral("eval code"); break; case CodeType::Module: traceLine = ASCIILiteral("module code"); break; case CodeType::Native: if (callee) traceLine = getCalculatedDisplayName(callFrame(), callee).impl(); break; case CodeType::Function: traceLine = getCalculatedDisplayName(callFrame(), callee).impl(); break; case CodeType::Global: traceLine = ASCIILiteral("global code"); break; } return traceLine.isNull() ? emptyString() : traceLine; }
CallIdentifier createCallIdentifierFromFunctionImp(ExecState* exec, JSObject* function, const String& defaultSourceURL, int defaultLineNumber) { const String& name = getCalculatedDisplayName(exec, function); JSFunction* jsFunction = jsDynamicCast<JSFunction*>(function); if (jsFunction && !jsFunction->isHostFunction()) return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, jsFunction->jsExecutable()->sourceURL(), jsFunction->jsExecutable()->lineNo()); return CallIdentifier(name.isEmpty() ? AnonymousFunction : name, defaultSourceURL, defaultLineNumber); }
String DebuggerCallFrame::functionName() const { ASSERT(isValid()); if (!isValid()) return String(); JSObject* function = m_callFrame->callee(); if (!function) return String(); return getCalculatedDisplayName(m_callFrame, function); }
String DebuggerCallFrame::calculatedFunctionName() const { if (!m_callFrame->codeBlock()) return String(); JSObject* function = m_callFrame->callee(); if (!function) return String(); return getCalculatedDisplayName(m_callFrame, function); }
String CallFrame::friendlyFunctionName() { CodeBlock* codeBlock = this->codeBlock(); if (!codeBlock) return emptyString(); switch (codeBlock->codeType()) { case EvalCode: return ASCIILiteral("eval code"); case ModuleCode: return ASCIILiteral("module code"); case GlobalCode: return ASCIILiteral("global code"); case FunctionCode: if (callee()) return getCalculatedDisplayName(vm(), callee()); return emptyString(); } ASSERT_NOT_REACHED(); return emptyString(); }