Пример #1
0
    Js::FunctionBody* TTDebuggerSourceLocation::ResolveAssociatedSourceInfo(Js::ScriptContext* ctx) const
    {
        Js::FunctionBody* resBody = ctx->TTDContextInfo->FindFunctionBodyByFileName(this->m_sourceFile);

        while(true)
        {
            for(uint32 i = 0; i < resBody->GetNestedCount(); ++i)
            {
                Js::ParseableFunctionInfo* ipfi = resBody->GetNestedFunc(i)->EnsureDeserialized();
                Js::FunctionBody* ifb = JsSupport::ForceAndGetFunctionBody(ipfi);

                if(this->m_functionLine == ifb->GetLineNumber() && this->m_functionColumn == ifb->GetColumnNumber())
                {
                    return ifb;
                }

                //if it starts on a larger line or if same line but larger column then we don't contain the target
                AssertMsg(ifb->GetLineNumber() < this->m_functionLine || (ifb->GetLineNumber() == this->m_functionLine && ifb->GetColumnNumber() < this->m_functionColumn), "We went to far but didn't find our function??");

                uint32 endLine = UINT32_MAX;
                uint32 endColumn = UINT32_MAX;
                if(i + 1 < resBody->GetNestedCount())
                {
                    Js::ParseableFunctionInfo* ipfinext = resBody->GetNestedFunc(i + 1)->EnsureDeserialized();
                    Js::FunctionBody* ifbnext = JsSupport::ForceAndGetFunctionBody(ipfinext);

                    endLine = ifbnext->GetLineNumber();
                    endColumn = ifbnext->GetColumnNumber();
                }

                if(endLine > this->m_functionLine || (endLine == this->m_functionLine && endColumn > this->m_functionColumn))
                {
                    resBody = ifb;
                    break;
                }
            }
        }

        AssertMsg(false, "We should never get here!!!");
        return nullptr;
    }