Changeset 42478 in webkit for trunk/JavaScriptCore/runtime


Ignore:
Timestamp:
Apr 13, 2009, 11:24:43 PM (16 years ago)
Author:
[email protected]
Message:

BUG 25171: It should be possible to manually set the name of an anonymous function
<https://bugs.webkit.org/show_bug.cgi?id=25171>

Submitted by Francisco Tolmasky <[email protected]>
Reviewed by Oliver Hunt.

This change adds the displayName property to functions, which when set overrides the
normal name when appearing in the console.

Location:
trunk/JavaScriptCore/runtime
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/CommonIdentifiers.h

    r38138 r42478  
    6464    macro(toString) \
    6565    macro(UTC) \
    66     macro(valueOf)
     66    macro(valueOf) \
     67    macro(displayName)
    6768
    6869namespace JSC {
  • trunk/JavaScriptCore/runtime/InternalFunction.cpp

    r38440 r42478  
    4949}
    5050
     51const UString& InternalFunction::displayName(JSGlobalData* globalData)
     52{
     53    JSValuePtr displayName = getDirect(globalData->propertyNames->displayName);
     54   
     55    if (displayName)
     56        return asString(displayName)->value();
     57   
     58    return UString::null();
     59}
     60
     61const UString& InternalFunction::calculatedDisplayName(JSGlobalData* globalData)
     62{
     63    const UString& explicitName = displayName(globalData);
     64   
     65    if (!explicitName.isEmpty())
     66        return explicitName;
     67   
     68    return name(globalData);
     69}
     70
    5171} // namespace JSC
  • trunk/JavaScriptCore/runtime/InternalFunction.h

    r39670 r42478  
    3838
    3939        const UString& name(JSGlobalData*);
     40        const UString& displayName(JSGlobalData*);
     41        const UString& calculatedDisplayName(JSGlobalData*);
    4042
    4143        static PassRefPtr<Structure> createStructure(JSValuePtr proto)
Note: See TracChangeset for help on using the changeset viewer.