Changeset 195431 in webkit


Ignore:
Timestamp:
Jan 21, 2016 6:05:28 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[INTL] Implement Array.prototype.toLocaleString in ECMA-402
https://bugs.webkit.org/show_bug.cgi?id=147614

Patch by Andy VanWagoner <andy@instructure.com> on 2016-01-21
Reviewed by Benjamin Poulain.

Source/JavaScriptCore:

The primary changes in the ECMA-402 version, and the existing implementation
are passing the arguments on to each element's toLocaleString call, and
missing/undefined/null elements become empty string instead of being skipped.

  • runtime/ArrayPrototype.cpp:

(JSC::arrayProtoFuncToLocaleString):

LayoutTests:

  • js/array-toLocaleString-expected.txt: Added.
  • js/array-toLocaleString.html: Added.
  • js/script-tests/array-toLocaleString.js: Added.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r195428 r195431  
     12016-01-21  Andy VanWagoner  <andy@instructure.com>
     2
     3        [INTL] Implement Array.prototype.toLocaleString in ECMA-402
     4        https://bugs.webkit.org/show_bug.cgi?id=147614
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        * js/array-toLocaleString-expected.txt: Added.
     9        * js/array-toLocaleString.html: Added.
     10        * js/script-tests/array-toLocaleString.js: Added.
     11
    1122016-01-21  Ryan Haddad  <ryanhaddad@apple.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r195425 r195431  
     12016-01-21  Andy VanWagoner  <andy@instructure.com>
     2
     3        [INTL] Implement Array.prototype.toLocaleString in ECMA-402
     4        https://bugs.webkit.org/show_bug.cgi?id=147614
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        The primary changes in the ECMA-402 version, and the existing implementation
     9        are passing the arguments on to each element's toLocaleString call, and
     10        missing/undefined/null elements become empty string instead of being skipped.
     11
     12        * runtime/ArrayPrototype.cpp:
     13        (JSC::arrayProtoFuncToLocaleString):
     14
    1152016-01-21  Per Arne Vollan  <peavo@outlook.com>
    216
  • trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp

    r194310 r195431  
    337337        return JSValue::encode(jsUndefined());
    338338
     339#if ENABLE(INTL)
     340    ArgList arguments(exec);
     341    for (unsigned i = 0; i < length; ++i) {
     342        JSValue element = thisObject->getIndex(exec, i);
     343        if (exec->hadException())
     344            return JSValue::encode(jsUndefined());
     345        if (element.isUndefinedOrNull())
     346            element = jsEmptyString(exec);
     347        else {
     348            JSValue conversionFunction = element.get(exec, exec->propertyNames().toLocaleString);
     349            if (exec->hadException())
     350                return JSValue::encode(jsUndefined());
     351            CallData callData;
     352            CallType callType = getCallData(conversionFunction, callData);
     353            if (callType != CallTypeNone) {
     354                element = call(exec, conversionFunction, callType, callData, element, arguments);
     355                if (exec->hadException())
     356                return JSValue::encode(jsUndefined());
     357            }
     358        }
     359        stringJoiner.append(*exec, element);
     360        if (exec->hadException())
     361            return JSValue::encode(jsUndefined());
     362    }
     363#else // !ENABLE(INTL)
    339364    for (unsigned i = 0; i < length; ++i) {
    340365        JSValue element = thisObject->getIndex(exec, i);
     
    357382            return JSValue::encode(jsUndefined());
    358383    }
     384#endif // !ENABLE(INTL)
    359385
    360386    return JSValue::encode(stringJoiner.join(*exec));
Note: See TracChangeset for help on using the changeset viewer.