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
            {
Example #2
0
    JavascriptString* CharStringCache::GetStringForCharA(char c)
    {
        AssertMsg(JavascriptString::IsASCII7BitChar(c), "GetStringForCharA must be called with ASCII 7bit chars only");

        PropertyString * str = charStringCacheA[(int)c];
        if (str == nullptr)
        {
            PropertyRecord const * propertyRecord;
            char16 wc = c;
            JavascriptLibrary * javascriptLibrary = JavascriptLibrary::FromCharStringCache(this);
            javascriptLibrary->GetScriptContext()->GetOrAddPropertyRecord(&wc, 1, &propertyRecord);
            str = javascriptLibrary->CreatePropertyString(propertyRecord);
            charStringCacheA[(int)c] = str;
        }

        return str;
    }
Example #3
0
 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)));
         }
     }