+class AddParentForConsoleStartFunctor {
+public:
+ AddParentForConsoleStartFunctor(ExecState* exec, RefPtr<ProfileNode>& head, RefPtr<ProfileNode>& currentNode)
+ : m_exec(exec)
+ , m_hasSkippedFirstFrame(false)
+ , m_foundParent(false)
+ , m_head(head)
+ , m_currentNode(currentNode)
+ {
+ }
+
+ bool foundParent() const { return m_foundParent; }
+
+ StackVisitor::Status operator()(StackVisitor& visitor)
+ {
+ if (!m_hasSkippedFirstFrame) {
+ m_hasSkippedFirstFrame = true;
+ return StackVisitor::Continue;
+ }
+
+ unsigned line = 0;
+ unsigned column = 0;
+ visitor->computeLineAndColumn(line, column);
+ m_currentNode = ProfileNode::create(m_exec, LegacyProfiler::createCallIdentifier(m_exec, visitor->callee(), visitor->sourceURL(), line, column), m_head.get(), m_head.get());
+ m_head->insertNode(m_currentNode.get());
+
+ m_foundParent = true;
+ return StackVisitor::Done;
+ }
+
+private:
+ ExecState* m_exec;
+ bool m_hasSkippedFirstFrame;
+ bool m_foundParent;
+ RefPtr<ProfileNode>& m_head;
+ RefPtr<ProfileNode>& m_currentNode;
+};
+