JavascriptString * RuntimeFunction::EnsureSourceString() { JavascriptLibrary* library = this->GetLibrary(); ScriptContext * scriptContext = library->GetScriptContext(); JavascriptString * retStr = nullptr; if (this->functionNameId == nullptr) { retStr = library->GetFunctionDisplayString(); this->functionNameId = retStr; } else { if (TaggedInt::Is(this->functionNameId)) { if (this->GetTypeHandler()->IsDeferredTypeHandler()) { JavascriptString* functionName = nullptr; DebugOnly(bool status = ) this->GetFunctionName(&functionName); Assert(status); this->SetPropertyWithAttributes(PropertyIds::name, functionName, PropertyConfigurable, nullptr); } // This has a side-effect where any other code (such as debugger) that uses functionNameId value will now get the value like "function foo() { native code }" // instead of just "foo". Alternative ways will need to be devised; if it's not desirable to use this full display name value in those cases. retStr = GetNativeFunctionDisplayString(scriptContext, scriptContext->GetPropertyString(TaggedInt::ToInt32(this->functionNameId))); this->functionNameId = retStr; } else {
Var RuntimeFunction::EnsureSourceString() { JavascriptLibrary* library = this->GetLibrary(); ScriptContext * scriptContext = library->GetScriptContext(); if (this->functionNameId == nullptr) { this->functionNameId = library->GetFunctionDisplayString(); } else { if (TaggedInt::Is(this->functionNameId)) { if (this->GetScriptContext()->GetConfig()->IsES6FunctionNameEnabled() && this->GetTypeHandler()->IsDeferredTypeHandler()) { JavascriptString* functionName = nullptr; DebugOnly(bool status = ) this->GetFunctionName(&functionName); Assert(status); this->SetPropertyWithAttributes(PropertyIds::name, functionName, PropertyConfigurable, nullptr); } this->functionNameId = GetNativeFunctionDisplayString(scriptContext, scriptContext->GetPropertyString(TaggedInt::ToInt32(this->functionNameId))); } }