Ignore:
Timestamp:
Jun 22, 2009, 10:44:55 PM (16 years ago)
Author:
[email protected]
Message:

Bug 26640: JSON.stringify needs to special case Boolean objects
<https://bugs.webkit.org/show_bug.cgi?id=26640>

Reviewed by Alexey Proskuryakov.

Add special case handling of the Boolean object so we match current
ES5 errata.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSONObject.cpp

    r44968 r44974  
    2727#include "JSONObject.h"
    2828
     29#include "BooleanObject.h"
    2930#include "Error.h"
    3031#include "ExceptionHelpers.h"
     
    120121// ------------------------------ helper functions --------------------------------
    121122
    122 static inline JSValue unwrapNumberOrString(JSValue value)
     123static inline JSValue unwrapBoxedPrimitive(JSValue value)
    123124{
    124125    if (!value.isObject())
    125126        return value;
    126     if (!asObject(value)->inherits(&NumberObject::info) && !asObject(value)->inherits(&StringObject::info))
     127    if (!asObject(value)->inherits(&NumberObject::info) && !asObject(value)->inherits(&StringObject::info) && !asObject(value)->inherits(&BooleanObject::info))
    127128        return value;
    128129    return static_cast<JSWrapperObject*>(asObject(value))->internalValue();
     
    131132static inline UString gap(JSValue space)
    132133{
    133     space = unwrapNumberOrString(space);
     134    space = unwrapBoxedPrimitive(space);
    134135
    135136    // If the space value is a number, create a gap string with that number of spaces.
     
    356357    }
    357358
     359    value = unwrapBoxedPrimitive(value);
     360
    358361    if (value.isBoolean()) {
    359362        builder.append(value.getBoolean() ? "true" : "false");
    360363        return StringifySucceeded;
    361364    }
    362 
    363     value = unwrapNumberOrString(value);
    364365
    365366    UString stringValue;
Note: See TracChangeset for help on using the changeset viewer.