<!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>[185989] 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/185989">185989</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-06-25 23:49:20 -0700 (Thu, 25 Jun 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Source/JavaScriptCore:
[ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function.
https://bugs.webkit.org/show_bug.cgi?id=144955
Reviewed by Yusuke Suzuki.
Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc.
This patch implements the simplest cases of arrow function declaration:
parameters () => 10 + 20
parameter x => x + 20
parameters (x, y) => x + y
function with block x => { return x*10; }
Not implemented:
bind of the this, arguments, super and etc.
exception in case of trying to use 'new' with arrow function
Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createFunctionExpr):
(JSC::ASTBuilder::createArrowFunctionExpr):
(JSC::ASTBuilder::createGetterOrSetterProperty):
(JSC::ASTBuilder::createFuncDeclStatement):
* parser/Lexer.cpp:
(JSC::Lexer<T>::setTokenPosition):
(JSC::Lexer<T>::lex):
* parser/Lexer.h:
(JSC::Lexer::lastTokenLocation):
(JSC::Lexer::setTerminator):
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseSourceElements):
(JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody):
(JSC::Parser<LexerType>::parseSwitchClauses):
(JSC::Parser<LexerType>::parseSwitchDefaultClause):
(JSC::Parser<LexerType>::parseBlockStatement):
(JSC::Parser<LexerType>::parseFunctionBody):
(JSC::stringForFunctionMode):
(JSC::Parser<LexerType>::parseFunctionParameters):
(JSC::Parser<LexerType>::parseFunctionInfo):
(JSC::Parser<LexerType>::parseFunctionDeclaration):
(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseAssignmentExpression):
(JSC::Parser<LexerType>::parsePropertyMethod):
(JSC::Parser<LexerType>::parseGetterSetter):
(JSC::Parser<LexerType>::parseArrowFunctionExpression):
* parser/Parser.h:
(JSC::Parser::locationBeforeLastToken):
(JSC::Parser::isEndOfArrowFunction):
(JSC::Parser::isArrowFunctionParamters):
(JSC::Parser::setEndOfStatement):
* parser/ParserFunctionInfo.h:
* parser/ParserTokens.h:
* parser/SourceCode.h:
(JSC::SourceCode::subArrowExpression):
* parser/SourceProviderCacheItem.h:
(JSC::SourceProviderCacheItem::endFunctionToken):
(JSC::SourceProviderCacheItem::SourceProviderCacheItem):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createArrowFunctionExpr):
(JSC::SyntaxChecker::setFunctionNameStart):
LayoutTests:
[ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function
https://bugs.webkit.org/show_bug.cgi?id=144955
Reviewed by Yusuke Suzuki.
Added arrow function tests
Patch by Aleksandr Skachkov <gskachkov@gmail.com> on 2015-06-26
* js/arrowfunction-asparamter-1-expected.txt: Added.
* js/arrowfunction-asparamter-1.html: Added.
* js/arrowfunction-asparamter-2-expected.txt: Added.
* js/arrowfunction-asparamter-2.html: Added.
* js/arrowfunction-associativity-1-expected.txt: Added.
* js/arrowfunction-associativity-1.html: Added.
* js/arrowfunction-associativity-2-expected.txt: Added.
* js/arrowfunction-associativity-2.html: Added.
* js/arrowfunction-block-1-expected.txt: Added.
* js/arrowfunction-block-1.html: Added.
* js/arrowfunction-block-2-expected.txt: Added.
* js/arrowfunction-block-2.html: Added.
* js/arrowfunction-syntax-endings-expected.txt: Added.
* js/arrowfunction-syntax-endings.html: Added.
* js/arrowfunction-syntax-errors-expected.txt: Added.
* js/arrowfunction-syntax-errors.html: Added.
* js/arrowfunction-syntax-expected.txt: Added.
* js/arrowfunction-syntax.html: Added.
* js/script-tests/arrowfunction-asparamter-1.js: Added.
* js/script-tests/arrowfunction-asparamter-2.js: Added.
* js/script-tests/arrowfunction-associativity-1.js: Added.
* js/script-tests/arrowfunction-associativity-2.js: Added.
* js/script-tests/arrowfunction-block-1.js: Added.
* js/script-tests/arrowfunction-block-2.js: Added.
* js/script-tests/arrowfunction-syntax-endings.js: Added.
* js/script-tests/arrowfunction-syntax-errors.js: Added.
* js/script-tests/arrowfunction-syntax.js: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserASTBuilderh">trunk/Source/JavaScriptCore/parser/ASTBuilder.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserLexercpp">trunk/Source/JavaScriptCore/parser/Lexer.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserLexerh">trunk/Source/JavaScriptCore/parser/Lexer.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParsercpp">trunk/Source/JavaScriptCore/parser/Parser.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParserh">trunk/Source/JavaScriptCore/parser/Parser.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParserFunctionInfoh">trunk/Source/JavaScriptCore/parser/ParserFunctionInfo.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserParserTokensh">trunk/Source/JavaScriptCore/parser/ParserTokens.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserSourceCodeh">trunk/Source/JavaScriptCore/parser/SourceCode.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserSourceProviderCacheItemh">trunk/Source/JavaScriptCore/parser/SourceProviderCacheItem.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserSyntaxCheckerh">trunk/Source/JavaScriptCore/parser/SyntaxChecker.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsarrowfunctionasparamter1expectedtxt">trunk/LayoutTests/js/arrowfunction-asparamter-1-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionasparamter1html">trunk/LayoutTests/js/arrowfunction-asparamter-1.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionasparamter2expectedtxt">trunk/LayoutTests/js/arrowfunction-asparamter-2-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionasparamter2html">trunk/LayoutTests/js/arrowfunction-asparamter-2.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionassociativity1expectedtxt">trunk/LayoutTests/js/arrowfunction-associativity-1-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionassociativity1html">trunk/LayoutTests/js/arrowfunction-associativity-1.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionassociativity2expectedtxt">trunk/LayoutTests/js/arrowfunction-associativity-2-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionassociativity2html">trunk/LayoutTests/js/arrowfunction-associativity-2.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionblock1expectedtxt">trunk/LayoutTests/js/arrowfunction-block-1-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionblock1html">trunk/LayoutTests/js/arrowfunction-block-1.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionblock2expectedtxt">trunk/LayoutTests/js/arrowfunction-block-2-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionblock2html">trunk/LayoutTests/js/arrowfunction-block-2.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionsyntaxendingsexpectedtxt">trunk/LayoutTests/js/arrowfunction-syntax-endings-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionsyntaxendingshtml">trunk/LayoutTests/js/arrowfunction-syntax-endings.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionsyntaxerrorsexpectedtxt">trunk/LayoutTests/js/arrowfunction-syntax-errors-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionsyntaxerrorshtml">trunk/LayoutTests/js/arrowfunction-syntax-errors.html</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionsyntaxexpectedtxt">trunk/LayoutTests/js/arrowfunction-syntax-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsarrowfunctionsyntaxhtml">trunk/LayoutTests/js/arrowfunction-syntax.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionasparamter1js">trunk/LayoutTests/js/script-tests/arrowfunction-asparamter-1.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionasparamter2js">trunk/LayoutTests/js/script-tests/arrowfunction-asparamter-2.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionassociativity1js">trunk/LayoutTests/js/script-tests/arrowfunction-associativity-1.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionassociativity2js">trunk/LayoutTests/js/script-tests/arrowfunction-associativity-2.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionblock1js">trunk/LayoutTests/js/script-tests/arrowfunction-block-1.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionblock2js">trunk/LayoutTests/js/script-tests/arrowfunction-block-2.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionsyntaxendingsjs">trunk/LayoutTests/js/script-tests/arrowfunction-syntax-endings.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionsyntaxerrorsjs">trunk/LayoutTests/js/script-tests/arrowfunction-syntax-errors.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsarrowfunctionsyntaxjs">trunk/LayoutTests/js/script-tests/arrowfunction-syntax.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/LayoutTests/ChangeLog        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2015-06-26 Aleksandr Skachkov <gskachkov@gmail.com>
+
+ [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function
+ https://bugs.webkit.org/show_bug.cgi?id=144955
+
+ Reviewed by Yusuke Suzuki.
+
+ Added arrow function tests
+
+ * js/arrowfunction-asparamter-1-expected.txt: Added.
+ * js/arrowfunction-asparamter-1.html: Added.
+ * js/arrowfunction-asparamter-2-expected.txt: Added.
+ * js/arrowfunction-asparamter-2.html: Added.
+ * js/arrowfunction-associativity-1-expected.txt: Added.
+ * js/arrowfunction-associativity-1.html: Added.
+ * js/arrowfunction-associativity-2-expected.txt: Added.
+ * js/arrowfunction-associativity-2.html: Added.
+ * js/arrowfunction-block-1-expected.txt: Added.
+ * js/arrowfunction-block-1.html: Added.
+ * js/arrowfunction-block-2-expected.txt: Added.
+ * js/arrowfunction-block-2.html: Added.
+ * js/arrowfunction-syntax-endings-expected.txt: Added.
+ * js/arrowfunction-syntax-endings.html: Added.
+ * js/arrowfunction-syntax-errors-expected.txt: Added.
+ * js/arrowfunction-syntax-errors.html: Added.
+ * js/arrowfunction-syntax-expected.txt: Added.
+ * js/arrowfunction-syntax.html: Added.
+ * js/script-tests/arrowfunction-asparamter-1.js: Added.
+ * js/script-tests/arrowfunction-asparamter-2.js: Added.
+ * js/script-tests/arrowfunction-associativity-1.js: Added.
+ * js/script-tests/arrowfunction-associativity-2.js: Added.
+ * js/script-tests/arrowfunction-block-1.js: Added.
+ * js/script-tests/arrowfunction-block-2.js: Added.
+ * js/script-tests/arrowfunction-syntax-endings.js: Added.
+ * js/script-tests/arrowfunction-syntax-errors.js: Added.
+ * js/script-tests/arrowfunction-syntax.js: Added.
+
</ins><span class="cx"> 2015-06-25 Chris Fleizach <cfleizach@apple.com>
</span><span class="cx">
</span><span class="cx"> AX: improve list heuristics (presentational use versus actual lists)
</span></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionasparamter1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-asparamter-1-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-asparamter-1-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-asparamter-1-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Tests for ES6 arrow function, passing arrow function as the paramter
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS "" + [1, 2, 3, 4].map(x => x, 32) is '1,2,3,4'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionasparamter1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-asparamter-1.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-asparamter-1.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-asparamter-1.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-asparamter-1.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionasparamter2expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-asparamter-2-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-asparamter-2-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-asparamter-2-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Tests for ES6 arrow function, passing arrow function as the paramter
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS f(x=>{return x * 25;}, 121) is 25*121
+PASS f2((x, y)=>{return x * y;}, 14, 12) is 14*12
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionasparamter2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-asparamter-2.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-asparamter-2.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-asparamter-2.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-asparamter-2.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionassociativity1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-associativity-1-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-associativity-1-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-associativity-1-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Tests for ES6 arrow function nested declaration
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+af1 = af2 = af3 => af1 = af2 = af3
+PASS af1 is af2
+PASS af2 is 13
+PASS af1 is 13
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionassociativity1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-associativity-1.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-associativity-1.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-associativity-1.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-associativity-1.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionassociativity2expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-associativity-2-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-associativity-2-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-associativity-2-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Tests for ES6 arrow function nested declaration
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+af = a => b => a
+PASS af('ABC')('DEF') is 'ABC'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionassociativity2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-associativity-2.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-associativity-2.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-associativity-2.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-associativity-2.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionblock1expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-block-1-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-block-1-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-block-1-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,13 @@
</span><ins>+Tests for ES6 arrow function declaration body as block
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+f = () => {}
+PASS typeof f() is 'undefined'
+g = () => ({})
+PASS typeof g() is 'object'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionblock1html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-block-1.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-block-1.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-block-1.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-block-1.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionblock2expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-block-2-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-block-2-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-block-2-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+Tests for ES6 arrow function declaration body as block
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof af(0) is "undefined"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionblock2html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-block-2.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-block-2.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-block-2.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-block-2.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionsyntaxendingsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-syntax-endings-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-syntax-endings-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-syntax-endings-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+Tests for ES6 arrow function endings
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS afEOL(12) is 13
+PASS x=>x+1 did not throw exception.
+PASS x=>x+1
+ did not throw exception.
+PASS f() is 39
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionsyntaxendingshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-syntax-endings.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-syntax-endings.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-syntax-endings.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-syntax-endings.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionsyntaxerrorsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-syntax-errors-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-syntax-errors-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-syntax-errors-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,123 @@
</span><ins>+Tests for ES6 arrow function syntax errors
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS =>{} threw exception SyntaxError: Unexpected keyword '=>'.
+PASS x=> threw exception SyntaxError: Unexpected end of script.
+PASS x=>* threw exception SyntaxError: Unexpected token '*'.
+PASS x=>/ threw exception SyntaxError: Unexpected token '/'. Invalid regular expression..
+PASS x=>% threw exception SyntaxError: Unexpected token '%'.
+PASS x=>+ threw exception SyntaxError: Unexpected end of script.
+PASS x=>- threw exception SyntaxError: Unexpected end of script.
+PASS x=><< threw exception SyntaxError: Unexpected token '<<'.
+PASS x=>>> threw exception SyntaxError: Unexpected token '>>'.
+PASS x=>>>> threw exception SyntaxError: Unexpected token '>>>'.
+PASS x=>< threw exception SyntaxError: Unexpected token '<'.
+PASS x=>> threw exception SyntaxError: Unexpected token '>'.
+PASS x=><= threw exception SyntaxError: Unexpected token '<='.
+PASS x=>>= threw exception SyntaxError: Unexpected token '>='.
+PASS x=>instanceof threw exception SyntaxError: Unexpected keyword 'instanceof'.
+PASS x=>in threw exception SyntaxError: Unexpected keyword 'in'.
+PASS x=>== threw exception SyntaxError: Unexpected token '=='.
+PASS x=>!= threw exception SyntaxError: Unexpected token '!='.
+PASS x=>=== threw exception SyntaxError: Unexpected token '==='.
+PASS x=>!== threw exception SyntaxError: Unexpected token '!=='.
+PASS x=>& threw exception SyntaxError: Unexpected token '&'.
+PASS x=>^ threw exception SyntaxError: Unexpected token '^'.
+PASS x=>| threw exception SyntaxError: Unexpected token '|'.
+PASS x=>&& threw exception SyntaxError: Unexpected token '&&'.
+PASS x=>|| threw exception SyntaxError: Unexpected token '||'.
+PASS x=>; threw exception SyntaxError: Unexpected token ';'.
+PASS x=>, threw exception SyntaxError: Unexpected token ','.
+PASS x=>{ threw exception SyntaxError: Unexpected end of script.
+PASS x=>{* threw exception SyntaxError: Unexpected token '*'.
+PASS x=>{/ threw exception SyntaxError: Unexpected token '/'. Invalid regular expression..
+PASS x=>{% threw exception SyntaxError: Unexpected token '%'.
+PASS x=>{+ threw exception SyntaxError: Unexpected end of script.
+PASS x=>{- threw exception SyntaxError: Unexpected end of script.
+PASS x=>{<< threw exception SyntaxError: Unexpected token '<<'.
+PASS x=>{>> threw exception SyntaxError: Unexpected token '>>'.
+PASS x=>{>>> threw exception SyntaxError: Unexpected token '>>>'.
+PASS x=>{< threw exception SyntaxError: Unexpected token '<'.
+PASS x=>{> threw exception SyntaxError: Unexpected token '>'.
+PASS x=>{<= threw exception SyntaxError: Unexpected token '<='.
+PASS x=>{>= threw exception SyntaxError: Unexpected token '>='.
+PASS x=>{instanceof threw exception SyntaxError: Unexpected keyword 'instanceof'.
+PASS x=>{in threw exception SyntaxError: Unexpected keyword 'in'.
+PASS x=>{== threw exception SyntaxError: Unexpected token '=='.
+PASS x=>{!= threw exception SyntaxError: Unexpected token '!='.
+PASS x=>{=== threw exception SyntaxError: Unexpected token '==='.
+PASS x=>{!== threw exception SyntaxError: Unexpected token '!=='.
+PASS x=>{& threw exception SyntaxError: Unexpected token '&'.
+PASS x=>{^ threw exception SyntaxError: Unexpected token '^'.
+PASS x=>{| threw exception SyntaxError: Unexpected token '|'.
+PASS x=>{&& threw exception SyntaxError: Unexpected token '&&'.
+PASS x=>{|| threw exception SyntaxError: Unexpected token '||'.
+PASS x=>{; threw exception SyntaxError: Unexpected end of script.
+PASS x=>{, threw exception SyntaxError: Unexpected token ','.
+PASS x=>} threw exception SyntaxError: Unexpected token '}'.
+PASS var y = x=> threw exception SyntaxError: Unexpected end of script.
+PASS var y = x=>* threw exception SyntaxError: Unexpected token '*'.
+PASS var y = x=>/ threw exception SyntaxError: Unexpected token '/'. Invalid regular expression..
+PASS var y = x=>% threw exception SyntaxError: Unexpected token '%'.
+PASS var y = x=>+ threw exception SyntaxError: Unexpected end of script.
+PASS var y = x=>- threw exception SyntaxError: Unexpected end of script.
+PASS var y = x=><< threw exception SyntaxError: Unexpected token '<<'.
+PASS var y = x=>>> threw exception SyntaxError: Unexpected token '>>'.
+PASS var y = x=>>>> threw exception SyntaxError: Unexpected token '>>>'.
+PASS var y = x=>< threw exception SyntaxError: Unexpected token '<'.
+PASS var y = x=>> threw exception SyntaxError: Unexpected token '>'.
+PASS var y = x=><= threw exception SyntaxError: Unexpected token '<='.
+PASS var y = x=>>= threw exception SyntaxError: Unexpected token '>='.
+PASS var y = x=>instanceof threw exception SyntaxError: Unexpected keyword 'instanceof'.
+PASS var y = x=>in threw exception SyntaxError: Unexpected keyword 'in'.
+PASS var y = x=>== threw exception SyntaxError: Unexpected token '=='.
+PASS var y = x=>!= threw exception SyntaxError: Unexpected token '!='.
+PASS var y = x=>=== threw exception SyntaxError: Unexpected token '==='.
+PASS var y = x=>!== threw exception SyntaxError: Unexpected token '!=='.
+PASS var y = x=>& threw exception SyntaxError: Unexpected token '&'.
+PASS var y = x=>^ threw exception SyntaxError: Unexpected token '^'.
+PASS var y = x=>| threw exception SyntaxError: Unexpected token '|'.
+PASS var y = x=>&& threw exception SyntaxError: Unexpected token '&&'.
+PASS var y = x=>|| threw exception SyntaxError: Unexpected token '||'.
+PASS var y = x=>; threw exception SyntaxError: Unexpected token ';'.
+PASS var y = x=>, threw exception SyntaxError: Unexpected token ','.
+PASS var y = x=>{ threw exception SyntaxError: Unexpected end of script.
+PASS var y = x=>{* threw exception SyntaxError: Unexpected token '*'.
+PASS var y = x=>{/ threw exception SyntaxError: Unexpected token '/'. Invalid regular expression..
+PASS var y = x=>{% threw exception SyntaxError: Unexpected token '%'.
+PASS var y = x=>{+ threw exception SyntaxError: Unexpected end of script.
+PASS var y = x=>{- threw exception SyntaxError: Unexpected end of script.
+PASS var y = x=>{<< threw exception SyntaxError: Unexpected token '<<'.
+PASS var y = x=>{>> threw exception SyntaxError: Unexpected token '>>'.
+PASS var y = x=>{>>> threw exception SyntaxError: Unexpected token '>>>'.
+PASS var y = x=>{< threw exception SyntaxError: Unexpected token '<'.
+PASS var y = x=>{> threw exception SyntaxError: Unexpected token '>'.
+PASS var y = x=>{<= threw exception SyntaxError: Unexpected token '<='.
+PASS var y = x=>{>= threw exception SyntaxError: Unexpected token '>='.
+PASS var y = x=>{instanceof threw exception SyntaxError: Unexpected keyword 'instanceof'.
+PASS var y = x=>{in threw exception SyntaxError: Unexpected keyword 'in'.
+PASS var y = x=>{== threw exception SyntaxError: Unexpected token '=='.
+PASS var y = x=>{!= threw exception SyntaxError: Unexpected token '!='.
+PASS var y = x=>{=== threw exception SyntaxError: Unexpected token '==='.
+PASS var y = x=>{!== threw exception SyntaxError: Unexpected token '!=='.
+PASS var y = x=>{& threw exception SyntaxError: Unexpected token '&'.
+PASS var y = x=>{^ threw exception SyntaxError: Unexpected token '^'.
+PASS var y = x=>{| threw exception SyntaxError: Unexpected token '|'.
+PASS var y = x=>{&& threw exception SyntaxError: Unexpected token '&&'.
+PASS var y = x=>{|| threw exception SyntaxError: Unexpected token '||'.
+PASS var y = x=>{; threw exception SyntaxError: Unexpected end of script.
+PASS var y = x=>{, threw exception SyntaxError: Unexpected token ','.
+PASS var y = x=>} threw exception SyntaxError: Unexpected token '}'.
+PASS var t = x=>x+1; =>{} threw exception SyntaxError: Unexpected keyword '=>'.
+PASS [=>x+1] threw exception SyntaxError: Unexpected keyword '=>'.
+PASS [x=>x+1, =>x+1] threw exception SyntaxError: Unexpected keyword '=>'.
+PASS var f=>x+1; threw exception SyntaxError: Unexpected keyword '=>'. Expected ';' after var declaration..
+PASS var x, y=>y+1; threw exception SyntaxError: Unexpected keyword '=>'. Expected ';' after var declaration..
+PASS debug(=>x+1) threw exception SyntaxError: Unexpected keyword '=>'.
+PASS debug("xyz", =>x+1) threw exception SyntaxError: Unexpected keyword '=>'.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionsyntaxerrorshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-syntax-errors.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-syntax-errors.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-syntax-errors.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-syntax-errors.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionsyntaxexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-syntax-expected.txt (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-syntax-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-syntax-expected.txt        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+Tests for ES6 arrow function calling
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS af0(10) is 11
+PASS af1(10) is 20
+PASS af2(1212) is 1000
+PASS af2_1(121) is a
+PASS af3(11,12) is 23
+PASS afwrapper(x => 1234) is 1234
+PASS afwrapper(x => 1234, 2345) is 1234
+PASS afwrapper(x => 121 + 232) is 353
+PASS afwrapper(x => 123 + 321, 9999) is 444
+PASS afwrapper(x => x + 12, 21) is 33
+PASS afwrapper((x) => x + 21, 32) is 53
+PASS afwrapper(() => 100) is 100
+PASS afwrapper(() => ext_value) is 121
+PASS afwrapper(() => ext_value * 10) is 1210
+PASS afwrapper((x) => ext_value * x, 30) is ext_value * 30
+PASS afwrapper(() => 100, 11) is 100
+PASS afwrapper(() => 100 + 10) is 110
+PASS afwrapper(() => 100 + 11, 12) is 111
+PASS arrowFunction4(1011) is 1012
+PASS xyz1 is 10101
+PASS afwrapper2((x, y) => x + y, 12 ,43) is 55
+PASS afArr0[0](10) is 100
+PASS afArr1[0](10) is 11
+PASS afArr1[1](11) is 13
+PASS afArr2[0](11) is 12
+PASS afArr2[1](11) is 13
+PASS afArr3[0](11) is 101
+PASS afArr3[1](11) is 12323
+PASS afObj.func(11) is 23
+PASS afBlock0(11) is 1000
+PASS afBlock1(11) is 1100
+PASS afBlock2(11) is 2200
+PASS afBlock3(11, 12222) is 134442
+PASS (function funcSelfExecAE1(value) { var f = x => x+1; return f(value);})(123); is 124
+PASS (function funcSelfExecAE2(value) { var f = x => { x++; return x + 1; }; return f(value);})(123); is 125
+PASS (function funcSelfExecAE3(value) { var f = (x) => { x++; return x + 1; }; return f(value);})(123); is 125
+PASS (function funcSelfExecAE4(value) { var f = (x, y) => { x++; return x + y; }; return f(value, value * 2);})(123); is 370
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsarrowfunctionsyntaxhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/arrowfunction-syntax.html (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/arrowfunction-syntax.html         (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-syntax.html        2015-06-26 06:49:20 UTC (rev 185989)
</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/arrowfunction-syntax.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionasparamter1js"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-asparamter-1.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-asparamter-1.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-asparamter-1.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+description('Tests for ES6 arrow function, passing arrow function as the paramter');
+
+shouldBe('"" + [1, 2, 3, 4].map(x => x, 32)', "'1,2,3,4'");
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionasparamter2js"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-asparamter-2.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-asparamter-2.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-asparamter-2.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+description('Tests for ES6 arrow function, passing arrow function as the paramter');
+
+var f = function (cl, paramter) { return cl(paramter); };
+var f2 = function (cl, paramter1, paramter2) { return cl(paramter1, paramter2); };
+
+shouldBe('f(x=>{return x * 25;}, 121)', '25*121' );
+shouldBe('f2((x, y)=>{return x * y;}, 14, 12)', '14*12');
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionassociativity1js"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-associativity-1.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-associativity-1.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-associativity-1.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+description('Tests for ES6 arrow function nested declaration');
+
+var af1, af2, af3;
+af1 = af2 = af3 => af1 = af2 = af3;
+debug('af1 = af2 = af3 => af1 = af2 = af3')
+shouldBe('af1', 'af2');
+af1(13);
+shouldBe('af2', '13');
+shouldBe('af1', '13');
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionassociativity2js"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-associativity-2.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-associativity-2.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-associativity-2.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+description('Tests for ES6 arrow function nested declaration');
+
+debug("af = a => b => a")
+var af = a => b => a;
+
+shouldBe("af('ABC')('DEF')", "'ABC'");
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionblock1js"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-block-1.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-block-1.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-block-1.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+description('Tests for ES6 arrow function declaration body as block');
+
+debug('f = () => {}');
+var f = () => {};
+shouldBe("typeof f()", "'undefined'");
+
+debug('g = () => ({})');
+var g = () => ({});
+shouldBe("typeof g()", "'object'");
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionblock2js"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-block-2.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-block-2.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-block-2.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+description('Tests for ES6 arrow function declaration body as block');
+
+var af = a => { a + 1; };
+
+shouldBe("typeof af(0)", '"undefined"');
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionsyntaxendingsjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-syntax-endings.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-syntax-endings.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-syntax-endings.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,35 @@
</span><ins>+description("Tests for ES6 arrow function endings");
+
+var afEOL = x=>x+1
+result = afEOL(12);
+
+shouldBe('afEOL(12)', '13');
+
+shouldNotThrow('x=>x+1');
+
+var afEOLTxt = 'x=>x+1' + String.fromCharCode(10);
+shouldNotThrow(afEOLTxt);
+
+var f = function () {
+ var result = 0;
+ var afEOF;
+
+
+ afEOF = x => x*10000 + x*1000 - x*10000 - x*1000 + x
+
+
+
+ result = afEOF(12);
+
+
+ result = result + afEOF(13);
+
+
+ result = result + afEOF(14);
+
+ return result;
+};
+
+shouldBe('f()', '39');
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionsyntaxerrorsjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-syntax-errors.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-syntax-errors.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-syntax-errors.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+description("Tests for ES6 arrow function syntax errors");
+
+shouldThrow('=>{}');
+
+function checkStatement(statement) {
+ var unexpectedSymbols = [ "",
+ "*", "/", "%" , "+", "-" ,
+ "<<", ">>", ">>>" ,
+ "<", ">", "<=", ">=", "instanceof", "in" ,
+ "==", "!=", "===", "!==",
+ "&" , "^" , "|" ,
+ "&&" , "||", ";" , ","
+ ];
+
+ for (var i = 0; i < unexpectedSymbols.length; i++) {
+ shouldThrow(statement + unexpectedSymbols[i]);
+ }
+}
+
+checkStatement('x=>');
+checkStatement('x=>{');
+shouldThrow('x=>}');
+
+checkStatement('var y = x=>');
+checkStatement('var y = x=>{');
+shouldThrow('var y = x=>}');
+
+
+shouldThrow('var t = x=>x+1; =>{}');
+shouldThrow('[=>x+1]');
+shouldThrow('[x=>x+1, =>x+1]');
+shouldThrow('var f=>x+1;');
+shouldThrow('var x, y=>y+1;');
+shouldThrow('debug(=>x+1)');
+shouldThrow('debug("xyz", =>x+1)');
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsarrowfunctionsyntaxjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/arrowfunction-syntax.js (0 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/arrowfunction-syntax.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-syntax.js        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -0,0 +1,82 @@
</span><ins>+description("Tests for ES6 arrow function calling");
+
+var af0 = v => v + 1;
+shouldBe('af0(10)', '11');
+
+var af1 = (v) => v * 2;
+shouldBe('af1(10)', '20');
+
+var af2 = () => 1000;
+shouldBe('af2(1212)', '1000' );
+
+var a = 151;
+var af2_1 = () => a;
+shouldBe('af2_1(121)', 'a');
+
+var af3 = (v, x) => v + x;
+shouldBe('af3(11,12)', '23');
+
+var afwrapper = function (cl, paramter) { return cl(paramter); };
+
+shouldBe('afwrapper(x => 1234)', '1234');
+shouldBe('afwrapper(x => 1234, 2345)', '1234' );
+shouldBe('afwrapper(x => 121 + 232)', '353' );
+shouldBe('afwrapper(x => 123 + 321, 9999)', '444' );
+shouldBe('afwrapper(x => x + 12, 21)', '33' );
+shouldBe('afwrapper((x) => x + 21, 32)', '53');
+shouldBe('afwrapper(() => 100)', '100');
+
+var ext_value = 121;
+shouldBe('afwrapper(() => ext_value)', '121');
+shouldBe('afwrapper(() => ext_value * 10)', '1210');
+shouldBe('afwrapper((x) => ext_value * x, 30)', 'ext_value * 30');
+shouldBe('afwrapper(() => 100, 11)', '100' );
+shouldBe('afwrapper(() => 100 + 10)', '110');
+shouldBe('afwrapper(() => 100 + 11, 12)', '111' );
+
+var arrowFunction4 = v => v + 1, xyz1 = 10101;
+shouldBe('arrowFunction4(1011)', '1012');
+shouldBe('xyz1', '10101');
+
+var afwrapper2 = function (cl, paramter1, paramter2) { return cl(paramter1, paramter2); };
+shouldBe('afwrapper2((x, y) => x + y, 12 ,43)', '55');
+
+var afArr0 = [v => v * 10];
+shouldBe('afArr0[0](10)', '100');
+
+var afArr1 = [v => v + 1, v => v + 2];
+shouldBe('afArr1[0](10)', '11');
+shouldBe('afArr1[1](11)', '13');
+
+var afArr2 = [(v) => v + 1, (v) => v + 2];
+shouldBe('afArr2[0](11)', '12');
+shouldBe('afArr2[1](11)', '13');
+
+var afArr3 = [() => 101, () => 12323];
+shouldBe('afArr3[0](11)', '101');
+shouldBe('afArr3[1](11)', '12323');
+
+var afObj = {func : y => y + 12};
+shouldBe('afObj.func(11)', '23');
+
+var afBlock0 = () => { return 1000; };
+shouldBe('afBlock0(11)', '1000');
+
+var afBlock1 = v => { var intval = 100; return v * intval; };
+shouldBe('afBlock1(11)', '1100');
+
+var afBlock2 = (v) => { var int = 200; return v * int; };
+shouldBe('afBlock2(11)', '2200');
+
+var afBlock3 = (v, x) => { var result = x * v; return result; };
+shouldBe('afBlock3(11, 12222)', '134442');
+
+shouldBe('(function funcSelfExecAE1(value) { var f = x => x+1; return f(value);})(123);', '124');
+
+shouldBe('(function funcSelfExecAE2(value) { var f = x => { x++; return x + 1; }; return f(value);})(123);', '125');
+
+shouldBe('(function funcSelfExecAE3(value) { var f = (x) => { x++; return x + 1; }; return f(value);})(123);', '125');
+
+shouldBe('(function funcSelfExecAE4(value) { var f = (x, y) => { x++; return x + y; }; return f(value, value * 2);})(123);', '370');
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2015-06-26 Aleksandr Skachkov <gskachkov@gmail.com>
+
+ [ES6] Implement ES6 arrow function syntax. Parser of arrow function with execution as common function.
+ https://bugs.webkit.org/show_bug.cgi?id=144955
+
+ Reviewed by Yusuke Suzuki.
+
+ Added support of ES6 arrow function. Changes were made according to following spec http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax. Patch does not include any arrow function specific behavior e.g. lexical bind this, arguments and etc.
+ This patch implements the simplest cases of arrow function declaration:
+ parameters () => 10 + 20
+ parameter x => x + 20
+ parameters (x, y) => x + y
+ function with block x => { return x*10; }
+
+ Not implemented:
+ bind of the this, arguments, super and etc.
+ exception in case of trying to use 'new' with arrow function
+
+ * parser/ASTBuilder.h:
+ (JSC::ASTBuilder::createFunctionExpr):
+ (JSC::ASTBuilder::createArrowFunctionExpr):
+ (JSC::ASTBuilder::createGetterOrSetterProperty):
+ (JSC::ASTBuilder::createFuncDeclStatement):
+ * parser/Lexer.cpp:
+ (JSC::Lexer<T>::setTokenPosition):
+ (JSC::Lexer<T>::lex):
+ * parser/Lexer.h:
+ (JSC::Lexer::lastTokenLocation):
+ (JSC::Lexer::setTerminator):
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::parseInner):
+ (JSC::Parser<LexerType>::parseSourceElements):
+ (JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBody):
+ (JSC::Parser<LexerType>::parseSwitchClauses):
+ (JSC::Parser<LexerType>::parseSwitchDefaultClause):
+ (JSC::Parser<LexerType>::parseBlockStatement):
+ (JSC::Parser<LexerType>::parseFunctionBody):
+ (JSC::stringForFunctionMode):
+ (JSC::Parser<LexerType>::parseFunctionParameters):
+ (JSC::Parser<LexerType>::parseFunctionInfo):
+ (JSC::Parser<LexerType>::parseFunctionDeclaration):
+ (JSC::Parser<LexerType>::parseClass):
+ (JSC::Parser<LexerType>::parseAssignmentExpression):
+ (JSC::Parser<LexerType>::parsePropertyMethod):
+ (JSC::Parser<LexerType>::parseGetterSetter):
+ (JSC::Parser<LexerType>::parseArrowFunctionExpression):
+ * parser/Parser.h:
+ (JSC::Parser::locationBeforeLastToken):
+ (JSC::Parser::isEndOfArrowFunction):
+ (JSC::Parser::isArrowFunctionParamters):
+ (JSC::Parser::setEndOfStatement):
+ * parser/ParserFunctionInfo.h:
+ * parser/ParserTokens.h:
+ * parser/SourceCode.h:
+ (JSC::SourceCode::subArrowExpression):
+ * parser/SourceProviderCacheItem.h:
+ (JSC::SourceProviderCacheItem::endFunctionToken):
+ (JSC::SourceProviderCacheItem::SourceProviderCacheItem):
+ * parser/SyntaxChecker.h:
+ (JSC::SyntaxChecker::createArrowFunctionExpr):
+ (JSC::SyntaxChecker::setFunctionNameStart):
+
</ins><span class="cx"> 2015-06-25 Yusuke Suzuki <utatane.tea@gmail.com>
</span><span class="cx">
</span><span class="cx"> [ES6] Support rest element in destructuring assignments
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserASTBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/ASTBuilder.h (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/ASTBuilder.h        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/ASTBuilder.h        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -347,7 +347,7 @@
</span><span class="cx"> ExpressionNode* createFunctionExpr(const JSTokenLocation& location, const ParserFunctionInfo<ASTBuilder>& info)
</span><span class="cx"> {
</span><span class="cx"> FuncExprNode* result = new (m_parserArena) FuncExprNode(location, *info.name, info.body,
</span><del>- m_sourceCode->subExpression(info.openBraceOffset, info.closeBraceOffset, info.bodyStartLine, info.bodyStartColumn), info.parameters);
</del><ins>+ m_sourceCode->subExpression(info.startFunctionOffset, info.endFunctionOffset, info.bodyStartLine, info.bodyStartColumn), info.parameters);
</ins><span class="cx"> info.body->setLoc(info.bodyStartLine, info.bodyEndLine, location.startOffset, location.lineStartOffset);
</span><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="lines">@@ -364,13 +364,26 @@
</span><span class="cx"> inStrictContext, constructorKind);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ ExpressionNode* createArrowFunctionExpr(const JSTokenLocation& location, const ParserFunctionInfo<ASTBuilder>& info)
+ {
+ SourceCode source = info.functionBodyType == ArrowFunctionBodyExpression
+ ? m_sourceCode->subArrowExpression(info.arrowFunctionOffset, info.endFunctionOffset, info.bodyStartLine, info.bodyStartColumn)
+ : m_sourceCode->subExpression(info.startFunctionOffset, info.endFunctionOffset, info.bodyStartLine, info.bodyStartColumn);
+
+ FuncExprNode* result = new (m_parserArena) FuncExprNode(location, *info.name, info.body, source, info.parameters);
+ info.body->setLoc(info.bodyStartLine, info.bodyEndLine, location.startOffset, location.lineStartOffset);
+ return result;
+ }
+#endif
+
</ins><span class="cx"> NEVER_INLINE PropertyNode* createGetterOrSetterProperty(const JSTokenLocation& location, PropertyNode::Type type, bool,
</span><span class="cx"> const Identifier* name, const ParserFunctionInfo<ASTBuilder>& info, SuperBinding superBinding)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(name);
</span><span class="cx"> info.body->setLoc(info.bodyStartLine, info.bodyEndLine, location.startOffset, location.lineStartOffset);
</span><span class="cx"> info.body->setInferredName(*name);
</span><del>- SourceCode source = m_sourceCode->subExpression(info.openBraceOffset, info.closeBraceOffset, info.bodyStartLine, info.bodyStartColumn);
</del><ins>+ SourceCode source = m_sourceCode->subExpression(info.startFunctionOffset, info.endFunctionOffset, info.bodyStartLine, info.bodyStartColumn);
</ins><span class="cx"> FuncExprNode* funcExpr = new (m_parserArena) FuncExprNode(location, m_vm->propertyNames->nullIdentifier, info.body, source, info.parameters);
</span><span class="cx"> return new (m_parserArena) PropertyNode(*name, funcExpr, type, PropertyNode::Unknown, superBinding);
</span><span class="cx"> }
</span><span class="lines">@@ -380,7 +393,7 @@
</span><span class="cx"> {
</span><span class="cx"> info.body->setLoc(info.bodyStartLine, info.bodyEndLine, location.startOffset, location.lineStartOffset);
</span><span class="cx"> const Identifier& ident = parserArena.identifierArena().makeNumericIdentifier(vm, name);
</span><del>- SourceCode source = m_sourceCode->subExpression(info.openBraceOffset, info.closeBraceOffset, info.bodyStartLine, info.bodyStartColumn);
</del><ins>+ SourceCode source = m_sourceCode->subExpression(info.startFunctionOffset, info.endFunctionOffset, info.bodyStartLine, info.bodyStartColumn);
</ins><span class="cx"> FuncExprNode* funcExpr = new (m_parserArena) FuncExprNode(location, vm->propertyNames->nullIdentifier, info.body, source, info.parameters);
</span><span class="cx"> return new (m_parserArena) PropertyNode(ident, funcExpr, type, PropertyNode::Unknown, superBinding);
</span><span class="cx"> }
</span><span class="lines">@@ -417,7 +430,7 @@
</span><span class="cx"> StatementNode* createFuncDeclStatement(const JSTokenLocation& location, const ParserFunctionInfo<ASTBuilder>& info)
</span><span class="cx"> {
</span><span class="cx"> FuncDeclNode* decl = new (m_parserArena) FuncDeclNode(location, *info.name, info.body,
</span><del>- m_sourceCode->subExpression(info.openBraceOffset, info.closeBraceOffset, info.bodyStartLine, info.bodyStartColumn), info.parameters);
</del><ins>+ m_sourceCode->subExpression(info.startFunctionOffset, info.endFunctionOffset, info.bodyStartLine, info.bodyStartColumn), info.parameters);
</ins><span class="cx"> if (*info.name == m_vm->propertyNames->arguments)
</span><span class="cx"> usesArguments();
</span><span class="cx"> m_scope.m_funcDeclarations.append(decl->body());
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserLexercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Lexer.cpp (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Lexer.cpp        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/Lexer.cpp        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -1715,11 +1715,25 @@
</span><span class="cx"> return code < m_codeEnd && *code == ':';
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
</ins><span class="cx"> template <typename T>
</span><ins>+void Lexer<T>::setTokenPosition(JSToken* tokenRecord)
+{
+ JSTokenData* tokenData = &tokenRecord->m_data;
+ tokenData->line = lineNumber();
+ tokenData->offset = currentOffset();
+ tokenData->lineStartOffset = currentLineStartOffset();
+ ASSERT(tokenData->offset >= tokenData->lineStartOffset);
+}
+#endif
+
+template <typename T>
</ins><span class="cx"> JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
</span><span class="cx"> {
</span><span class="cx"> JSTokenData* tokenData = &tokenRecord->m_data;
</span><span class="cx"> JSTokenLocation* tokenLocation = &tokenRecord->m_location;
</span><ins>+ m_lastTockenLocation = JSTokenLocation(tokenRecord->m_location);
+
</ins><span class="cx"> ASSERT(!m_error);
</span><span class="cx"> ASSERT(m_buffer8.isEmpty());
</span><span class="cx"> ASSERT(m_buffer16.isEmpty());
</span><span class="lines">@@ -1778,7 +1792,19 @@
</span><span class="cx"> }
</span><span class="cx"> token = GT;
</span><span class="cx"> break;
</span><del>- case CharacterEqual:
</del><ins>+ case CharacterEqual: {
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ if (peek(1) == '>') {
+ token = ARROWFUNCTION;
+ tokenData->line = lineNumber();
+ tokenData->offset = currentOffset();
+ tokenData->lineStartOffset = currentLineStartOffset();
+ ASSERT(tokenData->offset >= tokenData->lineStartOffset);
+ shift();
+ shift();
+ break;
+ }
+#endif
</ins><span class="cx"> shift();
</span><span class="cx"> if (m_current == '=') {
</span><span class="cx"> shift();
</span><span class="lines">@@ -1792,6 +1818,7 @@
</span><span class="cx"> }
</span><span class="cx"> token = EQUAL;
</span><span class="cx"> break;
</span><ins>+ }
</ins><span class="cx"> case CharacterLess:
</span><span class="cx"> shift();
</span><span class="cx"> if (m_current == '!' && peek(1) == '-' && peek(2) == '-') {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserLexerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Lexer.h (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Lexer.h        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/Lexer.h        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -87,6 +87,9 @@
</span><span class="cx"> void setIsReparsing() { m_isReparsing = true; }
</span><span class="cx"> bool isReparsing() const { return m_isReparsing; }
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ void setTokenPosition(JSToken* tokenRecord);
+#endif
</ins><span class="cx"> JSTokenType lex(JSToken*, unsigned, bool strictMode);
</span><span class="cx"> bool nextTokenIsColon();
</span><span class="cx"> int lineNumber() const { return m_lineNumber; }
</span><span class="lines">@@ -97,6 +100,7 @@
</span><span class="cx"> return JSTextPosition(m_lineNumber, currentOffset(), currentLineStartOffset());
</span><span class="cx"> }
</span><span class="cx"> JSTextPosition positionBeforeLastNewline() const { return m_positionBeforeLastNewline; }
</span><ins>+ JSTokenLocation lastTokenLocation() const { return m_lastTockenLocation; }
</ins><span class="cx"> void setLastLineNumber(int lastLineNumber) { m_lastLineNumber = lastLineNumber; }
</span><span class="cx"> int lastLineNumber() const { return m_lastLineNumber; }
</span><span class="cx"> bool prevTerminator() const { return m_terminator; }
</span><span class="lines">@@ -131,6 +135,10 @@
</span><span class="cx"> {
</span><span class="cx"> m_lineNumber = line;
</span><span class="cx"> }
</span><ins>+ void setTerminator(bool terminator)
+ {
+ m_terminator = terminator;
+ }
</ins><span class="cx">
</span><span class="cx"> SourceProvider* sourceProvider() const { return m_source->provider(); }
</span><span class="cx">
</span><span class="lines">@@ -215,6 +223,7 @@
</span><span class="cx"> const T* m_codeStartPlusOffset;
</span><span class="cx"> const T* m_lineStart;
</span><span class="cx"> JSTextPosition m_positionBeforeLastNewline;
</span><ins>+ JSTokenLocation m_lastTockenLocation;
</ins><span class="cx"> bool m_isReparsing;
</span><span class="cx"> bool m_atLineStart;
</span><span class="cx"> bool m_error;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.cpp (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.cpp        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/Parser.cpp        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -264,7 +264,7 @@
</span><span class="cx"> if (m_lexer->isReparsing())
</span><span class="cx"> m_statementDepth--;
</span><span class="cx"> ScopeRef scope = currentScope();
</span><del>- SourceElements* sourceElements = parseSourceElements(context, CheckForStrictMode);
</del><ins>+ SourceElements* sourceElements = parseSourceElements(context, CheckForStrictMode, StandardFunctionParseType);
</ins><span class="cx"> if (!sourceElements || !consume(EOFTOK)) {
</span><span class="cx"> if (hasError())
</span><span class="cx"> parseError = m_errorMessage;
</span><span class="lines">@@ -343,7 +343,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> template <typename LexerType>
</span><del>-template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseSourceElements(TreeBuilder& context, SourceElementsMode mode)
</del><ins>+template <class TreeBuilder> TreeSourceElements Parser<LexerType>::parseSourceElements(TreeBuilder& context, SourceElementsMode mode, FunctionParseType functionParseType)
</ins><span class="cx"> {
</span><span class="cx"> const unsigned lengthOfUseStrictLiteral = 12; // "use strict".length
</span><span class="cx"> TreeSourceElements sourceElements = context.createSourceElements();
</span><span class="lines">@@ -352,6 +352,21 @@
</span><span class="cx"> unsigned directiveLiteralLength = 0;
</span><span class="cx"> auto savePoint = createSavePoint();
</span><span class="cx"> bool hasSetStrict = false;
</span><ins>+
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ if (match(ARROWFUNCTION)) {
+ TreeStatement arrowfunctionStatement = parseArrowFunctionSingleExpressionBody(context, functionParseType);
+
+ if (arrowfunctionStatement) {
+ context.setEndOffset(arrowfunctionStatement, m_lastTokenEndPosition.offset);
+ context.appendStatement(sourceElements, arrowfunctionStatement);
+ }
+
+ propagateError();
+ return sourceElements;
+ }
+#endif
+
</ins><span class="cx"> while (TreeStatement statement = parseStatement(context, directive, &directiveLiteralLength)) {
</span><span class="cx"> if (mode == CheckForStrictMode && !seenNonDirective) {
</span><span class="cx"> if (directive) {
</span><span class="lines">@@ -583,7 +598,43 @@
</span><span class="cx"> return context.createBindingLocation(token.m_location, name, token.m_startPosition, token.m_endPosition);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
</ins><span class="cx"> template <typename LexerType>
</span><ins>+template <class TreeBuilder> TreeStatement Parser<LexerType>::parseArrowFunctionSingleExpressionBody(TreeBuilder& context, FunctionParseType parseType)
+{
+ ASSERT(match(ARROWFUNCTION));
+
+ // When reparsing phase, parseType becomes StandardFunctionParseType even if the function is arrow function.
+ // This condition considers the following situations.
+ // (1): If we are in the reparsing phase, this arrow function is already parsed once, so there is no syntax error.
+ // (2): But if we are not in the reparsing phase, we should check this function is called in the context of the arrow function.
+ if (!m_lexer->isReparsing() && parseType != ArrowFunctionParseType)
+ failDueToUnexpectedToken();
+
+ JSTokenLocation location(tokenLocation());
+ JSTextPosition start = tokenStartPosition();
+ JSTextPosition end = tokenEndPosition();
+
+ next();
+
+ failIfStackOverflow();
+ TreeExpression expr = parseAssignmentExpression(context);
+ failIfFalse(expr, "Cannot parse the arrow function expression");
+
+ context.setEndOffset(expr, m_lastTokenEndPosition.offset);
+
+ failIfFalse(isEndOfArrowFunction(), "Expected a ';', ']', '}', ')', ',', line terminator or EOF following a arrow function statement");
+
+ end = tokenEndPosition();
+
+ if (!m_lexer->prevTerminator())
+ setEndOfStatement();
+
+ return context.createReturnStatement(location, expr, start, end);
+}
+#endif
+
+template <typename LexerType>
</ins><span class="cx"> template <class TreeBuilder> TreeDeconstructionPattern Parser<LexerType>::tryParseDeconstructionPatternExpression(TreeBuilder& context)
</span><span class="cx"> {
</span><span class="cx"> return parseDeconstructionPattern(context, DeconstructToExpressions);
</span><span class="lines">@@ -1065,7 +1116,7 @@
</span><span class="cx"> TreeExpression condition = parseExpression(context);
</span><span class="cx"> failIfFalse(condition, "Cannot parse switch clause");
</span><span class="cx"> consumeOrFail(COLON, "Expected a ':' after switch clause expression");
</span><del>- TreeSourceElements statements = parseSourceElements(context, DontCheckForStrictMode);
</del><ins>+ TreeSourceElements statements = parseSourceElements(context, DontCheckForStrictMode, StandardFunctionParseType);
</ins><span class="cx"> failIfFalse(statements, "Cannot parse the body of a switch clause");
</span><span class="cx"> TreeClause clause = context.createClause(condition, statements);
</span><span class="cx"> context.setStartOffset(clause, startOffset);
</span><span class="lines">@@ -1078,7 +1129,7 @@
</span><span class="cx"> TreeExpression condition = parseExpression(context);
</span><span class="cx"> failIfFalse(condition, "Cannot parse switch case expression");
</span><span class="cx"> consumeOrFail(COLON, "Expected a ':' after switch clause expression");
</span><del>- TreeSourceElements statements = parseSourceElements(context, DontCheckForStrictMode);
</del><ins>+ TreeSourceElements statements = parseSourceElements(context, DontCheckForStrictMode, StandardFunctionParseType);
</ins><span class="cx"> failIfFalse(statements, "Cannot parse the body of a switch clause");
</span><span class="cx"> clause = context.createClause(condition, statements);
</span><span class="cx"> context.setStartOffset(clause, startOffset);
</span><span class="lines">@@ -1095,7 +1146,7 @@
</span><span class="cx"> unsigned startOffset = tokenStart();
</span><span class="cx"> next();
</span><span class="cx"> consumeOrFail(COLON, "Expected a ':' after switch default clause");
</span><del>- TreeSourceElements statements = parseSourceElements(context, DontCheckForStrictMode);
</del><ins>+ TreeSourceElements statements = parseSourceElements(context, DontCheckForStrictMode, StandardFunctionParseType);
</ins><span class="cx"> failIfFalse(statements, "Cannot parse the body of a switch default clause");
</span><span class="cx"> TreeClause result = context.createClause(0, statements);
</span><span class="cx"> context.setStartOffset(result, startOffset);
</span><span class="lines">@@ -1180,7 +1231,7 @@
</span><span class="cx"> context.setEndOffset(result, endOffset);
</span><span class="cx"> return result;
</span><span class="cx"> }
</span><del>- TreeSourceElements subtree = parseSourceElements(context, DontCheckForStrictMode);
</del><ins>+ TreeSourceElements subtree = parseSourceElements(context, DontCheckForStrictMode, StandardFunctionParseType);
</ins><span class="cx"> failIfFalse(subtree, "Cannot parse the body of the block statement");
</span><span class="cx"> matchOrFail(CLOSEBRACE, "Expected a closing '}' at the end of a block statement");
</span><span class="cx"> int endOffset = m_token.m_data.offset;
</span><span class="lines">@@ -1201,6 +1252,7 @@
</span><span class="cx"> failIfStackOverflow();
</span><span class="cx"> TreeStatement result = 0;
</span><span class="cx"> bool shouldSetEndOffset = true;
</span><ins>+
</ins><span class="cx"> switch (m_token.m_type) {
</span><span class="cx"> case OPENBRACE:
</span><span class="cx"> result = parseBlockStatement(context);
</span><span class="lines">@@ -1310,20 +1362,27 @@
</span><span class="cx"> template <typename LexerType>
</span><span class="cx"> template <class TreeBuilder> TreeFunctionBody Parser<LexerType>::parseFunctionBody(
</span><span class="cx"> TreeBuilder& context, int functionKeywordStart, int functionNameStart,
</span><del>- int parametersStart, ConstructorKind constructorKind)
</del><ins>+ int parametersStart, ConstructorKind constructorKind, FunctionParseType parseType)
</ins><span class="cx"> {
</span><span class="cx"> JSTokenLocation startLocation(tokenLocation());
</span><span class="cx"> unsigned startColumn = tokenColumn();
</span><del>- next();
</del><span class="cx">
</span><del>- if (match(CLOSEBRACE)) {
- unsigned endColumn = tokenColumn();
- return context.createFunctionBody(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind);
</del><ins>+ if (parseType == StandardFunctionParseType) {
+ next();
+ if (match(CLOSEBRACE)) {
+ unsigned endColumn = tokenColumn();
+ return context.createFunctionBody(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind);
+ }
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> DepthManager statementDepth(&m_statementDepth);
</span><span class="cx"> m_statementDepth = 0;
</span><span class="cx"> typename TreeBuilder::FunctionBodyBuilder bodyBuilder(const_cast<VM*>(m_vm), m_lexer.get());
</span><del>- failIfFalse(parseSourceElements(bodyBuilder, CheckForStrictMode), "Cannot parse body of this function");
</del><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ failIfFalse(parseSourceElements(bodyBuilder, CheckForStrictMode, parseType), parseType == StandardFunctionParseType ? "Cannot parse body of this function" : "Cannot parse body of this arrow function");
+#else
+ failIfFalse(parseSourceElements(bodyBuilder, CheckForStrictMode, StandardFunctionParseType), "Cannot parse body of this function");
+#endif
</ins><span class="cx"> unsigned endColumn = tokenColumn();
</span><span class="cx"> return context.createFunctionBody(startLocation, tokenLocation(), startColumn, endColumn, functionKeywordStart, functionNameStart, parametersStart, strictMode(), constructorKind);
</span><span class="cx"> }
</span><span class="lines">@@ -1339,27 +1398,46 @@
</span><span class="cx"> return "function";
</span><span class="cx"> case MethodMode:
</span><span class="cx"> return "method";
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ case ArrowFunctionMode:
+ return "arrow function";
+#endif
</ins><span class="cx"> }
</span><span class="cx"> RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-template <typename LexerType> template <class TreeBuilder> int Parser<LexerType>::parseFunctionParameters(TreeBuilder& context, FunctionRequirements requirements, FunctionParseMode mode, bool nameIsInContainingScope, AutoPopScopeRef& functionScope, ParserFunctionInfo<TreeBuilder>& info)
</del><ins>+template <typename LexerType> template <class TreeBuilder> int Parser<LexerType>::parseFunctionParameters(TreeBuilder& context, FunctionParseMode mode, ParserFunctionInfo<TreeBuilder>& info)
</ins><span class="cx"> {
</span><del>- if (match(IDENT)) {
- info.name = m_token.m_data.ident;
- m_lastFunctionName = info.name;
- next();
- if (!nameIsInContainingScope)
- failIfFalseIfStrict(functionScope->declareVariable(info.name), "'", info.name->impl(), "' is not a valid ", stringForFunctionMode(mode), " name in strict mode");
- } else if (requirements == FunctionNeedsName) {
- if (match(OPENPAREN) && mode == FunctionMode)
- semanticFail("Function statements must have a name");
- semanticFailureDueToKeyword(stringForFunctionMode(mode), " name");
- failDueToUnexpectedToken();
- return false;
</del><ins>+ int parametersStart = m_token.m_location.startOffset;
+
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ if (mode == ArrowFunctionMode) {
+ if (!match(IDENT) && !match(OPENPAREN)) {
+ semanticFailureDueToKeyword(stringForFunctionMode(mode), " name");
+ failWithMessage("Expected an arrow function input parameter");
+ } else {
+ if (match(OPENPAREN)) {
+ next();
+
+ if (!match(CLOSEPAREN)) {
+ info.parameters = parseFormalParameters(context);
+ failIfFalse(info.parameters, "Cannot parse parameters for this ", stringForFunctionMode(mode));
+ }
+
+ consumeOrFail(CLOSEPAREN, "Expected a ')' or a ',' after a parameter declaration");
+ } else {
+ auto parameter = parseDeconstructionPattern(context, DeconstructToParameters);
+ failIfFalse(parameter, "Cannot parse parameter pattern");
+ info.parameters = context.createFormalParameterList(parameter);
+ failIfFalse(info.parameters, "Cannot parse parameters for this ", stringForFunctionMode(mode));
+ }
+ }
+
+ return parametersStart;
</ins><span class="cx"> }
</span><del>- int parametersStart = m_token.m_location.startOffset;
</del><ins>+#endif
+
</ins><span class="cx"> if (!consume(OPENPAREN)) {
</span><span class="cx"> semanticFailureDueToKeyword(stringForFunctionMode(mode), " name");
</span><span class="cx"> failWithMessage("Expected an opening '(' before a ", stringForFunctionMode(mode), "'s parameter list");
</span><span class="lines">@@ -1384,43 +1462,89 @@
</span><span class="cx">
</span><span class="cx"> return parametersStart;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> template <typename LexerType>
</span><del>-template <class TreeBuilder> bool Parser<LexerType>::parseFunctionInfo(TreeBuilder& context, FunctionRequirements requirements, FunctionParseMode mode, bool nameIsInContainingScope, ConstructorKind constructorKind, SuperBinding expectedSuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>& info)
</del><ins>+template <class TreeBuilder> bool Parser<LexerType>::parseFunctionInfo(TreeBuilder& context, FunctionRequirements requirements, FunctionParseMode mode, bool nameIsInContainingScope, ConstructorKind constructorKind, SuperBinding expectedSuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>& info, FunctionParseType parseType)
</ins><span class="cx"> {
</span><span class="cx"> AutoPopScopeRef functionScope(this, pushScope());
</span><span class="cx"> functionScope->setIsFunction();
</span><span class="cx"> int functionNameStart = m_token.m_location.startOffset;
</span><span class="cx"> const Identifier* lastFunctionName = m_lastFunctionName;
</span><span class="cx"> m_lastFunctionName = nullptr;
</span><ins>+ int parametersStart;
</ins><span class="cx">
</span><del>- int parametersStart = parseFunctionParameters(context, requirements, mode, nameIsInContainingScope, functionScope, info);
- propagateError();
</del><ins>+ switch (parseType) {
+ case StandardFunctionParseType: {
+ if (match(IDENT)) {
+ info.name = m_token.m_data.ident;
+ m_lastFunctionName = info.name;
+ next();
+ if (!nameIsInContainingScope)
+ failIfFalseIfStrict(functionScope->declareVariable(info.name), "'", info.name->impl(), "' is not a valid ", stringForFunctionMode(mode), " name in strict mode");
+ } else if (requirements == FunctionNeedsName) {
+ if (match(OPENPAREN) && mode == FunctionMode)
+ semanticFail("Function statements must have a name");
+ semanticFailureDueToKeyword(stringForFunctionMode(mode), " name");
+ failDueToUnexpectedToken();
+ return false;
+ }
+
+ parametersStart = parseFunctionParameters(context, mode, info);
+ propagateError();
+
+ matchOrFail(OPENBRACE, "Expected an opening '{' at the start of a ", stringForFunctionMode(mode), " body");
+
+ // BytecodeGenerator emits code to throw TypeError when a class constructor is "call"ed.
+ // Set ConstructorKind to None for non-constructor methods of classes.
+
+ if (m_defaultConstructorKind != ConstructorKind::None) {
+ constructorKind = m_defaultConstructorKind;
+ expectedSuperBinding = m_defaultConstructorKind == ConstructorKind::Derived ? SuperBinding::Needed : SuperBinding::NotNeeded;
+ }
+
+ info.startFunctionOffset = m_token.m_data.offset;
+
+ break;
+ }
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ case ArrowFunctionParseType: {
+ parametersStart = parseFunctionParameters(context, ArrowFunctionMode, info);
+ propagateError();
+
+ matchOrFail(ARROWFUNCTION, "Expected a '=>' after arrow function parameter declaration");
+ ASSERT(constructorKind == ConstructorKind::None);
+
+ info.arrowFunctionOffset = m_token.m_data.offset;
+ // Check if arrow body start with {. If it true it mean that arrow function is Fat arrow function
+ // and we need use common approach to parse function body
+ SavePoint savePoint = createSavePoint();
+
+ next();
+ info.functionBodyType = match(OPENBRACE) ? ArrowFunctionBodyBlock : ArrowFunctionBodyExpression;
+ info.startFunctionOffset = (info.functionBodyType == ArrowFunctionBodyBlock) ? m_token.m_data.offset : info.arrowFunctionOffset;
+
+ restoreSavePoint(savePoint);
</ins><span class="cx">
</span><del>- matchOrFail(OPENBRACE, "Expected an opening '{' at the start of a ", stringForFunctionMode(mode), " body");
-
- // BytecodeGenerator emits code to throw TypeError when a class constructor is "call"ed.
- // Set ConstructorKind to None for non-constructor methods of classes.
- if (m_defaultConstructorKind != ConstructorKind::None) {
- constructorKind = m_defaultConstructorKind;
- expectedSuperBinding = m_defaultConstructorKind == ConstructorKind::Derived ? SuperBinding::Needed : SuperBinding::NotNeeded;
</del><ins>+ break;
</ins><span class="cx"> }
</span><ins>+#endif
+ }
+
</ins><span class="cx"> bool isClassConstructor = constructorKind != ConstructorKind::None;
</span><span class="cx">
</span><del>- info.openBraceOffset = m_token.m_data.offset;
</del><span class="cx"> info.bodyStartLine = tokenLine();
</span><span class="cx"> info.bodyStartColumn = m_token.m_data.offset - m_token.m_data.lineStartOffset;
</span><span class="cx"> JSTokenLocation startLocation(tokenLocation());
</span><span class="cx">
</span><span class="cx"> // If we know about this function already, we can use the cached info and skip the parser to the end of the function.
</span><del>- if (const SourceProviderCacheItem* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(info.openBraceOffset) : 0) {
</del><ins>+ if (const SourceProviderCacheItem* cachedInfo = TreeBuilder::CanUseFunctionCache ? findCachedFunctionInfo(info.startFunctionOffset) : 0) {
</ins><span class="cx"> // If we're in a strict context, the cached function info must say it was strict too.
</span><span class="cx"> ASSERT(!strictMode() || cachedInfo->strictMode);
</span><span class="cx"> JSTokenLocation endLocation;
</span><span class="cx">
</span><del>- endLocation.line = cachedInfo->closeBraceLine;
- endLocation.startOffset = cachedInfo->closeBraceOffset;
- endLocation.lineStartOffset = cachedInfo->closeBraceLineStartOffset;
</del><ins>+ endLocation.line = cachedInfo->lastTockenLine;
+ endLocation.startOffset = cachedInfo->lastTockenStartOffset;
+ endLocation.lineStartOffset = cachedInfo->lastTockenLineStartOffset;
</ins><span class="cx">
</span><span class="cx"> bool endColumnIsOnStartLine = (endLocation.line == info.bodyStartLine);
</span><span class="cx"> ASSERT(endLocation.startOffset >= endLocation.lineStartOffset);
</span><span class="lines">@@ -1437,24 +1561,64 @@
</span><span class="cx"> functionScope->restoreFromSourceProviderCache(cachedInfo);
</span><span class="cx"> failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo), "Parser error");
</span><span class="cx">
</span><del>- info.closeBraceOffset = cachedInfo->closeBraceOffset;
-
- m_token = cachedInfo->closeBraceToken();
</del><ins>+ m_token = cachedInfo->endFunctionToken();
+
</ins><span class="cx"> if (endColumnIsOnStartLine)
</span><span class="cx"> m_token.m_location.lineStartOffset = currentLineStartOffset;
</span><span class="cx">
</span><span class="cx"> m_lexer->setOffset(m_token.m_location.endOffset, m_token.m_location.lineStartOffset);
</span><span class="cx"> m_lexer->setLineNumber(m_token.m_location.line);
</span><del>-
</del><ins>+ info.endFunctionOffset = cachedInfo->endFunctionOffset;
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ if (parseType == ArrowFunctionParseType)
+ info.functionBodyType = cachedInfo->isBodyArrowExpression ? ArrowFunctionBodyExpression : ArrowFunctionBodyBlock;
+ else
+ info.functionBodyType = StandardFunctionBodyBlock;
+
+ switch (info.functionBodyType) {
+ case ArrowFunctionBodyExpression:
+ next();
+ context.setEndOffset(info.body, m_lexer->currentOffset());
+ break;
+ case ArrowFunctionBodyBlock:
+ case StandardFunctionBodyBlock:
+ context.setEndOffset(info.body, m_lexer->currentOffset());
+ next();
+ break;
+ }
+#else
</ins><span class="cx"> context.setEndOffset(info.body, m_lexer->currentOffset());
</span><del>-
</del><span class="cx"> next();
</span><ins>+#endif
</ins><span class="cx"> info.bodyEndLine = m_lastTokenEndPosition.line;
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> m_lastFunctionName = lastFunctionName;
</span><span class="cx"> ParserState oldState = saveState();
</span><del>- info.body = parseFunctionBody(context, functionKeywordStart, functionNameStart, parametersStart, constructorKind);
</del><ins>+
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ switch (info.functionBodyType) {
+ case ArrowFunctionBodyBlock: {
+ // Consume => in case of arrow function block e.g. x => { return x; }
+ next();
+
+ info.bodyStartLine = tokenLine();
+ info.bodyStartColumn = m_token.m_data.offset - m_token.m_data.lineStartOffset;
+
+ info.body = parseFunctionBody(context, functionKeywordStart, functionNameStart, parametersStart, constructorKind, StandardFunctionParseType);
+ break;
+ }
+ case StandardFunctionBodyBlock:
+ case ArrowFunctionBodyExpression : {
+ info.body = parseFunctionBody(context, functionKeywordStart, functionNameStart, parametersStart, constructorKind, parseType);
+ break;
+ }
+ }
+#else
+ info.body = parseFunctionBody(context, functionKeywordStart, functionNameStart, parametersStart, constructorKind, StandardFunctionParseType);
+#endif
+
</ins><span class="cx"> restoreState(oldState);
</span><span class="cx"> failIfFalse(info.body, "Cannot parse the body of this ", stringForFunctionMode(mode));
</span><span class="cx"> context.setEndOffset(info.body, m_lexer->currentOffset());
</span><span class="lines">@@ -1470,33 +1634,56 @@
</span><span class="cx"> if (functionScope->needsSuperBinding())
</span><span class="cx"> semanticFailIfTrue(expectedSuperBinding == SuperBinding::NotNeeded, "super can only be used in a method of a derived class");
</span><span class="cx">
</span><del>- info.closeBraceOffset = m_token.m_data.offset;
- unsigned closeBraceLine = m_token.m_data.line;
- unsigned closeBraceLineStartOffset = m_token.m_data.lineStartOffset;
</del><ins>+ JSTokenLocation location = JSTokenLocation(m_token.m_location);
+ info.endFunctionOffset = m_token.m_data.offset;
</ins><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ if (info.functionBodyType == ArrowFunctionBodyExpression) {
+ location = locationBeforeLastToken();
+ info.endFunctionOffset = location.endOffset;
+ }
+#endif
+
</ins><span class="cx"> // Cache the tokenizer state and the function scope the first time the function is parsed.
</span><span class="cx"> // Any future reparsing can then skip the function.
</span><span class="cx"> static const int minimumFunctionLengthToCache = 16;
</span><span class="cx"> std::unique_ptr<SourceProviderCacheItem> newInfo;
</span><del>- int functionLength = info.closeBraceOffset - info.openBraceOffset;
</del><ins>+ int functionLength = info.endFunctionOffset - info.startFunctionOffset;
</ins><span class="cx"> if (TreeBuilder::CanUseFunctionCache && m_functionCache && functionLength > minimumFunctionLengthToCache) {
</span><span class="cx"> SourceProviderCacheItemCreationParameters parameters;
</span><ins>+ parameters.endFunctionOffset = info.endFunctionOffset;
</ins><span class="cx"> parameters.functionNameStart = functionNameStart;
</span><del>- parameters.closeBraceLine = closeBraceLine;
- parameters.closeBraceOffset = info.closeBraceOffset;
- parameters.closeBraceLineStartOffset = closeBraceLineStartOffset;
</del><ins>+ parameters.lastTockenLine = location.line;
+ parameters.lastTockenStartOffset = location.startOffset;
+ parameters.lastTockenEndOffset = location.endOffset;
+ parameters.lastTockenLineStartOffset = location.lineStartOffset;
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ if (info.functionBodyType == ArrowFunctionBodyExpression) {
+ parameters.isBodyArrowExpression = true;
+ parameters.tokenType = m_token.m_type;
+ }
+#endif
</ins><span class="cx"> functionScope->fillParametersForSourceProviderCache(parameters);
</span><span class="cx"> newInfo = SourceProviderCacheItem::create(parameters);
</span><del>-
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> failIfFalse(popScope(functionScope, TreeBuilder::NeedsFreeVariableInfo), "Parser error");
</span><ins>+
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ if (info.functionBodyType == ArrowFunctionBodyExpression)
+ failIfFalse(isEndOfArrowFunction(), "Expected the closing ';' ',' ']' ')' '}', line terminator or EOF after arrow function");
+ else {
+ matchOrFail(CLOSEBRACE, "Expected a closing '}' after a ", stringForFunctionMode(mode), " body");
+ next();
+ }
+#else
</ins><span class="cx"> matchOrFail(CLOSEBRACE, "Expected a closing '}' after a ", stringForFunctionMode(mode), " body");
</span><ins>+ next();
+#endif
</ins><span class="cx">
</span><span class="cx"> if (newInfo)
</span><del>- m_functionCache->add(info.openBraceOffset, WTF::move(newInfo));
</del><ins>+ m_functionCache->add(info.startFunctionOffset, WTF::move(newInfo));
</ins><span class="cx">
</span><del>- next();
</del><span class="cx"> info.bodyEndLine = m_lastTokenEndPosition.line;
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="lines">@@ -1510,7 +1697,7 @@
</span><span class="cx"> next();
</span><span class="cx"> ParserFunctionInfo<TreeBuilder> info;
</span><span class="cx"> failIfFalse((parseFunctionInfo(context, FunctionNeedsName, FunctionMode, true, ConstructorKind::None, SuperBinding::NotNeeded,
</span><del>- functionKeywordStart, info)), "Cannot parse this function");
</del><ins>+ functionKeywordStart, info, StandardFunctionParseType)), "Cannot parse this function");
</ins><span class="cx"> failIfFalse(info.name, "Function statements must have a name");
</span><span class="cx"> failIfFalseIfStrict(declareVariable(info.name), "Cannot declare a function named '", info.name->impl(), "' in strict mode");
</span><span class="cx"> return context.createFuncDeclStatement(location, info);
</span><span class="lines">@@ -1629,8 +1816,7 @@
</span><span class="cx"> } else {
</span><span class="cx"> ParserFunctionInfo<TreeBuilder> methodInfo;
</span><span class="cx"> bool isConstructor = !isStaticMethod && *ident == propertyNames.constructor;
</span><del>- failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, isStaticMethod ? FunctionMode : MethodMode, false,
- isConstructor ? constructorKind : ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo)), "Cannot parse this method");
</del><ins>+ failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, isStaticMethod ? FunctionMode : MethodMode, false, isConstructor ? constructorKind : ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo, StandardFunctionParseType)), "Cannot parse this method");
</ins><span class="cx"> failIfFalse(ident && declareVariable(ident), "Cannot declare a method named '", methodInfo.name->impl(), "'");
</span><span class="cx"> methodInfo.name = isConstructor ? className : ident;
</span><span class="cx">
</span><span class="lines">@@ -1871,6 +2057,7 @@
</span><span class="cx"> return head;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> template <typename LexerType>
</span><span class="cx"> template <typename TreeBuilder> TreeExpression Parser<LexerType>::parseAssignmentExpression(TreeBuilder& context)
</span><span class="cx"> {
</span><span class="lines">@@ -1889,6 +2076,12 @@
</span><span class="cx"> }
</span><span class="cx"> restoreSavePoint(savePoint);
</span><span class="cx"> }
</span><ins>+
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ if (isArrowFunctionParamters())
+ return parseArrowFunctionExpression(context);
+#endif
+
</ins><span class="cx"> TreeExpression lhs = parseConditionalExpression(context);
</span><span class="cx"> failIfFalse(lhs, "Cannot parse expression");
</span><span class="cx"> if (initialNonLHSCount != m_nonLHSCount) {
</span><span class="lines">@@ -2129,8 +2322,7 @@
</span><span class="cx"> JSTokenLocation methodLocation(tokenLocation());
</span><span class="cx"> unsigned methodStart = tokenStart();
</span><span class="cx"> ParserFunctionInfo<TreeBuilder> methodInfo;
</span><del>- failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, MethodMode, false, ConstructorKind::None, SuperBinding::NotNeeded,
- methodStart, methodInfo)), "Cannot parse this method");
</del><ins>+ failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, MethodMode, false, ConstructorKind::None, SuperBinding::NotNeeded, methodStart, methodInfo, StandardFunctionParseType)), "Cannot parse this method");
</ins><span class="cx"> methodInfo.name = methodName;
</span><span class="cx"> return context.createFunctionExpr(methodLocation, methodInfo);
</span><span class="cx"> }
</span><span class="lines">@@ -2157,11 +2349,11 @@
</span><span class="cx"> if (type & PropertyNode::Getter) {
</span><span class="cx"> failIfFalse(match(OPENPAREN), "Expected a parameter list for getter definition");
</span><span class="cx"> failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, GetterMode, false, constructorKind, superBinding,
</span><del>- getterOrSetterStartOffset, info)), "Cannot parse getter definition");
</del><ins>+ getterOrSetterStartOffset, info, StandardFunctionParseType)), "Cannot parse getter definition");
</ins><span class="cx"> } else {
</span><span class="cx"> failIfFalse(match(OPENPAREN), "Expected a parameter list for setter definition");
</span><span class="cx"> failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SetterMode, false, constructorKind, superBinding,
</span><del>- getterOrSetterStartOffset, info)), "Cannot parse setter definition");
</del><ins>+ getterOrSetterStartOffset, info, StandardFunctionParseType)), "Cannot parse setter definition");
</ins><span class="cx"> }
</span><span class="cx"> if (stringPropertyName)
</span><span class="cx"> return context.createGetterOrSetterProperty(location, type, strict, stringPropertyName, info, superBinding);
</span><span class="lines">@@ -2428,8 +2620,7 @@
</span><span class="cx"> next();
</span><span class="cx"> ParserFunctionInfo<TreeBuilder> info;
</span><span class="cx"> info.name = &m_vm->propertyNames->nullIdentifier;
</span><del>- failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, FunctionMode, false, ConstructorKind::None, SuperBinding::NotNeeded,
- functionKeywordStart, info)), "Cannot parse function expression");
</del><ins>+ failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, FunctionMode, false, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, info, StandardFunctionParseType)), "Cannot parse function expression");
</ins><span class="cx"> return context.createFunctionExpr(location, info);
</span><span class="cx"> }
</span><span class="cx"> #if ENABLE(ES6_CLASS_SYNTAX)
</span><span class="lines">@@ -2669,6 +2860,22 @@
</span><span class="cx"> return base;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+template <typename LexerType>
+template <class TreeBuilder> TreeExpression Parser<LexerType>::parseArrowFunctionExpression(TreeBuilder& context)
+{
+ JSTokenLocation location;
+
+ unsigned functionKeywordStart = tokenStart();
+ location = tokenLocation();
+ ParserFunctionInfo<TreeBuilder> info;
+ info.name = &m_vm->propertyNames->nullIdentifier;
+ failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, FunctionMode, true, ConstructorKind::None, SuperBinding::NotNeeded, functionKeywordStart, info, ArrowFunctionParseType)), "Cannot parse arrow function expression");
+
+ return context.createArrowFunctionExpr(location, info);
+}
+#endif
+
</ins><span class="cx"> static const char* operatorString(bool prefix, unsigned tok)
</span><span class="cx"> {
</span><span class="cx"> switch (tok) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.h (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.h        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/Parser.h        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -80,12 +80,20 @@
</span><span class="cx"> COMPILE_ASSERT(LastUntaggedToken < 64, LessThan64UntaggedTokens);
</span><span class="cx">
</span><span class="cx"> enum SourceElementsMode { CheckForStrictMode, DontCheckForStrictMode };
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+enum FunctionParseType { StandardFunctionParseType, ArrowFunctionParseType };
+#else
+enum FunctionParseType { StandardFunctionParseType};
+#endif
</ins><span class="cx"> enum FunctionRequirements { FunctionNoRequirements, FunctionNeedsName };
</span><span class="cx"> enum FunctionParseMode {
</span><span class="cx"> FunctionMode,
</span><span class="cx"> GetterMode,
</span><span class="cx"> SetterMode,
</span><span class="cx"> MethodMode,
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ ArrowFunctionMode
+#endif
</ins><span class="cx"> };
</span><span class="cx"> enum DeconstructionKind {
</span><span class="cx"> DeconstructToVariables,
</span><span class="lines">@@ -430,6 +438,7 @@
</span><span class="cx"> std::unique_ptr<ParsedNode> parse(ParserError&);
</span><span class="cx">
</span><span class="cx"> JSTextPosition positionBeforeLastNewline() const { return m_lexer->positionBeforeLastNewline(); }
</span><ins>+ JSTokenLocation locationBeforeLastToken() const { return m_lexer->lastTokenLocation(); }
</ins><span class="cx"> Vector<RefPtr<UniquedStringImpl>>&& closedVariables() { return WTF::move(m_closedVariables); }
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -612,6 +621,47 @@
</span><span class="cx"> return m_token.m_type == IDENT && *m_token.m_data.ident == m_vm->propertyNames->of;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ ALWAYS_INLINE bool isEndOfArrowFunction()
+ {
+ return match(SEMICOLON) || match(COMMA) || match(CLOSEPAREN) || match(CLOSEBRACE) || match(CLOSEBRACKET) || match(EOFTOK) || m_lexer->prevTerminator();
+ }
+
+ ALWAYS_INLINE bool isArrowFunctionParamters()
+ {
+ bool isArrowFunction = false;
+
+ if (match(EOFTOK))
+ return isArrowFunction;
+
+ SavePoint saveArrowFunctionPoint = createSavePoint();
+
+ if (consume(OPENPAREN)) {
+ bool isArrowFunctionParamters = true;
+
+ while (consume(IDENT)) {
+ if (consume(COMMA)) {
+ if (!match(IDENT)) {
+ isArrowFunctionParamters = false;
+ break;
+ }
+ } else
+ break;
+ }
+
+ if (isArrowFunctionParamters) {
+ if (consume(CLOSEPAREN) && match(ARROWFUNCTION))
+ isArrowFunction = true;
+ }
+ } else if (consume(IDENT) && match(ARROWFUNCTION))
+ isArrowFunction = true;
+
+ restoreSavePoint(saveArrowFunctionPoint);
+
+ return isArrowFunction;
+ }
+#endif
+
</ins><span class="cx"> ALWAYS_INLINE unsigned tokenStart()
</span><span class="cx"> {
</span><span class="cx"> return m_token.m_location.startOffset;
</span><span class="lines">@@ -715,8 +765,8 @@
</span><span class="cx"> }
</span><span class="cx"> return result;
</span><span class="cx"> }
</span><del>-
- template <class TreeBuilder> TreeSourceElements parseSourceElements(TreeBuilder&, SourceElementsMode);
</del><ins>+
+ template <class TreeBuilder> TreeSourceElements parseSourceElements(TreeBuilder&, SourceElementsMode, FunctionParseType);
</ins><span class="cx"> template <class TreeBuilder> TreeStatement parseStatement(TreeBuilder&, const Identifier*& directive, unsigned* directiveLiteralLength = 0);
</span><span class="cx"> #if ENABLE(ES6_CLASS_SYNTAX)
</span><span class="cx"> template <class TreeBuilder> TreeStatement parseClassDeclaration(TreeBuilder&);
</span><span class="lines">@@ -756,24 +806,30 @@
</span><span class="cx"> template <class TreeBuilder> TreeProperty parseProperty(TreeBuilder&, bool strict);
</span><span class="cx"> template <class TreeBuilder> TreeExpression parsePropertyMethod(TreeBuilder& context, const Identifier* methodName);
</span><span class="cx"> template <class TreeBuilder> TreeProperty parseGetterSetter(TreeBuilder&, bool strict, PropertyNode::Type, unsigned getterOrSetterStartOffset, ConstructorKind = ConstructorKind::None, SuperBinding = SuperBinding::NotNeeded);
</span><del>- template <class TreeBuilder> ALWAYS_INLINE TreeFunctionBody parseFunctionBody(TreeBuilder&, int functionKeywordStart, int functionNameStart, int parametersStart, ConstructorKind);
</del><ins>+ template <class TreeBuilder> ALWAYS_INLINE TreeFunctionBody parseFunctionBody(TreeBuilder&, int functionKeywordStart, int functionNameStart, int parametersStart, ConstructorKind, FunctionParseType);
</ins><span class="cx"> template <class TreeBuilder> ALWAYS_INLINE TreeFormalParameterList parseFormalParameters(TreeBuilder&);
</span><span class="cx"> enum VarDeclarationListContext { ForLoopContext, VarDeclarationContext };
</span><span class="cx"> template <class TreeBuilder> TreeExpression parseVarDeclarationList(TreeBuilder&, int& declarations, TreeDeconstructionPattern& lastPattern, TreeExpression& lastInitializer, JSTextPosition& identStart, JSTextPosition& initStart, JSTextPosition& initEnd, VarDeclarationListContext);
</span><span class="cx"> template <class TreeBuilder> NEVER_INLINE TreeConstDeclList parseConstDeclarationList(TreeBuilder&);
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ template <class TreeBuilder> TreeStatement parseArrowFunctionSingleExpressionBody(TreeBuilder&, FunctionParseType);
+ template <class TreeBuilder> TreeExpression parseArrowFunctionExpression(TreeBuilder&);
+#endif
+
</ins><span class="cx"> template <class TreeBuilder> NEVER_INLINE TreeDeconstructionPattern createBindingPattern(TreeBuilder&, DeconstructionKind, const Identifier&, int depth, JSToken);
</span><span class="cx"> template <class TreeBuilder> NEVER_INLINE TreeDeconstructionPattern parseDeconstructionPattern(TreeBuilder&, DeconstructionKind, int depth = 0);
</span><span class="cx"> template <class TreeBuilder> NEVER_INLINE TreeDeconstructionPattern tryParseDeconstructionPatternExpression(TreeBuilder&);
</span><span class="cx"> template <class TreeBuilder> NEVER_INLINE TreeExpression parseDefaultValueForDeconstructionPattern(TreeBuilder&);
</span><span class="cx">
</span><del>- template <class TreeBuilder> NEVER_INLINE bool parseFunctionInfo(TreeBuilder&, FunctionRequirements, FunctionParseMode, bool nameIsInContainingScope, ConstructorKind, SuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>&);
</del><ins>+ template <class TreeBuilder> NEVER_INLINE bool parseFunctionInfo(TreeBuilder&, FunctionRequirements, FunctionParseMode, bool nameIsInContainingScope, ConstructorKind, SuperBinding, int functionKeywordStart, ParserFunctionInfo<TreeBuilder>&, FunctionParseType);
</ins><span class="cx">
</span><del>- template <class TreeBuilder> NEVER_INLINE int parseFunctionParameters(TreeBuilder&, FunctionRequirements, FunctionParseMode, bool, AutoPopScopeRef&, ParserFunctionInfo<TreeBuilder>&);
</del><ins>+ template <class TreeBuilder> NEVER_INLINE int parseFunctionParameters(TreeBuilder&, FunctionParseMode, ParserFunctionInfo<TreeBuilder>&);
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(ES6_CLASS_SYNTAX)
</span><span class="cx"> template <class TreeBuilder> NEVER_INLINE TreeClassExpression parseClass(TreeBuilder&, FunctionRequirements, ParserClassInfo<TreeBuilder>&);
</span><span class="cx"> #endif
</span><ins>+
</ins><span class="cx"> #if ENABLE(ES6_TEMPLATE_LITERAL_SYNTAX)
</span><span class="cx"> template <class TreeBuilder> NEVER_INLINE typename TreeBuilder::TemplateString parseTemplateString(TreeBuilder& context, bool isTemplateHead, typename LexerType::RawStringsBuildMode, bool& elementIsTail);
</span><span class="cx"> template <class TreeBuilder> NEVER_INLINE typename TreeBuilder::TemplateLiteral parseTemplateLiteral(TreeBuilder&, typename LexerType::RawStringsBuildMode);
</span><span class="lines">@@ -793,6 +849,14 @@
</span><span class="cx"> return allowAutomaticSemicolon();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ void setEndOfStatement()
+ {
+ m_lexer->setTokenPosition(&m_token);
+ }
+#endif
+
</ins><span class="cx"> bool canRecurse()
</span><span class="cx"> {
</span><span class="cx"> return m_vm->isSafeToRecurse();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserFunctionInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/ParserFunctionInfo.h (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/ParserFunctionInfo.h        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/ParserFunctionInfo.h        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -28,16 +28,27 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+enum FunctionBodyType { ArrowFunctionBodyExpression, ArrowFunctionBodyBlock, StandardFunctionBodyBlock };
+#endif
+
</ins><span class="cx"> template <class TreeBuilder>
</span><span class="cx"> struct ParserFunctionInfo {
</span><span class="cx"> const Identifier* name = 0;
</span><span class="cx"> typename TreeBuilder::FormalParameterList parameters = 0;
</span><span class="cx"> typename TreeBuilder::FunctionBody body = 0;
</span><del>- unsigned openBraceOffset = 0;
- unsigned closeBraceOffset = 0;
</del><ins>+ unsigned startFunctionOffset = 0;
+ unsigned endFunctionOffset = 0;
</ins><span class="cx"> int bodyStartLine = 0;
</span><span class="cx"> int bodyEndLine = 0;
</span><span class="cx"> unsigned bodyStartColumn = 0;
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ unsigned arrowFunctionOffset = 0;
+ unsigned arrowFunctionNextTockenEndOffset = 0;
+ bool isArrowFunction { false };
+ bool isEndByTerminator { false };
+ FunctionBodyType functionBodyType { StandardFunctionBodyBlock };
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #if ENABLE(ES6_CLASS_SYNTAX)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserTokensh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/ParserTokens.h (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/ParserTokens.h        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/ParserTokens.h        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -75,6 +75,9 @@
</span><span class="cx"> FINALLY,
</span><span class="cx"> DEBUGGER,
</span><span class="cx"> ELSE,
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ ARROWFUNCTION,
+#endif
</ins><span class="cx"> #if ENABLE(ES6_CLASS_SYNTAX)
</span><span class="cx"> CLASSTOKEN,
</span><span class="cx"> EXTENDS,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserSourceCodeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/SourceCode.h (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/SourceCode.h        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/SourceCode.h        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -105,6 +105,9 @@
</span><span class="cx">
</span><span class="cx"> SourceCode subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn);
</span><span class="cx">
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ SourceCode subArrowExpression(unsigned startArrowFunction, unsigned endArrowFunction, int firstLine, int startColumn);
+#endif
</ins><span class="cx"> private:
</span><span class="cx"> RefPtr<SourceProvider> m_provider;
</span><span class="cx"> int m_startChar;
</span><span class="lines">@@ -117,7 +120,17 @@
</span><span class="cx"> {
</span><span class="cx"> return SourceCode(StringSourceProvider::create(source, url, startPosition), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
</span><span class="cx"> }
</span><ins>+
+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ inline SourceCode SourceCode::subArrowExpression(unsigned startArrowFunction, unsigned endArrowFunction, int firstLine, int startColumn)
+ {
+ ASSERT(provider()->source()[startArrowFunction] == '=' && provider()->source()[startArrowFunction + 1] == '>');
</ins><span class="cx">
</span><ins>+ startColumn += 1; // Convert to base 1.
+ return SourceCode(provider(), startArrowFunction, endArrowFunction, firstLine, startColumn);
+ }
+#endif
+
</ins><span class="cx"> inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(provider()->source()[openBrace] == '{');
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserSourceProviderCacheItemh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/SourceProviderCacheItem.h (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/SourceProviderCacheItem.h        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/SourceProviderCacheItem.h        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -35,14 +35,20 @@
</span><span class="cx">
</span><span class="cx"> struct SourceProviderCacheItemCreationParameters {
</span><span class="cx"> unsigned functionNameStart;
</span><del>- unsigned closeBraceLine;
- unsigned closeBraceOffset;
- unsigned closeBraceLineStartOffset;
</del><ins>+ unsigned lastTockenLine;
+ unsigned lastTockenStartOffset;
+ unsigned lastTockenEndOffset;
+ unsigned lastTockenLineStartOffset;
+ unsigned endFunctionOffset;
</ins><span class="cx"> bool needsFullActivation;
</span><span class="cx"> bool usesEval;
</span><span class="cx"> bool strictMode;
</span><span class="cx"> Vector<RefPtr<UniquedStringImpl>> usedVariables;
</span><span class="cx"> Vector<RefPtr<UniquedStringImpl>> writtenVariables;
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ bool isBodyArrowExpression { false };
+ JSTokenType tokenType { CLOSEBRACE };
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #if COMPILER(MSVC)
</span><span class="lines">@@ -56,15 +62,19 @@
</span><span class="cx"> static std::unique_ptr<SourceProviderCacheItem> create(const SourceProviderCacheItemCreationParameters&);
</span><span class="cx"> ~SourceProviderCacheItem();
</span><span class="cx">
</span><del>- JSToken closeBraceToken() const
</del><ins>+ JSToken endFunctionToken() const
</ins><span class="cx"> {
</span><span class="cx"> JSToken token;
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ token.m_type = isBodyArrowExpression ? tokenType : CLOSEBRACE;
+#else
</ins><span class="cx"> token.m_type = CLOSEBRACE;
</span><del>- token.m_data.offset = closeBraceOffset;
- token.m_location.startOffset = closeBraceOffset;
- token.m_location.endOffset = closeBraceOffset + 1;
- token.m_location.line = closeBraceLine;
- token.m_location.lineStartOffset = closeBraceLineStartOffset;
</del><ins>+#endif
+ token.m_data.offset = lastTockenStartOffset;
+ token.m_location.startOffset = lastTockenStartOffset;
+ token.m_location.endOffset = lastTockenEndOffset;
+ token.m_location.line = lastTockenLine;
+ token.m_location.lineStartOffset = lastTockenLineStartOffset;
</ins><span class="cx"> // token.m_location.sourceOffset is initialized once by the client. So,
</span><span class="cx"> // we do not need to set it here.
</span><span class="cx"> return token;
</span><span class="lines">@@ -72,19 +82,26 @@
</span><span class="cx">
</span><span class="cx"> unsigned functionNameStart : 31;
</span><span class="cx"> bool needsFullActivation : 1;
</span><ins>+
+ unsigned endFunctionOffset : 31;
+ unsigned lastTockenLine : 31;
+ unsigned lastTockenStartOffset : 31;
+ unsigned lastTockenEndOffset: 31;
</ins><span class="cx">
</span><del>- unsigned closeBraceLine : 31;
</del><span class="cx"> bool usesEval : 1;
</span><span class="cx">
</span><del>- unsigned closeBraceOffset : 31;
</del><span class="cx"> bool strictMode : 1;
</span><span class="cx">
</span><del>- unsigned closeBraceLineStartOffset;
</del><ins>+ unsigned lastTockenLineStartOffset;
</ins><span class="cx"> unsigned usedVariablesCount;
</span><span class="cx"> unsigned writtenVariablesCount;
</span><span class="cx">
</span><span class="cx"> UniquedStringImpl** usedVariables() const { return const_cast<UniquedStringImpl**>(m_variables); }
</span><span class="cx"> UniquedStringImpl** writtenVariables() const { return const_cast<UniquedStringImpl**>(&m_variables[usedVariablesCount]); }
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ bool isBodyArrowExpression;
+ JSTokenType tokenType;
+#endif
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> SourceProviderCacheItem(const SourceProviderCacheItemCreationParameters&);
</span><span class="lines">@@ -109,13 +126,19 @@
</span><span class="cx"> inline SourceProviderCacheItem::SourceProviderCacheItem(const SourceProviderCacheItemCreationParameters& parameters)
</span><span class="cx"> : functionNameStart(parameters.functionNameStart)
</span><span class="cx"> , needsFullActivation(parameters.needsFullActivation)
</span><del>- , closeBraceLine(parameters.closeBraceLine)
</del><ins>+ , endFunctionOffset(parameters.endFunctionOffset)
+ , lastTockenLine(parameters.lastTockenLine)
+ , lastTockenStartOffset(parameters.lastTockenStartOffset)
+ , lastTockenEndOffset(parameters.lastTockenEndOffset)
</ins><span class="cx"> , usesEval(parameters.usesEval)
</span><del>- , closeBraceOffset(parameters.closeBraceOffset)
</del><span class="cx"> , strictMode(parameters.strictMode)
</span><del>- , closeBraceLineStartOffset(parameters.closeBraceLineStartOffset)
</del><ins>+ , lastTockenLineStartOffset(parameters.lastTockenLineStartOffset)
</ins><span class="cx"> , usedVariablesCount(parameters.usedVariables.size())
</span><span class="cx"> , writtenVariablesCount(parameters.writtenVariables.size())
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ , isBodyArrowExpression(parameters.isBodyArrowExpression)
+ , tokenType(parameters.tokenType)
+#endif
</ins><span class="cx"> {
</span><span class="cx"> unsigned j = 0;
</span><span class="cx"> for (unsigned i = 0; i < usedVariablesCount; ++i, ++j) {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserSyntaxCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/SyntaxChecker.h (185988 => 185989)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/SyntaxChecker.h        2015-06-26 06:42:39 UTC (rev 185988)
+++ trunk/Source/JavaScriptCore/parser/SyntaxChecker.h        2015-06-26 06:49:20 UTC (rev 185989)
</span><span class="lines">@@ -179,6 +179,10 @@
</span><span class="cx"> #endif
</span><span class="cx"> ExpressionType createFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
</span><span class="cx"> int createFunctionBody(const JSTokenLocation&, const JSTokenLocation&, int, int, bool, int, int, int, ConstructorKind) { return FunctionBodyResult; }
</span><ins>+#if ENABLE(ES6_ARROWFUNCTION_SYNTAX)
+ ExpressionType createArrowFunctionExpr(const JSTokenLocation&, const ParserFunctionInfo<SyntaxChecker>&) { return FunctionExpr; }
+#endif
+ void setFunctionNameStart(int, int) { }
</ins><span class="cx"> int createArguments() { return ArgumentsResult; }
</span><span class="cx"> int createArguments(int) { return ArgumentsResult; }
</span><span class="cx"> ExpressionType createSpreadExpression(const JSTokenLocation&, ExpressionType, int, int, int) { return SpreadExpr; }
</span></span></pre>
</div>
</div>
</body>
</html>