<!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>[185432] 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/185432">185432</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-06-10 15:32:36 -0700 (Wed, 10 Jun 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement RegExp.prototype.flags
https://bugs.webkit.org/show_bug.cgi?id=145599
Patch by Jordan Harband <ljharb@gmail.com> on 2015-06-10
Reviewed by Geoffrey Garen.
Source/JavaScriptCore:
Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-regexp.prototype.flags
* runtime/CommonIdentifiers.h:
* runtime/RegExpPrototype.cpp:
(JSC::flagsString):
(JSC::regExpProtoFuncToString):
(JSC::regExpProtoGetterFlags):
* tests/stress/static-getter-in-names.js:
LayoutTests:
* js/Object-getOwnPropertyNames-expected.txt:
* js/regexp-flags-expected.txt: Added.
* js/regexp-flags.html: Added.
* js/script-tests/Object-getOwnPropertyNames.js:
* js/script-tests/regexp-flags.js: Added.
(.get shouldBe):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt">trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs">trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeRegExpPrototypecpp">trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressstaticgetterinnamesjs">trunk/Source/JavaScriptCore/tests/stress/static-getter-in-names.js</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsregexpflagsexpectedtxt">trunk/LayoutTests/js/regexp-flags-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsregexpflagshtml">trunk/LayoutTests/js/regexp-flags.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsregexpflagsjs">trunk/LayoutTests/js/script-tests/regexp-flags.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (185431 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-06-10 21:53:42 UTC (rev 185431)
+++ trunk/LayoutTests/ChangeLog        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-06-10 Jordan Harband <ljharb@gmail.com>
+
+ Implement RegExp.prototype.flags
+ https://bugs.webkit.org/show_bug.cgi?id=145599
+
+ Reviewed by Geoffrey Garen.
+
+ * js/Object-getOwnPropertyNames-expected.txt:
+ * js/regexp-flags-expected.txt: Added.
+ * js/regexp-flags.html: Added.
+ * js/script-tests/Object-getOwnPropertyNames.js:
+ * js/script-tests/regexp-flags.js: Added.
+ (.get shouldBe):
+
</ins><span class="cx"> 2015-06-10 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Move all content extension tests to same directory to fix flakiness.
</span></span></pre></div>
<a id="trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt (185431 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2015-06-10 21:53:42 UTC (rev 185431)
+++ trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx"> PASS getSortedOwnPropertyNames(Date) is ['UTC', 'length', 'name', 'now', 'parse', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Date.prototype) is ['constructor', 'getDate', 'getDay', 'getFullYear', 'getHours', 'getMilliseconds', 'getMinutes', 'getMonth', 'getSeconds', 'getTime', 'getTimezoneOffset', 'getUTCDate', 'getUTCDay', 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setYear', 'toDateString', 'toGMTString', 'toISOString', 'toJSON', 'toLocaleDateString', 'toLocaleString', 'toLocaleTimeString', 'toString', 'toTimeString', 'toUTCString', 'valueOf']
</span><span class="cx"> PASS getSortedOwnPropertyNames(RegExp) is ['$&', "$'", '$*', '$+', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', '$_', '$`', 'input', 'lastMatch', 'lastParen', 'leftContext', 'length', 'multiline', 'name', 'prototype', 'rightContext']
</span><del>-PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']
</del><ins>+PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', 'flags', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']
</ins><span class="cx"> PASS getSortedOwnPropertyNames(Error) is ['length', 'name', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Math) is ['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','clz32','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']
</span></span></pre></div>
<a id="trunkLayoutTestsjsregexpflagsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regexp-flags-expected.txt (0 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regexp-flags-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/regexp-flags-expected.txt        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -0,0 +1,29 @@
</span><ins>+Test RegExp#flags accessor
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+property descriptor
+PASS descriptor.configurable is true
+PASS descriptor.enumerable is false
+PASS typeof descriptor.get is 'function'
+PASS descriptor.set is undefined
+PASS /a/g.flags is 'g'
+PASS /a/.flags is ''
+PASS /a/gmi.flags is 'gim'
+PASS new RegExp('a', 'gmi').flags is 'gim'
+PASS flags.call(/a/ig) is 'gi'
+non-object receivers
+PASS flags.call(undefined) threw exception TypeError: Type error.
+PASS flags.call(null) threw exception TypeError: Type error.
+PASS flags.call(false) threw exception TypeError: Type error.
+PASS flags.call(true) threw exception TypeError: Type error.
+non-regex objects
+PASS flags.call({}) is ''
+PASS flags.call({global: true, multiline: true, ignoreCase: true}) is 'gim'
+PASS flags.call({global: 1, multiline: 0, ignoreCase: 2}) is 'gi'
+PASS flags.call({ __proto__: { multiline: true } }) is 'm'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsregexpflagshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/regexp-flags.html (0 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/regexp-flags.html         (rev 0)
+++ trunk/LayoutTests/js/regexp-flags.html        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/regexp-flags.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (185431 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2015-06-10 21:53:42 UTC (rev 185431)
+++ trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx"> "Date": "['UTC', 'length', 'name', 'now', 'parse', 'prototype']",
</span><span class="cx"> "Date.prototype": "['constructor', 'getDate', 'getDay', 'getFullYear', 'getHours', 'getMilliseconds', 'getMinutes', 'getMonth', 'getSeconds', 'getTime', 'getTimezoneOffset', 'getUTCDate', 'getUTCDay', 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setYear', 'toDateString', 'toGMTString', 'toISOString', 'toJSON', 'toLocaleDateString', 'toLocaleString', 'toLocaleTimeString', 'toString', 'toTimeString', 'toUTCString', 'valueOf']",
</span><span class="cx"> "RegExp": "['$&', \"$'\", '$*', '$+', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', '$_', '$`', 'input', 'lastMatch', 'lastParen', 'leftContext', 'length', 'multiline', 'name', 'prototype', 'rightContext']",
</span><del>- "RegExp.prototype": "['compile', 'constructor', 'exec', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']",
</del><ins>+ "RegExp.prototype": "['compile', 'constructor', 'exec', 'flags', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'test', 'toString']",
</ins><span class="cx"> "Error": "['length', 'name', 'prototype']",
</span><span class="cx"> "Error.prototype": "['constructor', 'message', 'name', 'toString']",
</span><span class="cx"> "Math": "['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','clz32','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']",
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsregexpflagsjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/regexp-flags.js (0 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/regexp-flags.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/regexp-flags.js        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+description('Test RegExp#flags accessor');
+
+debug("property descriptor");
+var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
+shouldBe("descriptor.configurable", "true");
+shouldBe("descriptor.enumerable", "false");
+shouldBe("typeof descriptor.get", "'function'");
+shouldBe("descriptor.set", "undefined");
+
+var flags = descriptor.get;
+
+shouldBe("/a/g.flags", "'g'");
+shouldBe("/a/.flags", "''");
+shouldBe("/a/gmi.flags", "'gim'"); // order is specified, happens to be alphabetic
+shouldBe("new RegExp('a', 'gmi').flags", "'gim'");
+shouldBe("flags.call(/a/ig)", "'gi'");
+
+debug("non-object receivers");
+shouldThrow("flags.call(undefined)", "'TypeError: Type error'");
+shouldThrow("flags.call(null)", "'TypeError: Type error'");
+shouldThrow("flags.call(false)", "'TypeError: Type error'");
+shouldThrow("flags.call(true)", "'TypeError: Type error'");
+
+debug("non-regex objects");
+shouldBe("flags.call({})", "''");
+shouldBe("flags.call({global: true, multiline: true, ignoreCase: true})", "'gim'");
+shouldBe("flags.call({global: 1, multiline: 0, ignoreCase: 2})", "'gi'");
+// inherited properties count
+shouldBe("flags.call({ __proto__: { multiline: true } })", "'m'");
+
+if (RegExp.prototype.hasOwnProperty('sticky')) {
+ debug("sticky flag");
+ // when the engine supports "sticky", these tests will fail by design.
+ // Hopefully, only the expected output will need updating.
+ shouldBe("/a/yimg.flags", "'gimy'");
+ shouldBe("new RegExp('a', 'yimg').flags", "'gimy'");
+ shouldBe("flags.call({global: true, multiline: true, ignoreCase: true, sticky: true})", "'gimy'");
+}
+if (RegExp.prototype.hasOwnProperty('unicode')) {
+ debug("unicode flag");
+ // when the engine supports "unicode", these tests will fail by design.
+ // Hopefully, only the expected output will need updating.
+ shouldBe("/a/uimg.flags", "'gimu'");
+ shouldBe("new RegExp('a', 'uimg').flags", "'gimu'");
+ shouldBe("flags.call({global: true, multiline: true, ignoreCase: true, unicode: true})", "'gimu'");
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (185431 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-06-10 21:53:42 UTC (rev 185431)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-06-10 Jordan Harband <ljharb@gmail.com>
+
+ Implement RegExp.prototype.flags
+ https://bugs.webkit.org/show_bug.cgi?id=145599
+
+ Reviewed by Geoffrey Garen.
+ Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-regexp.prototype.flags
+
+ * runtime/CommonIdentifiers.h:
+ * runtime/RegExpPrototype.cpp:
+ (JSC::flagsString):
+ (JSC::regExpProtoFuncToString):
+ (JSC::regExpProtoGetterFlags):
+ * tests/stress/static-getter-in-names.js:
+
</ins><span class="cx"> 2015-06-10 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> DFG ASSERTION FAILED: !iterate() on stress/singleton-scope-then-overwrite.js.ftl-eager
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (185431 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2015-06-10 21:53:42 UTC (rev 185431)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -103,6 +103,7 @@
</span><span class="cx"> macro(exec) \
</span><span class="cx"> macro(executionCount) \
</span><span class="cx"> macro(exitKind) \
</span><ins>+ macro(flags) \
</ins><span class="cx"> macro(focus) \
</span><span class="cx"> macro(forEach) \
</span><span class="cx"> macro(forward) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeRegExpPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp (185431 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp        2015-06-10 21:53:42 UTC (rev 185431)
+++ trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoGetterIgnoreCase(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoGetterMultiline(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoGetterSource(ExecState*);
</span><ins>+static EncodedJSValue JSC_HOST_CALL regExpProtoGetterFlags(ExecState*);
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -66,6 +67,7 @@
</span><span class="cx"> ignoreCase regExpProtoGetterIgnoreCase DontEnum|Accessor
</span><span class="cx"> multiline regExpProtoGetterMultiline DontEnum|Accessor
</span><span class="cx"> source regExpProtoGetterSource DontEnum|Accessor
</span><ins>+ flags regExpProtoGetterFlags DontEnum|Accessor
</ins><span class="cx"> @end
</span><span class="cx"> */
</span><span class="cx">
</span><span class="lines">@@ -135,6 +137,30 @@
</span><span class="cx"> return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static inline String flagsString(ExecState *exec, JSObject* regexp)
+{
+ char flags[4] = { 0, 0, 0, 0 };
+ int index = 0;
+
+ JSValue globalValue = regexp->get(exec, exec->propertyNames().global);
+ if (exec->hadException())
+ return String();
+ JSValue ignoreCaseValue = regexp->get(exec, exec->propertyNames().ignoreCase);
+ if (exec->hadException())
+ return String();
+ JSValue multilineValue = regexp->get(exec, exec->propertyNames().multiline);
+ if (exec->hadException())
+ return String();
+
+ if (globalValue.toBoolean(exec))
+ flags[index++] = 'g';
+ if (ignoreCaseValue.toBoolean(exec))
+ flags[index++] = 'i';
+ if (multilineValue.toBoolean(exec))
+ flags[index] = 'm';
+ return String(flags);
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx"> JSValue thisValue = exec->thisValue();
</span><span class="lines">@@ -147,17 +173,19 @@
</span><span class="cx"> if (JSValue earlyReturnValue = checker.earlyReturnValue())
</span><span class="cx"> return JSValue::encode(earlyReturnValue);
</span><span class="cx">
</span><del>- char postfix[5] = { '/', 0, 0, 0, 0 };
- int index = 1;
- if (thisObject->get(exec, exec->propertyNames().global).toBoolean(exec))
- postfix[index++] = 'g';
- if (thisObject->get(exec, exec->propertyNames().ignoreCase).toBoolean(exec))
- postfix[index++] = 'i';
- if (thisObject->get(exec, exec->propertyNames().multiline).toBoolean(exec))
- postfix[index] = 'm';
- String source = thisObject->get(exec, exec->propertyNames().source).toString(exec)->value(exec);
</del><ins>+ JSValue sourceValue = thisObject->get(exec, exec->propertyNames().source);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+ String source = sourceValue.toString(exec)->value(exec);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+
+ String flags = flagsString(exec, thisObject);
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+
</ins><span class="cx"> // If source is empty, use "/(?:)/" to avoid colliding with comment syntax
</span><del>- return JSValue::encode(jsMakeNontrivialString(exec, "/", source, postfix));
</del><ins>+ return JSValue::encode(jsMakeNontrivialString(exec, "/", source, "/", flags));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoGetterGlobal(ExecState* exec)
</span><span class="lines">@@ -187,6 +215,21 @@
</span><span class="cx"> return JSValue::encode(jsBoolean(asRegExpObject(thisValue)->regExp()->multiline()));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+EncodedJSValue JSC_HOST_CALL regExpProtoGetterFlags(ExecState* exec)
+{
+ JSValue thisValue = exec->thisValue();
+ if (!thisValue.isObject())
+ return JSValue::encode(throwTypeError(exec));
+
+ String flagsStr = flagsString(exec, asObject(thisValue));
+ if (exec->hadException())
+ return JSValue::encode(jsUndefined());
+
+ JSValue flags = jsMakeNontrivialString(exec, flagsStr);
+ return JSValue::encode(flags);
+}
+
+
</ins><span class="cx"> template <typename CharacterType>
</span><span class="cx"> static inline void appendLineTerminatorEscape(StringBuilder&, CharacterType);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressstaticgetterinnamesjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/stress/static-getter-in-names.js (185431 => 185432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/static-getter-in-names.js        2015-06-10 21:53:42 UTC (rev 185431)
+++ trunk/Source/JavaScriptCore/tests/stress/static-getter-in-names.js        2015-06-10 22:32:36 UTC (rev 185432)
</span><span class="lines">@@ -3,5 +3,5 @@
</span><span class="cx"> throw new Error('bad value: ' + actual);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-shouldBe(JSON.stringify(Object.getOwnPropertyNames(RegExp.prototype).sort()), '["compile","constructor","exec","global","ignoreCase","lastIndex","multiline","source","test","toString"]');
</del><ins>+shouldBe(JSON.stringify(Object.getOwnPropertyNames(RegExp.prototype).sort()), '["compile","constructor","exec","flags","global","ignoreCase","lastIndex","multiline","source","test","toString"]');
</ins><span class="cx"> shouldBe(JSON.stringify(Object.getOwnPropertyNames(/Cocoa/).sort()), '["lastIndex"]');
</span></span></pre>
</div>
</div>
</body>
</html>