<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[193493] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/193493">193493</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-12-04 17:14:03 -0800 (Fri, 04 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[INTL] Implement Number.prototype.toLocaleString in ECMA-402
https://bugs.webkit.org/show_bug.cgi?id=147610
Patch by Andy VanWagoner <thetalecrafter@gmail.com> on 2015-12-04
Reviewed by Benjamin Poulain.
Source/JavaScriptCore:
Add toLocaleString in builtin JavaScript that delegates formatting to Intl.NumberFormat.
Keep exisiting native implementation for use if INTL flag is disabled.
* CMakeLists.txt: Add NumberPrototype.js.
* DerivedSources.make: Add NumberPrototype.js.
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/NumberPrototype.js: Added.
(toLocaleString):
* runtime/CommonIdentifiers.h: Add private names for Intl constructors.
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init): Expose Intl constructors to builtin js.
* runtime/NumberPrototype.cpp:
(JSC::NumberPrototype::finishCreation): Replace toLocaleString implementation.
LayoutTests:
Add tests for ECMA-402 Number.prototype.toLocaleString.
Since NumberFormat is not fully implemented, don't test locale-specific behavior yet.
* js/number-toLocaleString-expected.txt: Added.
* js/number-toLocaleString.html: Added.
* js/script-tests/number-toLocaleString.js: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreDerivedSourcesmake">trunk/Source/JavaScriptCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeNumberPrototypecpp">trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsnumbertoLocaleStringexpectedtxt">trunk/LayoutTests/js/number-toLocaleString-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsnumbertoLocaleStringhtml">trunk/LayoutTests/js/number-toLocaleString.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsnumbertoLocaleStringjs">trunk/LayoutTests/js/script-tests/number-toLocaleString.js</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsNumberPrototypejs">trunk/Source/JavaScriptCore/builtins/NumberPrototype.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (193492 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-12-05 01:06:50 UTC (rev 193492)
+++ trunk/LayoutTests/ChangeLog        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-12-04 Andy VanWagoner <thetalecrafter@gmail.com>
+
+ [INTL] Implement Number.prototype.toLocaleString in ECMA-402
+ https://bugs.webkit.org/show_bug.cgi?id=147610
+
+ Reviewed by Benjamin Poulain.
+
+ Add tests for ECMA-402 Number.prototype.toLocaleString.
+ Since NumberFormat is not fully implemented, don't test locale-specific behavior yet.
+
+ * js/number-toLocaleString-expected.txt: Added.
+ * js/number-toLocaleString.html: Added.
+ * js/script-tests/number-toLocaleString.js: Added.
+
</ins><span class="cx"> 2015-12-04 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> Modern IDB: Flip test expectations around so we only list failures.
</span></span></pre></div>
<a id="trunkLayoutTestsjsnumbertoLocaleStringexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/number-toLocaleString-expected.txt (0 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/number-toLocaleString-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/number-toLocaleString-expected.txt        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -0,0 +1,25 @@
</span><ins>+This test checks the behavior of Number.prototype.toLocaleString as described in the ECMAScript Internationalization API Specification (ECMA-402 2.0).
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Number.prototype.toLocaleString.length is 0
+PASS Object.getOwnPropertyDescriptor(Number.prototype, 'toLocaleString').enumerable is false
+PASS Object.getOwnPropertyDescriptor(Number.prototype, 'toLocaleString').configurable is true
+PASS Object.getOwnPropertyDescriptor(Number.prototype, 'toLocaleString').writable is true
+PASS Number.prototype.toLocaleString.call(0) did not throw exception.
+PASS Number.prototype.toLocaleString.call(NaN) did not throw exception.
+PASS Number.prototype.toLocaleString.call(Infinity) did not throw exception.
+PASS Number.prototype.toLocaleString.call(new Number) did not throw exception.
+PASS Number.prototype.toLocaleString.call() threw exception TypeError: Number.prototype.toLocaleString called on incompatible undefined.
+PASS Number.prototype.toLocaleString.call(undefined) threw exception TypeError: Number.prototype.toLocaleString called on incompatible undefined.
+PASS Number.prototype.toLocaleString.call(null) threw exception TypeError: Number.prototype.toLocaleString called on incompatible object.
+PASS Number.prototype.toLocaleString.call('1') threw exception TypeError: Number.prototype.toLocaleString called on incompatible string.
+PASS Number.prototype.toLocaleString.call([]) threw exception TypeError: Number.prototype.toLocaleString called on incompatible object.
+PASS Number.prototype.toLocaleString.call(Symbol()) threw exception TypeError: Number.prototype.toLocaleString called on incompatible symbol.
+PASS (0).toLocaleString() is "0"
+PASS new Number(1).toLocaleString() is "1"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsnumbertoLocaleStringhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/number-toLocaleString.html (0 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/number-toLocaleString.html         (rev 0)
+++ trunk/LayoutTests/js/number-toLocaleString.html        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<meta charset="utf-8">
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/number-toLocaleString.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsnumbertoLocaleStringjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/number-toLocaleString.js (0 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/number-toLocaleString.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/number-toLocaleString.js        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -0,0 +1,32 @@
</span><ins>+description("This test checks the behavior of Number.prototype.toLocaleString as described in the ECMAScript Internationalization API Specification (ECMA-402 2.0).");
+
+shouldBe("Number.prototype.toLocaleString.length", "0");
+shouldBeFalse("Object.getOwnPropertyDescriptor(Number.prototype, 'toLocaleString').enumerable");
+shouldBeTrue("Object.getOwnPropertyDescriptor(Number.prototype, 'toLocaleString').configurable");
+shouldBeTrue("Object.getOwnPropertyDescriptor(Number.prototype, 'toLocaleString').writable");
+
+// Test thisNumberValue abrupt completion.
+shouldNotThrow("Number.prototype.toLocaleString.call(0)");
+shouldNotThrow("Number.prototype.toLocaleString.call(NaN)");
+shouldNotThrow("Number.prototype.toLocaleString.call(Infinity)");
+shouldNotThrow("Number.prototype.toLocaleString.call(new Number)");
+shouldThrow("Number.prototype.toLocaleString.call()", "'TypeError: Number.prototype.toLocaleString called on incompatible undefined'");
+shouldThrow("Number.prototype.toLocaleString.call(undefined)", "'TypeError: Number.prototype.toLocaleString called on incompatible undefined'");
+shouldThrow("Number.prototype.toLocaleString.call(null)", "'TypeError: Number.prototype.toLocaleString called on incompatible object'");
+shouldThrow("Number.prototype.toLocaleString.call('1')", "'TypeError: Number.prototype.toLocaleString called on incompatible string'");
+shouldThrow("Number.prototype.toLocaleString.call([])", "'TypeError: Number.prototype.toLocaleString called on incompatible object'");
+shouldThrow("Number.prototype.toLocaleString.call(Symbol())", "'TypeError: Number.prototype.toLocaleString called on incompatible symbol'");
+
+shouldBeEqualToString("(0).toLocaleString()", "0");
+shouldBeEqualToString("new Number(1).toLocaleString()", "1");
+
+// FIXME: Test for NumberFormat behavior once implemented.
+// shouldThrow("(0).toLocaleString('i')");
+// shouldBeEqualToString("Infinity.toLocaleString()", "∞");
+
+// Test that locale parameter is passed through properly.
+// shouldBeEqualToString("(123456.789).toLocaleString('ar')", "١٢٣٤٥٦٫٧٨٩");
+// shouldBeEqualToString("(123456.789).toLocaleString('zh-Hans-CN-u-nu-hanidec')", "一二三,四五六.七八九");
+
+// Test that options parameter is passed through properly.
+// shouldBeEqualToString("(123.456).toLocaleString('en', { maximumSignificantDigits: 3 })", "123");
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (193492 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2015-12-05 01:06:50 UTC (rev 193492)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -1225,6 +1225,7 @@
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/InternalPromiseConstructor.js
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/IteratorPrototype.js
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/ModuleLoaderObject.js
</span><ins>+ ${JAVASCRIPTCORE_DIR}/builtins/NumberPrototype.js
</ins><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/ObjectConstructor.js
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/PromiseConstructor.js
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/PromiseOperations.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (193492 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-12-05 01:06:50 UTC (rev 193492)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2015-12-04 Andy VanWagoner <thetalecrafter@gmail.com>
+
+ [INTL] Implement Number.prototype.toLocaleString in ECMA-402
+ https://bugs.webkit.org/show_bug.cgi?id=147610
+
+ Reviewed by Benjamin Poulain.
+
+ Add toLocaleString in builtin JavaScript that delegates formatting to Intl.NumberFormat.
+ Keep exisiting native implementation for use if INTL flag is disabled.
+
+ * CMakeLists.txt: Add NumberPrototype.js.
+ * DerivedSources.make: Add NumberPrototype.js.
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * builtins/NumberPrototype.js: Added.
+ (toLocaleString):
+ * runtime/CommonIdentifiers.h: Add private names for Intl constructors.
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::init): Expose Intl constructors to builtin js.
+ * runtime/NumberPrototype.cpp:
+ (JSC::NumberPrototype::finishCreation): Replace toLocaleString implementation.
+
</ins><span class="cx"> 2015-12-04 Michael Saboff <msaboff@apple.com>
</span><span class="cx">
</span><span class="cx"> CRASH: CodeBlock::setOptimizationThresholdBasedOnCompilationResult + 567
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/DerivedSources.make (193492 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/DerivedSources.make        2015-12-05 01:06:50 UTC (rev 193492)
+++ trunk/Source/JavaScriptCore/DerivedSources.make        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -90,6 +90,7 @@
</span><span class="cx"> $(JavaScriptCore)/builtins/InternalPromiseConstructor.js \
</span><span class="cx"> $(JavaScriptCore)/builtins/IteratorPrototype.js \
</span><span class="cx"> $(JavaScriptCore)/builtins/ModuleLoaderObject.js \
</span><ins>+ $(JavaScriptCore)/builtins/NumberPrototype.js \
</ins><span class="cx"> $(JavaScriptCore)/builtins/ObjectConstructor.js \
</span><span class="cx"> $(JavaScriptCore)/builtins/PromiseConstructor.js \
</span><span class="cx"> $(JavaScriptCore)/builtins/PromiseOperations.js \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (193492 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-12-05 01:06:50 UTC (rev 193492)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -3606,6 +3606,7 @@
</span><span class="cx">                 A1587D6C1B4DC14100D69849 /* IntlDateTimeFormatPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlDateTimeFormatPrototype.h; sourceTree = "<group>"; };
</span><span class="cx">                 A1587D731B4DC1C600D69849 /* IntlDateTimeFormatConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlDateTimeFormatConstructor.lut.h; sourceTree = "<group>"; };
</span><span class="cx">                 A1587D741B4DC1C600D69849 /* IntlDateTimeFormatPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntlDateTimeFormatPrototype.lut.h; sourceTree = "<group>"; };
</span><ins>+                A15DE5C51C0FBF8D0089133D /* NumberPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = NumberPrototype.js; sourceTree = "<group>"; };
</ins><span class="cx">                 A1712B3A11C7B212007A5315 /* RegExpCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RegExpCache.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 A1712B3E11C7B228007A5315 /* RegExpCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpCache.h; sourceTree = "<group>"; };
</span><span class="cx">                 A1712B4011C7B235007A5315 /* RegExpKey.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpKey.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -6666,6 +6667,7 @@
</span><span class="cx">                                 E33F50881B844A1A00413856 /* InternalPromiseConstructor.js */,
</span><span class="cx">                                 7CF9BC5B1B65D9A3009DB1EF /* IteratorPrototype.js */,
</span><span class="cx">                                 E30677971B8BC6F5003F87F0 /* ModuleLoaderObject.js */,
</span><ins>+                                A15DE5C51C0FBF8D0089133D /* NumberPrototype.js */,
</ins><span class="cx">                                 7CF9BC5C1B65D9B1009DB1EF /* ObjectConstructor.js */,
</span><span class="cx">                                 7CF9BC5D1B65D9B1009DB1EF /* PromiseOperations.js */,
</span><span class="cx">                                 7CFBAC1C18B535E500D00750 /* PromisePrototype.js */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsNumberPrototypejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/builtins/NumberPrototype.js (0 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/NumberPrototype.js         (rev 0)
+++ trunk/Source/JavaScriptCore/builtins/NumberPrototype.js        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -0,0 +1,47 @@
</span><ins>+/*
+ * Copyright (C) 2015 Andy VanWagoner <thetalecrafter@gmail.com>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+// @conditional=ENABLE(INTL)
+
+function toLocaleString(/* locales, options */)
+{
+ "use strict";
+
+ // 13.2.1 Number.prototype.toLocaleString ([locales [, options ]]) (ECMA-402 2.0)
+ // http://ecma-international.org/publications/standards/Ecma-402.htm
+
+ // 1. Let x be thisNumberValue(this value).
+ // 2. ReturnIfAbrupt(x).
+ var number = this;
+ if (!(typeof number === "number" || number instanceof Number))
+ throw new @TypeError("Number.prototype.toLocaleString called on incompatible " + typeof number);
+
+ // 3. Let numberFormat be Construct(%NumberFormat%, «locales, options»).
+ // 4. ReturnIfAbrupt(numberFormat).
+ var numberFormat = new @NumberFormat(arguments[0], arguments[1]);
+
+ // 5. Return FormatNumber(numberFormat, x).
+ return numberFormat.format(number);
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (193492 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2015-12-05 01:06:50 UTC (rev 193492)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -338,6 +338,9 @@
</span><span class="cx"> macro(generatorValue) \
</span><span class="cx"> macro(generatorThis) \
</span><span class="cx"> macro(generatorResumeMode) \
</span><ins>+ macro(Collator) \
+ macro(DateTimeFormat) \
+ macro(NumberFormat) \
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (193492 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2015-12-05 01:06:50 UTC (rev 193492)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -468,7 +468,8 @@
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->eval, m_evalFunction.get(), DontEnum);
</span><span class="cx">
</span><span class="cx"> #if ENABLE(INTL)
</span><del>- putDirectWithoutTransition(vm, vm.propertyNames->Intl, IntlObject::create(vm, this, IntlObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
</del><ins>+ IntlObject* intl = IntlObject::create(vm, this, IntlObject::createStructure(vm, this, m_objectPrototype.get()));
+ putDirectWithoutTransition(vm, vm.propertyNames->Intl, intl, DontEnum);
</ins><span class="cx"> #endif // ENABLE(INTL)
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->JSON, JSONObject::create(vm, JSONObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
</span><span class="cx"> putDirectWithoutTransition(vm, vm.propertyNames->Math, MathObject::create(vm, this, MathObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
</span><span class="lines">@@ -567,6 +568,11 @@
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->builtinNames().InspectorInstrumentationPrivateName(), InspectorInstrumentationObject::create(vm, this, InspectorInstrumentationObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum | DontDelete | ReadOnly),
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->MapPrivateName, mapConstructor, DontEnum | DontDelete | ReadOnly),
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->builtinNames().generatorResumePrivateName(), JSFunction::createBuiltinFunction(vm, generatorPrototypeGeneratorResumeCodeGenerator(vm), this), DontEnum | DontDelete | ReadOnly),
</span><ins>+#if ENABLE(INTL)
+ GlobalPropertyInfo(vm.propertyNames->builtinNames().CollatorPrivateName(), intl->getDirect(vm, vm.propertyNames->Collator), DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(vm.propertyNames->builtinNames().DateTimeFormatPrivateName(), intl->getDirect(vm, vm.propertyNames->DateTimeFormat), DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(vm.propertyNames->builtinNames().NumberFormatPrivateName(), intl->getDirect(vm, vm.propertyNames->NumberFormat), DontEnum | DontDelete | ReadOnly),
+#endif // ENABLE(INTL)
</ins><span class="cx"> };
</span><span class="cx"> addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeNumberPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp (193492 => 193493)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp        2015-12-05 01:06:50 UTC (rev 193492)
+++ trunk/Source/JavaScriptCore/runtime/NumberPrototype.cpp        2015-12-05 01:14:03 UTC (rev 193493)
</span><span class="lines">@@ -24,10 +24,11 @@
</span><span class="cx">
</span><span class="cx"> #include "BigInteger.h"
</span><span class="cx"> #include "Error.h"
</span><ins>+#include "JSCBuiltins.h"
+#include "JSCInlines.h"
</ins><span class="cx"> #include "JSFunction.h"
</span><span class="cx"> #include "JSGlobalObject.h"
</span><span class="cx"> #include "JSString.h"
</span><del>-#include "JSCInlines.h"
</del><span class="cx"> #include "Uint16WithFraction.h"
</span><span class="cx"> #include <wtf/dtoa.h>
</span><span class="cx"> #include <wtf/Assertions.h>
</span><span class="lines">@@ -75,11 +76,15 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void NumberPrototype::finishCreation(VM& vm, JSGlobalObject*)
</del><ins>+void NumberPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
</ins><span class="cx"> {
</span><span class="cx"> Base::finishCreation(vm);
</span><span class="cx"> setInternalValue(vm, jsNumber(0));
</span><span class="cx">
</span><ins>+#if ENABLE(INTL)
+ JSC_BUILTIN_FUNCTION("toLocaleString", numberPrototypeToLocaleStringCodeGenerator, DontEnum);
+#endif // ENABLE(INTL)
+
</ins><span class="cx"> ASSERT(inherits(info()));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>