Пример #1
0
void JsrtDebugUtils::AddFileNameOrScriptTypeToObject(Js::DynamicObject* object, Js::Utf8SourceInfo* utf8SourceInfo)
{
    if (utf8SourceInfo->IsDynamic())
    {
        AssertMsg(utf8SourceInfo->GetSourceContextInfo()->url == nullptr, "How come dynamic code have a url?");

        Js::FunctionBody* anyFunctionBody = utf8SourceInfo->GetAnyParsedFunction();

        Assert(anyFunctionBody != nullptr);

        LPCWSTR sourceName = anyFunctionBody->GetSourceName();

        JsrtDebugUtils::AddPropertyToObject(object, JsrtDebugPropertyId::scriptType, sourceName, wcslen(sourceName), utf8SourceInfo->GetScriptContext());
    }
    else
    {
        // url can be nullptr if JsParseScript/JsRunScript didn't passed any
        const char16* url = utf8SourceInfo->GetSourceContextInfo()->url == nullptr ? _u("") : utf8SourceInfo->GetSourceContextInfo()->url;
        JsrtDebugUtils::AddPropertyToObject(object, JsrtDebugPropertyId::fileName, url, wcslen(url), utf8SourceInfo->GetScriptContext());
    }
}