<!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>[179371] 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/179371">179371</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2015-01-29 14:59:19 -0800 (Thu, 29 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement ES6 class syntax without inheritance support
https://bugs.webkit.org/show_bug.cgi?id=140918

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Added the most basic support for ES6 class syntax. After this patch, we support basic class definition like:
class A {
    constructor() { }
    someMethod() { }
}

We'll add the support for &quot;extends&quot; keyword and automatically generating a constructor in follow up patches.
We also don't support block scoping of a class declaration.

We support both class declaration and class expression. A class expression is implemented by the newly added
ClassExprNode AST node. A class declaration is implemented by ClassDeclNode, which is a thin wrapper around
AssignResolveNode.

Tests: js/class-syntax-declaration.html
       js/class-syntax-expression.html

* bytecompiler/NodesCodegen.cpp:
(JSC::ObjectLiteralNode::emitBytecode): Create a new object instead of delegating the work to PropertyListNode.
Also fixed the 5-space indentation.
(JSC::PropertyListNode::emitBytecode): Don't create a new object now that ObjectLiteralNode does this.
(JSC::ClassDeclNode::emitBytecode): Added. Just let the AssignResolveNode node emit the byte code.
(JSC::ClassExprNode::emitBytecode): Create the class constructor and add static methods to the constructor by
emitting the byte code for PropertyListNode. Add instance methods to the class's prototype object the same way.

* parser/ASTBuilder.h:
(JSC::ASTBuilder::createClassExpr): Added. Creates a ClassExprNode.
(JSC::ASTBuilder::createClassDeclStatement): Added. Creates a AssignResolveNode and wraps it by a ClassDeclNode.

* parser/NodeConstructors.h:
(JSC::ClassDeclNode::ClassDeclNode): Added.
(JSC::ClassExprNode::ClassExprNode): Added.

* parser/Nodes.h:
(JSC::ClassExprNode): Added.
(JSC::ClassDeclNode): Added.

* parser/Parser.cpp:
(JSC::Parser&lt;LexerType&gt;::parseStatement): Added the support for class declaration.
(JSC::stringForFunctionMode): Return &quot;method&quot; for MethodMode.
(JSC::Parser&lt;LexerType&gt;::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps
it with ClassDeclNode as described above.
(JSC::Parser&lt;LexerType&gt;::parseClass): Parses a class expression.
(JSC::Parser&lt;LexerType&gt;::parseProperty):
(JSC::Parser&lt;LexerType&gt;::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty
and parseClass.
(JSC::Parser&lt;LexerType&gt;::parsePrimaryExpression): Added the support for class expression.

* parser/Parser.h:
(FunctionParseMode): Added MethodMode.

* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createClassExpr): Added.
(JSC::SyntaxChecker::createClassDeclStatement): Added.

LayoutTests:

Added two tests for class declarations and class expressions.

* TestExpectations:
* js/class-syntax-declaration-expected.txt: Added.
* js/class-syntax-declaration.html: Added.
* js/class-syntax-expression-expected.txt: Added.
* js/class-syntax-expression.html: Added.
* js/script-tests/class-syntax-declaration.js: Added.
* js/script-tests/class-syntax-expression.js: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecompilerNodesCodegencpp">trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserASTBuilderh">trunk/Source/JavaScriptCore/parser/ASTBuilder.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserNodeConstructorsh">trunk/Source/JavaScriptCore/parser/NodeConstructors.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreparserNodesh">trunk/Source/JavaScriptCore/parser/Nodes.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="#trunkSourceJavaScriptCoreparserSyntaxCheckerh">trunk/Source/JavaScriptCore/parser/SyntaxChecker.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsclasssyntaxdeclarationexpectedtxt">trunk/LayoutTests/js/class-syntax-declaration-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsclasssyntaxdeclarationhtml">trunk/LayoutTests/js/class-syntax-declaration.html</a></li>
<li><a href="#trunkLayoutTestsjsclasssyntaxexpressionexpectedtxt">trunk/LayoutTests/js/class-syntax-expression-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsclasssyntaxexpressionhtml">trunk/LayoutTests/js/class-syntax-expression.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsclasssyntaxdeclarationjs">trunk/LayoutTests/js/script-tests/class-syntax-declaration.js</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsclasssyntaxexpressionjs">trunk/LayoutTests/js/script-tests/class-syntax-expression.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/LayoutTests/ChangeLog        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-01-29  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Implement ES6 class syntax without inheritance support
+        https://bugs.webkit.org/show_bug.cgi?id=140918
+
+        Reviewed by Geoffrey Garen.
+
+        Added two tests for class declarations and class expressions.
+
+        * TestExpectations:
+        * js/class-syntax-declaration-expected.txt: Added.
+        * js/class-syntax-declaration.html: Added.
+        * js/class-syntax-expression-expected.txt: Added.
+        * js/class-syntax-expression.html: Added.
+        * js/script-tests/class-syntax-declaration.js: Added.
+        * js/script-tests/class-syntax-expression.js: Added.
+
</ins><span class="cx"> 2015-01-29  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Border-radius clipping on a stacking context causes descendants to not render
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/LayoutTests/TestExpectations        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -66,6 +66,10 @@
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/127860 [ Debug ] js/function-apply-aliased.html [ Skip ]
</span><span class="cx"> 
</span><ins>+# ES6 class syntax hasn't been enabled yet.
+webkit.org/b/140491 js/class-syntax-declaration.html [ Failure ]
+webkit.org/b/140491 js/class-syntax-expression.html [ Failure ]
+
</ins><span class="cx"> # This test verifies dynamic manipulation of the mroot and msqrt elements.
</span><span class="cx"> mathml/roots-removeChild.html [ ImageOnlyFailure ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsjsclasssyntaxdeclarationexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/class-syntax-declaration-expected.txt (0 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/class-syntax-declaration-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/class-syntax-declaration-expected.txt        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+PASS constructorCallCount is 0
+PASS A.someStaticMethod() is staticMethodValue
+PASS (new A).someInstanceMethod() is instanceMethodValue
+PASS constructorCallCount is 1
+PASS (new A).someGetter is getterValue
+PASS constructorCallCount is 2
+PASS (new A).someGetter is getterValue
+PASS setterValue is undefined
+PASS (new A).someSetter = 789 did not throw exception.
+PASS setterValue is 789
+PASS (new A).__proto__ is A.prototype
+PASS A.prototype.constructor is A
+PASS class threw exception SyntaxError: Unexpected end of script.
+PASS class X { threw exception SyntaxError: Unexpected end of script.
+PASS class X { ( } threw exception SyntaxError: Unexpected token '('. Expected an indentifier..
+PASS class X {} threw exception SyntaxError: Class declaration without a constructor is not supported yet..
+PASS class X { constructor() {} constructor() {} } threw exception SyntaxError: Cannot declare multiple constructors in a single class..
+PASS class X { constructor() {} static constructor() { return staticMethodValue; } } did not throw exception.
+PASS X.constructor() is staticMethodValue
+PASS class X { constructor() {} static prototype() {} } threw exception SyntaxError: Cannot declare a static method named 'prototype'..
+PASS class X { constructor() {} prototype() { return instanceMethodValue; } } did not throw exception.
+PASS (new X).prototype() is instanceMethodValue
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsclasssyntaxdeclarationhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/class-syntax-declaration.html (0 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/class-syntax-declaration.html                                (rev 0)
+++ trunk/LayoutTests/js/class-syntax-declaration.html        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/class-syntax-declaration.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsclasssyntaxexpressionexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/class-syntax-expression-expected.txt (0 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/class-syntax-expression-expected.txt                                (rev 0)
+++ trunk/LayoutTests/js/class-syntax-expression-expected.txt        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -0,0 +1,26 @@
</span><ins>+PASS constructorCallCount is 0
+PASS A.someStaticMethod() is staticMethodValue
+PASS (new A).someInstanceMethod() is instanceMethodValue
+PASS constructorCallCount is 1
+PASS (new A).someGetter is getterValue
+PASS constructorCallCount is 2
+PASS (new A).someGetter is getterValue
+PASS setterValue is undefined
+PASS (new A).someSetter = 789 did not throw exception.
+PASS setterValue is 789
+PASS (new A).__proto__ is A.prototype
+PASS A.prototype.constructor is A
+PASS x = class threw exception SyntaxError: Unexpected end of script.
+PASS x = class { threw exception SyntaxError: Unexpected end of script.
+PASS x = class { ( } threw exception SyntaxError: Unexpected token '('. Expected an indentifier..
+PASS x = class {} threw exception SyntaxError: Class declaration without a constructor is not supported yet..
+PASS x = class { constructor() {} constructor() {} } threw exception SyntaxError: Cannot declare multiple constructors in a single class..
+PASS x = class { constructor() {} static constructor() { return staticMethodValue; } } did not throw exception.
+PASS x.constructor() is staticMethodValue
+PASS x = class { constructor() {} static prototype() {} } threw exception SyntaxError: Cannot declare a static method named 'prototype'..
+PASS x = class { constructor() {} prototype() { return instanceMethodValue; } } did not throw exception.
+PASS (new x).prototype() is instanceMethodValue
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsclasssyntaxexpressionhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/class-syntax-expression.html (0 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/class-syntax-expression.html                                (rev 0)
+++ trunk/LayoutTests/js/class-syntax-expression.html        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -0,0 +1,8 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;body&gt;
+&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;script-tests/class-syntax-expression.js&quot;&gt;&lt;/script&gt;
+&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsclasssyntaxdeclarationjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/class-syntax-declaration.js (0 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/class-syntax-declaration.js                                (rev 0)
+++ trunk/LayoutTests/js/script-tests/class-syntax-declaration.js        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+var constructorCallCount = 0;
+const staticMethodValue = [1];
+const instanceMethodValue = [2];
+const getterValue = [3];
+var setterValue = undefined;
+class A {
+    constructor() { constructorCallCount++; }
+    static someStaticMethod() { return staticMethodValue; }
+    someInstanceMethod() { return instanceMethodValue; }
+    get someGetter() { return getterValue; }
+    set someSetter(value) { setterValue = value; }
+}
+
+shouldBe(&quot;constructorCallCount&quot;, &quot;0&quot;);
+shouldBe(&quot;A.someStaticMethod()&quot;, &quot;staticMethodValue&quot;);
+shouldBe(&quot;(new A).someInstanceMethod()&quot;, &quot;instanceMethodValue&quot;);
+shouldBe(&quot;constructorCallCount&quot;, &quot;1&quot;);
+shouldBe(&quot;(new A).someGetter&quot;, &quot;getterValue&quot;);
+shouldBe(&quot;constructorCallCount&quot;, &quot;2&quot;);
+shouldBe(&quot;(new A).someGetter&quot;, &quot;getterValue&quot;);
+shouldBe(&quot;setterValue&quot;, &quot;undefined&quot;);
+shouldNotThrow(&quot;(new A).someSetter = 789&quot;);
+shouldBe(&quot;setterValue&quot;, &quot;789&quot;);
+shouldBe(&quot;(new A).__proto__&quot;, &quot;A.prototype&quot;);
+shouldBe(&quot;A.prototype.constructor&quot;, &quot;A&quot;);
+
+shouldThrow(&quot;class&quot;, &quot;'SyntaxError: Unexpected end of script'&quot;);
+shouldThrow(&quot;class X {&quot;, &quot;'SyntaxError: Unexpected end of script'&quot;);
+shouldThrow(&quot;class X { ( }&quot;, &quot;'SyntaxError: Unexpected token \\'(\\'. Expected an indentifier.'&quot;);
+shouldThrow(&quot;class X {}&quot;, &quot;'SyntaxError: Class declaration without a constructor is not supported yet.'&quot;);
+shouldThrow(&quot;class X { constructor() {} constructor() {} }&quot;, &quot;'SyntaxError: Cannot declare multiple constructors in a single class.'&quot;);
+shouldNotThrow(&quot;class X { constructor() {} static constructor() { return staticMethodValue; } }&quot;);
+shouldBe(&quot;X.constructor()&quot;, &quot;staticMethodValue&quot;);
+shouldThrow(&quot;class X { constructor() {} static prototype() {} }&quot;, &quot;'SyntaxError: Cannot declare a static method named \\'prototype\\'.'&quot;);
+shouldNotThrow(&quot;class X { constructor() {} prototype() { return instanceMethodValue; } }&quot;);
+shouldBe(&quot;(new X).prototype()&quot;, &quot;instanceMethodValue&quot;);
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsclasssyntaxexpressionjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/class-syntax-expression.js (0 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/class-syntax-expression.js                                (rev 0)
+++ trunk/LayoutTests/js/script-tests/class-syntax-expression.js        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+var constructorCallCount = 0;
+const staticMethodValue = [1];
+const instanceMethodValue = [2];
+const getterValue = [3];
+var setterValue = undefined;
+var A = class {
+    constructor() { constructorCallCount++; }
+    static someStaticMethod() { return staticMethodValue; }
+    someInstanceMethod() { return instanceMethodValue; }
+    get someGetter() { return getterValue; }
+    set someSetter(value) { setterValue = value; }
+};
+
+shouldBe(&quot;constructorCallCount&quot;, &quot;0&quot;);
+shouldBe(&quot;A.someStaticMethod()&quot;, &quot;staticMethodValue&quot;);
+shouldBe(&quot;(new A).someInstanceMethod()&quot;, &quot;instanceMethodValue&quot;);
+shouldBe(&quot;constructorCallCount&quot;, &quot;1&quot;);
+shouldBe(&quot;(new A).someGetter&quot;, &quot;getterValue&quot;);
+shouldBe(&quot;constructorCallCount&quot;, &quot;2&quot;);
+shouldBe(&quot;(new A).someGetter&quot;, &quot;getterValue&quot;);
+shouldBe(&quot;setterValue&quot;, &quot;undefined&quot;);
+shouldNotThrow(&quot;(new A).someSetter = 789&quot;);
+shouldBe(&quot;setterValue&quot;, &quot;789&quot;);
+shouldBe(&quot;(new A).__proto__&quot;, &quot;A.prototype&quot;);
+shouldBe(&quot;A.prototype.constructor&quot;, &quot;A&quot;);
+
+shouldThrow(&quot;x = class&quot;, &quot;'SyntaxError: Unexpected end of script'&quot;);
+shouldThrow(&quot;x = class {&quot;, &quot;'SyntaxError: Unexpected end of script'&quot;);
+shouldThrow(&quot;x = class { ( }&quot;, &quot;'SyntaxError: Unexpected token \\'(\\'. Expected an indentifier.'&quot;);
+shouldThrow(&quot;x = class {}&quot;, &quot;'SyntaxError: Class declaration without a constructor is not supported yet.'&quot;);
+shouldThrow(&quot;x = class { constructor() {} constructor() {} }&quot;, &quot;'SyntaxError: Cannot declare multiple constructors in a single class.'&quot;);
+shouldNotThrow(&quot;x = class { constructor() {} static constructor() { return staticMethodValue; } }&quot;);
+shouldBe(&quot;x.constructor()&quot;, &quot;staticMethodValue&quot;);
+shouldThrow(&quot;x = class { constructor() {} static prototype() {} }&quot;, &quot;'SyntaxError: Cannot declare a static method named \\'prototype\\'.'&quot;);
+shouldNotThrow(&quot;x = class { constructor() {} prototype() { return instanceMethodValue; } }&quot;);
+shouldBe(&quot;(new x).prototype()&quot;, &quot;instanceMethodValue&quot;);
+
+var successfullyParsed = true;
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -1,3 +1,64 @@
</span><ins>+2015-01-29  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Implement ES6 class syntax without inheritance support
+        https://bugs.webkit.org/show_bug.cgi?id=140918
+
+        Reviewed by Geoffrey Garen.
+
+        Added the most basic support for ES6 class syntax. After this patch, we support basic class definition like:
+        class A {
+            constructor() { }
+            someMethod() { }
+        }
+
+        We'll add the support for &quot;extends&quot; keyword and automatically generating a constructor in follow up patches.
+        We also don't support block scoping of a class declaration.
+
+        We support both class declaration and class expression. A class expression is implemented by the newly added
+        ClassExprNode AST node. A class declaration is implemented by ClassDeclNode, which is a thin wrapper around
+        AssignResolveNode.
+
+        Tests: js/class-syntax-declaration.html
+               js/class-syntax-expression.html
+
+        * bytecompiler/NodesCodegen.cpp:
+        (JSC::ObjectLiteralNode::emitBytecode): Create a new object instead of delegating the work to PropertyListNode.
+        Also fixed the 5-space indentation.
+        (JSC::PropertyListNode::emitBytecode): Don't create a new object now that ObjectLiteralNode does this.
+        (JSC::ClassDeclNode::emitBytecode): Added. Just let the AssignResolveNode node emit the byte code.
+        (JSC::ClassExprNode::emitBytecode): Create the class constructor and add static methods to the constructor by
+        emitting the byte code for PropertyListNode. Add instance methods to the class's prototype object the same way.
+
+        * parser/ASTBuilder.h:
+        (JSC::ASTBuilder::createClassExpr): Added. Creates a ClassExprNode.
+        (JSC::ASTBuilder::createClassDeclStatement): Added. Creates a AssignResolveNode and wraps it by a ClassDeclNode.
+
+        * parser/NodeConstructors.h:
+        (JSC::ClassDeclNode::ClassDeclNode): Added.
+        (JSC::ClassExprNode::ClassExprNode): Added.
+
+        * parser/Nodes.h:
+        (JSC::ClassExprNode): Added.
+        (JSC::ClassDeclNode): Added.
+
+        * parser/Parser.cpp:
+        (JSC::Parser&lt;LexerType&gt;::parseStatement): Added the support for class declaration.
+        (JSC::stringForFunctionMode): Return &quot;method&quot; for MethodMode.
+        (JSC::Parser&lt;LexerType&gt;::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps
+        it with ClassDeclNode as described above.
+        (JSC::Parser&lt;LexerType&gt;::parseClass): Parses a class expression.
+        (JSC::Parser&lt;LexerType&gt;::parseProperty):
+        (JSC::Parser&lt;LexerType&gt;::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty
+        and parseClass.
+        (JSC::Parser&lt;LexerType&gt;::parsePrimaryExpression): Added the support for class expression.
+
+        * parser/Parser.h:
+        (FunctionParseMode): Added MethodMode.
+
+        * parser/SyntaxChecker.h:
+        (JSC::SyntaxChecker::createClassExpr): Added.
+        (JSC::SyntaxChecker::createClassDeclStatement): Added.
+
</ins><span class="cx"> 2015-01-29  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Try to fix the Windows build.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecompilerNodesCodegencpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -273,26 +273,24 @@
</span><span class="cx"> 
</span><span class="cx"> RegisterID* ObjectLiteralNode::emitBytecode(BytecodeGenerator&amp; generator, RegisterID* dst)
</span><span class="cx"> {
</span><del>-     if (!m_list) {
-         if (dst == generator.ignoredResult())
-             return 0;
-         return generator.emitNewObject(generator.finalDestination(dst));
-     }
-     return generator.emitNode(dst, m_list);
</del><ins>+    if (!m_list) {
+        if (dst == generator.ignoredResult())
+            return 0;
+        return generator.emitNewObject(generator.finalDestination(dst));
+    }
+    RefPtr&lt;RegisterID&gt; newObj = generator.emitNewObject(generator.tempDestination(dst));
+    generator.emitNode(newObj.get(), m_list);
+    return generator.moveToDestinationIfNeeded(dst, newObj.get());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // ------------------------------ PropertyListNode -----------------------------
</span><span class="cx"> 
</span><span class="cx"> RegisterID* PropertyListNode::emitBytecode(BytecodeGenerator&amp; generator, RegisterID* dst)
</span><span class="cx"> {
</span><del>-    RefPtr&lt;RegisterID&gt; newObj = generator.tempDestination(dst);
-    
-    generator.emitNewObject(newObj.get());
-    
</del><span class="cx">     // Fast case: this loop just handles regular value properties.
</span><span class="cx">     PropertyListNode* p = this;
</span><span class="cx">     for (; p &amp;&amp; p-&gt;m_node-&gt;m_type == PropertyNode::Constant; p = p-&gt;m_next)
</span><del>-        emitPutConstantProperty(generator, newObj.get(), *p-&gt;m_node);
</del><ins>+        emitPutConstantProperty(generator, dst, *p-&gt;m_node);
</ins><span class="cx"> 
</span><span class="cx">     // Were there any get/set properties?
</span><span class="cx">     if (p) {
</span><span class="lines">@@ -318,7 +316,7 @@
</span><span class="cx"> 
</span><span class="cx">             // Handle regular values.
</span><span class="cx">             if (node-&gt;m_type == PropertyNode::Constant) {
</span><del>-                emitPutConstantProperty(generator, newObj.get(), *node);
</del><ins>+                emitPutConstantProperty(generator, dst, *node);
</ins><span class="cx">                 continue;
</span><span class="cx">             }
</span><span class="cx"> 
</span><span class="lines">@@ -359,11 +357,11 @@
</span><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx"> 
</span><del>-            generator.emitPutGetterSetter(newObj.get(), *node-&gt;name(), getterReg.get(), setterReg.get());
</del><ins>+            generator.emitPutGetterSetter(dst, *node-&gt;name(), getterReg.get(), setterReg.get());
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    return generator.moveToDestinationIfNeeded(dst, newObj.get());
</del><ins>+    return dst;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PropertyListNode::emitPutConstantProperty(BytecodeGenerator&amp; generator, RegisterID* newObj, PropertyNode&amp; node)
</span><span class="lines">@@ -2753,6 +2751,33 @@
</span><span class="cx"> {
</span><span class="cx">     return generator.emitNewFunctionExpression(generator.finalDestination(dst), this);
</span><span class="cx"> }
</span><ins>+
+#if ENABLE(ES6_CLASS_SYNTAX)
+// ------------------------------ ClassDeclNode ---------------------------------
+
+void ClassDeclNode::emitBytecode(BytecodeGenerator&amp; generator, RegisterID* dst)
+{
+    generator.emitNode(dst, m_classDeclaration);
+}
+
+// ------------------------------ ClassExprNode ---------------------------------
+
+RegisterID* ClassExprNode::emitBytecode(BytecodeGenerator&amp; generator, RegisterID* dst)
+{
+    ASSERT(!m_parentClassExpression);
+
+    RefPtr&lt;RegisterID&gt; constructor = generator.emitNode(dst, m_constructorExpression);
+    RefPtr&lt;RegisterID&gt; prototype = generator.emitGetById(generator.newTemporary(), constructor.get(), generator.propertyNames().prototype);
+
+    if (m_staticMethods)
+        generator.emitNode(constructor.get(), m_staticMethods);
+
+    if (m_instanceMethods)
+        generator.emitNode(prototype.get(), m_instanceMethods);
+
+    return generator.moveToDestinationIfNeeded(dst, constructor.get());
+}
+#endif
</ins><span class="cx">     
</span><span class="cx"> // ------------------------------ DeconstructingAssignmentNode -----------------
</span><span class="cx"> RegisterID* DeconstructingAssignmentNode::emitBytecode(BytecodeGenerator&amp; generator, RegisterID* dst)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserASTBuilderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/ASTBuilder.h (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/ASTBuilder.h        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/Source/JavaScriptCore/parser/ASTBuilder.h        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -104,6 +104,9 @@
</span><span class="cx">     typedef ArgumentListNode* ArgumentsList;
</span><span class="cx">     typedef ParameterNode* FormalParameterList;
</span><span class="cx">     typedef FunctionBodyNode* FunctionBody;
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    typedef ClassExprNode* ClassExpression;
+#endif
</ins><span class="cx">     typedef StatementNode* Statement;
</span><span class="cx">     typedef ClauseListNode* ClauseList;
</span><span class="cx">     typedef CaseClauseNode* Clause;
</span><span class="lines">@@ -273,6 +276,14 @@
</span><span class="cx">         return node;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    ClassExprNode* createClassExpr(const JSTokenLocation&amp; location, const Identifier&amp; name, ExpressionNode* constructor,
+        ExpressionNode* parentClass, PropertyListNode* instanceMethods, PropertyListNode* staticMethods)
+    {
+        return new (m_parserArena) ClassExprNode(location, name, constructor, parentClass, instanceMethods, staticMethods);
+    }
+#endif
+
</ins><span class="cx">     ExpressionNode* createFunctionExpr(const JSTokenLocation&amp; location, const ParserFunctionInfo&lt;ASTBuilder&gt;&amp; info, unsigned functionKeywordStart)
</span><span class="cx">     {
</span><span class="cx">         FuncExprNode* result = new (m_parserArena) FuncExprNode(location, *info.name, info.body,
</span><span class="lines">@@ -353,6 +364,18 @@
</span><span class="cx">         return decl;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    StatementNode* createClassDeclStatement(const JSTokenLocation&amp; location, ClassExprNode* classExpression,
+        const JSTextPosition&amp; classStart, const JSTextPosition&amp; classEnd, unsigned startLine, unsigned endLine)
+    {
+        // FIXME: Use &quot;let&quot; declaration.
+        ExpressionNode* assign = createAssignResolve(location, classExpression-&gt;name(), classExpression, classStart, classStart + 1, classEnd);
+        ClassDeclNode* decl = new (m_parserArena) ClassDeclNode(location, assign);
+        decl-&gt;setLoc(startLine, endLine, location.startOffset, location.lineStartOffset);
+        return decl;
+    }
+#endif
+
</ins><span class="cx">     StatementNode* createBlockStatement(const JSTokenLocation&amp; location, JSC::SourceElements* elements, int startLine, int endLine)
</span><span class="cx">     {
</span><span class="cx">         BlockNode* block = new (m_parserArena) BlockNode(location, elements);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserNodeConstructorsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/NodeConstructors.h (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/NodeConstructors.h        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/Source/JavaScriptCore/parser/NodeConstructors.h        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -768,6 +768,24 @@
</span><span class="cx">         m_body-&gt;finishParsing(source, parameter, ident, FunctionDeclaration);
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    inline ClassDeclNode::ClassDeclNode(const JSTokenLocation&amp; location, ExpressionNode* classDeclaration)
+        : StatementNode(location)
+        , m_classDeclaration(classDeclaration)
+    {
+    }
+
+    inline ClassExprNode::ClassExprNode(const JSTokenLocation&amp; location, const Identifier&amp; name, ExpressionNode* constructorExpression, ExpressionNode* parentClassExpression, PropertyListNode* instanceMethods, PropertyListNode* staticMethods)
+        : ExpressionNode(location)
+        , m_name(name)
+        , m_constructorExpression(constructorExpression)
+        , m_parentClassExpression(parentClassExpression)
+        , m_instanceMethods(instanceMethods)
+        , m_staticMethods(staticMethods)
+    {
+    }
+#endif
+
</ins><span class="cx">     inline CaseClauseNode::CaseClauseNode(ExpressionNode* expr, SourceElements* statements)
</span><span class="cx">         : m_expr(expr)
</span><span class="cx">         , m_statements(statements)
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserNodesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Nodes.h (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Nodes.h        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/Source/JavaScriptCore/parser/Nodes.h        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -1611,6 +1611,25 @@
</span><span class="cx">         FunctionBodyNode* m_body;
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    class ClassExprNode final : public ExpressionNode {
+    public:
+        ClassExprNode(const JSTokenLocation&amp;, const Identifier&amp;, ExpressionNode* constructorExpresssion,
+            ExpressionNode* parentClass, PropertyListNode* instanceMethods, PropertyListNode* staticMethods);
+
+        const Identifier&amp; name() { return m_name; }
+
+    private:
+        virtual RegisterID* emitBytecode(BytecodeGenerator&amp;, RegisterID* = 0) override;
+
+        const Identifier&amp; m_name;
+        ExpressionNode* m_constructorExpression;
+        ExpressionNode* m_parentClassExpression;
+        PropertyListNode* m_instanceMethods;
+        PropertyListNode* m_staticMethods;
+    };
+#endif
+
</ins><span class="cx">     class DeconstructionPatternNode : public RefCounted&lt;DeconstructionPatternNode&gt; {
</span><span class="cx">         WTF_MAKE_NONCOPYABLE(DeconstructionPatternNode);
</span><span class="cx">         WTF_MAKE_FAST_ALLOCATED;
</span><span class="lines">@@ -1724,6 +1743,18 @@
</span><span class="cx">         FunctionBodyNode* m_body;
</span><span class="cx">     };
</span><span class="cx"> 
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    class ClassDeclNode final : public StatementNode {
+    public:
+        ClassDeclNode(const JSTokenLocation&amp;, ExpressionNode* classExpression);
+
+    private:
+        virtual void emitBytecode(BytecodeGenerator&amp;, RegisterID* = 0) override;
+
+        ExpressionNode* m_classDeclaration;
+    };
+#endif
+
</ins><span class="cx">     class CaseClauseNode : public ParserArenaFreeable {
</span><span class="cx">     public:
</span><span class="cx">         CaseClauseNode(ExpressionNode*, SourceElements* = 0);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.cpp (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.cpp        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/Source/JavaScriptCore/parser/Parser.cpp        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -1150,6 +1150,12 @@
</span><span class="cx">     case CONSTTOKEN:
</span><span class="cx">         result = parseConstDeclaration(context);
</span><span class="cx">         break;
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    case CLASSTOKEN:
+        failIfFalse(m_statementDepth == 1, &quot;Class declaration is not allowed in a lexically nested statement&quot;);
+        result = parseClassDeclaration(context);
+        break;
+#endif
</ins><span class="cx">     case FUNCTION:
</span><span class="cx">         failIfFalseIfStrict(m_statementDepth == 1, &quot;Strict mode does not allow function declarations in a lexically nested statement&quot;);
</span><span class="cx">         result = parseFunctionDeclaration(context);
</span><span class="lines">@@ -1267,6 +1273,10 @@
</span><span class="cx">         return &quot;setter&quot;;
</span><span class="cx">     case FunctionMode:
</span><span class="cx">         return &quot;function&quot;;
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    case MethodMode:
+        return &quot;method&quot;;
+#endif
</ins><span class="cx">     }
</span><span class="cx">     RELEASE_ASSERT_NOT_REACHED();
</span><span class="cx">     return nullptr;
</span><span class="lines">@@ -1404,6 +1414,129 @@
</span><span class="cx">     return context.createFuncDeclStatement(location, info, functionKeywordStart);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+template &lt;typename LexerType&gt;
+template &lt;class TreeBuilder&gt; TreeStatement Parser&lt;LexerType&gt;::parseClassDeclaration(TreeBuilder&amp; context)
+{
+    ASSERT(match(CLASSTOKEN));
+    JSTokenLocation location(tokenLocation());
+    JSTextPosition classStart = tokenStartPosition();
+    unsigned classStartLine = tokenLine();
+
+    TreeClassExpression classExpr = parseClass(context, FunctionNeedsName);
+    failIfFalse(classExpr, &quot;Failed to parse class&quot;);
+
+    JSTextPosition classEnd = lastTokenEndPosition();
+    unsigned classEndLine = tokenLine();
+
+    return context.createClassDeclStatement(location, classExpr, classStart, classEnd, classStartLine, classEndLine);
+}
+
+template &lt;typename LexerType&gt;
+template &lt;class TreeBuilder&gt; TreeClassExpression Parser&lt;LexerType&gt;::parseClass(TreeBuilder&amp; context, FunctionRequirements requirements)
+{
+    ASSERT(match(CLASSTOKEN));
+    JSTokenLocation location(tokenLocation());
+    next();
+
+    AutoPopScopeRef classScope(this, pushScope());
+    classScope-&gt;setStrictMode();
+
+    const Identifier* className = nullptr;
+    if (match(IDENT)) {
+        className = m_token.m_data.ident;
+        next();
+        failIfFalse(classScope-&gt;declareVariable(className), &quot;'&quot;, className-&gt;impl(), &quot;' is not a valid class name&quot;);
+    } else if (requirements == FunctionNeedsName) {
+        semanticFailureDueToKeyword(&quot;class name&quot;);
+        failDueToUnexpectedToken();
+    } else
+        className = &amp;m_vm-&gt;propertyNames-&gt;nullIdentifier;
+    ASSERT(className);
+
+    TreeExpression parentClass = 0;
+    if (consume(EXTENDS)) {
+        parentClass = parsePrimaryExpression(context);
+        failIfFalse(parentClass, &quot;Cannot parse the parent class name&quot;);
+        failWithMessage(&quot;Inheritance is not supported yet&quot;);
+    }
+
+    consumeOrFailWithFlags(OPENBRACE, TreeBuilder::DontBuildStrings, &quot;Expected opening '{' at the start of a class body&quot;);
+
+    TreeExpression constructor = 0;
+    TreePropertyList staticMethods = 0;
+    TreePropertyList instanceMethods = 0;
+    TreePropertyList instanceMethodsTail = 0;
+    TreePropertyList staticMethodsTail = 0;
+    while (!match(CLOSEBRACE)) {
+        if (match(SEMICOLON))
+            next();
+
+        JSTokenLocation methodLocation(tokenLocation());
+        unsigned methodStart = tokenStart();
+
+        bool isStaticMethod = match(STATICTOKEN);
+        if (isStaticMethod)
+            next();
+
+        matchOrFail(IDENT, &quot;Expected an indentifier&quot;);
+
+        const CommonIdentifiers&amp; propertyNames = *m_vm-&gt;propertyNames;
+        const Identifier&amp; ident = *m_token.m_data.ident;
+        bool isGetter = ident == propertyNames.get;
+        bool isSetter = ident == propertyNames.set;
+
+        TreeProperty property;
+        const bool alwaysStrictInsideClass = true;
+        if (isGetter || isSetter) {
+            semanticFailIfTrue(isStaticMethod, &quot;Cannot declare a static&quot;, stringForFunctionMode(isGetter ? GetterMode : SetterMode));
+            nextExpectIdentifier(LexerFlagsIgnoreReservedWords);
+            property = parseGetterSetter(context, alwaysStrictInsideClass, isGetter ? PropertyNode::Getter : PropertyNode::Setter, methodStart);
+            failIfFalse(property, &quot;Cannot parse this method&quot;);
+        } else {
+            ParserFunctionInfo&lt;TreeBuilder&gt; methodInfo;
+            failIfFalse((parseFunctionInfo(context, FunctionNeedsName, FunctionMode, false, methodInfo)), &quot;Cannot parse this method&quot;);
+            failIfFalse(methodInfo.name, &quot;method must have a name&quot;);
+            failIfFalse(declareVariable(methodInfo.name), &quot;Cannot declare a method named '&quot;, methodInfo.name-&gt;impl(), &quot;'&quot;);
+
+            bool isConstructor = !isStaticMethod &amp;&amp; *methodInfo.name == propertyNames.constructor;
+            if (isConstructor)
+                methodInfo.name = className;
+
+            TreeExpression method = context.createFunctionExpr(methodLocation, methodInfo, methodStart);
+            if (isConstructor) {
+                semanticFailIfTrue(constructor, &quot;Cannot declare multiple constructors in a single class&quot;);
+                constructor = method;
+                continue;
+            }
+
+            // FIXME: Syntax error when super() is called
+            semanticFailIfTrue(isStaticMethod &amp;&amp; *methodInfo.name == propertyNames.prototype,
+                &quot;Cannot declare a static method named 'prototype'&quot;);
+            property = context.createProperty(methodInfo.name, method, PropertyNode::Constant, alwaysStrictInsideClass);
+        }
+
+        TreePropertyList&amp; tail = isStaticMethod ? staticMethodsTail : instanceMethodsTail;
+        if (tail)
+            tail = context.createPropertyList(methodLocation, property, tail);
+        else {
+            tail = context.createPropertyList(methodLocation, property);
+            if (isStaticMethod)
+                staticMethods = tail;
+            else
+                instanceMethods = tail;
+        }
+    }
+
+    // FIXME: Create a Miranda function instead.
+    semanticFailIfFalse(constructor, &quot;Class declaration without a constructor is not supported yet&quot;);
+
+    consumeOrFail(CLOSEBRACE, &quot;Expected a closing '}' after a class body&quot;);
+
+    return context.createClassExpr(location, *className, constructor, parentClass, instanceMethods, staticMethods);
+}
+#endif
+
</ins><span class="cx"> struct LabelInfo {
</span><span class="cx">     LabelInfo(const Identifier* ident, const JSTextPosition&amp; start, const JSTextPosition&amp; end)
</span><span class="cx">     : m_ident(ident)
</span><span class="lines">@@ -1802,27 +1935,7 @@
</span><span class="cx">             type = PropertyNode::Setter;
</span><span class="cx">         else
</span><span class="cx">             failWithMessage(&quot;Expected a ':' following the property name '&quot;, ident-&gt;impl(), &quot;'&quot;);
</span><del>-        const Identifier* stringPropertyName = 0;
-        double numericPropertyName = 0;
-        if (m_token.m_type == IDENT || m_token.m_type == STRING)
-            stringPropertyName = m_token.m_data.ident;
-        else if (m_token.m_type == NUMBER)
-            numericPropertyName = m_token.m_data.doubleValue;
-        else
-            failDueToUnexpectedToken();
-        JSTokenLocation location(tokenLocation());
-        next();
-        ParserFunctionInfo&lt;TreeBuilder&gt; info;
-        if (type == PropertyNode::Getter) {
-            failIfFalse(match(OPENPAREN), &quot;Expected a parameter list for getter definition&quot;);
-            failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, GetterMode, false, info)), &quot;Cannot parse getter definition&quot;);
-        } else {
-            failIfFalse(match(OPENPAREN), &quot;Expected a parameter list for setter definition&quot;);
-            failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SetterMode, false, info)), &quot;Cannot parse setter definition&quot;);
-        }
-        if (stringPropertyName)
-            return context.createGetterOrSetterProperty(location, type, complete, stringPropertyName, info, getterOrSetterStartOffset);
-        return context.createGetterOrSetterProperty(const_cast&lt;VM*&gt;(m_vm), m_parserArena, location, type, complete, numericPropertyName, info, getterOrSetterStartOffset);
</del><ins>+        return parseGetterSetter(context, complete, type, getterOrSetterStartOffset);
</ins><span class="cx">     }
</span><span class="cx">     case NUMBER: {
</span><span class="cx">         double propertyName = m_token.m_data.doubleValue;
</span><span class="lines">@@ -1852,6 +1965,32 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template &lt;typename LexerType&gt;
</span><ins>+template &lt;class TreeBuilder&gt; TreeProperty Parser&lt;LexerType&gt;::parseGetterSetter(TreeBuilder&amp; context, bool strict, PropertyNode::Type type, unsigned getterOrSetterStartOffset)
+{
+    const Identifier* stringPropertyName = 0;
+    double numericPropertyName = 0;
+    if (m_token.m_type == IDENT || m_token.m_type == STRING)
+        stringPropertyName = m_token.m_data.ident;
+    else if (m_token.m_type == NUMBER)
+        numericPropertyName = m_token.m_data.doubleValue;
+    else
+        failDueToUnexpectedToken();
+    JSTokenLocation location(tokenLocation());
+    next();
+    ParserFunctionInfo&lt;TreeBuilder&gt; info;
+    if (type == PropertyNode::Getter) {
+        failIfFalse(match(OPENPAREN), &quot;Expected a parameter list for getter definition&quot;);
+        failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, GetterMode, false, info)), &quot;Cannot parse getter definition&quot;);
+    } else {
+        failIfFalse(match(OPENPAREN), &quot;Expected a parameter list for setter definition&quot;);
+        failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, SetterMode, false, info)), &quot;Cannot parse setter definition&quot;);
+    }
+    if (stringPropertyName)
+        return context.createGetterOrSetterProperty(location, type, strict, stringPropertyName, info, getterOrSetterStartOffset);
+    return context.createGetterOrSetterProperty(const_cast&lt;VM*&gt;(m_vm), m_parserArena, location, type, strict, numericPropertyName, info, getterOrSetterStartOffset);
+}
+
+template &lt;typename LexerType&gt;
</ins><span class="cx"> template &lt;class TreeBuilder&gt; TreeExpression Parser&lt;LexerType&gt;::parseObjectLiteral(TreeBuilder&amp; context)
</span><span class="cx"> {
</span><span class="cx">     auto savePoint = createSavePoint();
</span><span class="lines">@@ -2036,6 +2175,10 @@
</span><span class="cx">         failIfFalse((parseFunctionInfo(context, FunctionNoRequirements, FunctionMode, false, info)), &quot;Cannot parse function expression&quot;);
</span><span class="cx">         return context.createFunctionExpr(location, info, functionKeywordStart);
</span><span class="cx">     }
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    case CLASSTOKEN:
+        return parseClass(context, FunctionNoRequirements);
+#endif
</ins><span class="cx">     case OPENBRACE:
</span><span class="cx">         if (strictMode())
</span><span class="cx">             return parseStrictObjectLiteral(context);
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/Parser.h (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/Parser.h        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/Source/JavaScriptCore/parser/Parser.h        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -70,6 +70,9 @@
</span><span class="cx"> #define TreeArguments typename TreeBuilder::Arguments
</span><span class="cx"> #define TreeArgumentsList typename TreeBuilder::ArgumentsList
</span><span class="cx"> #define TreeFunctionBody typename TreeBuilder::FunctionBody
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+#define TreeClassExpression typename TreeBuilder::ClassExpression
+#endif
</ins><span class="cx"> #define TreeProperty typename TreeBuilder::Property
</span><span class="cx"> #define TreePropertyList typename TreeBuilder::PropertyList
</span><span class="cx"> #define TreeDeconstructionPattern typename TreeBuilder::DeconstructionPattern
</span><span class="lines">@@ -78,7 +81,14 @@
</span><span class="cx"> 
</span><span class="cx"> enum SourceElementsMode { CheckForStrictMode, DontCheckForStrictMode };
</span><span class="cx"> enum FunctionRequirements { FunctionNoRequirements, FunctionNeedsName };
</span><del>-enum FunctionParseMode { FunctionMode, GetterMode, SetterMode };
</del><ins>+enum FunctionParseMode {
+    FunctionMode,
+    GetterMode,
+    SetterMode,
+#if ENABLE(ES6_CLASS_SYNTAX)
+    MethodMode
+#endif
+};
</ins><span class="cx"> enum DeconstructionKind {
</span><span class="cx">     DeconstructToVariables,
</span><span class="cx">     DeconstructToParameters,
</span><span class="lines">@@ -693,6 +703,9 @@
</span><span class="cx">     
</span><span class="cx">     template &lt;class TreeBuilder&gt; TreeSourceElements parseSourceElements(TreeBuilder&amp;, SourceElementsMode);
</span><span class="cx">     template &lt;class TreeBuilder&gt; TreeStatement parseStatement(TreeBuilder&amp;, const Identifier*&amp; directive, unsigned* directiveLiteralLength = 0);
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    template &lt;class TreeBuilder&gt; TreeStatement parseClassDeclaration(TreeBuilder&amp;);
+#endif
</ins><span class="cx">     template &lt;class TreeBuilder&gt; TreeStatement parseFunctionDeclaration(TreeBuilder&amp;);
</span><span class="cx">     template &lt;class TreeBuilder&gt; TreeStatement parseVarDeclaration(TreeBuilder&amp;);
</span><span class="cx">     template &lt;class TreeBuilder&gt; TreeStatement parseConstDeclaration(TreeBuilder&amp;);
</span><span class="lines">@@ -726,6 +739,7 @@
</span><span class="cx">     enum SpreadMode { AllowSpread, DontAllowSpread };
</span><span class="cx">     template &lt;class TreeBuilder&gt; ALWAYS_INLINE TreeArguments parseArguments(TreeBuilder&amp;, SpreadMode);
</span><span class="cx">     template &lt;class TreeBuilder&gt; TreeProperty parseProperty(TreeBuilder&amp;, bool strict);
</span><ins>+    template &lt;class TreeBuilder&gt; TreeProperty parseGetterSetter(TreeBuilder&amp;, bool strict, PropertyNode::Type, unsigned getterOrSetterStartOffset);
</ins><span class="cx">     template &lt;class TreeBuilder&gt; ALWAYS_INLINE TreeFunctionBody parseFunctionBody(TreeBuilder&amp;);
</span><span class="cx">     template &lt;class TreeBuilder&gt; ALWAYS_INLINE TreeFormalParameterList parseFormalParameters(TreeBuilder&amp;);
</span><span class="cx">     template &lt;class TreeBuilder&gt; TreeExpression parseVarDeclarationList(TreeBuilder&amp;, int&amp; declarations, TreeDeconstructionPattern&amp; lastPattern, TreeExpression&amp; lastInitializer, JSTextPosition&amp; identStart, JSTextPosition&amp; initStart, JSTextPosition&amp; initEnd);
</span><span class="lines">@@ -736,6 +750,9 @@
</span><span class="cx">     template &lt;class TreeBuilder&gt; NEVER_INLINE TreeDeconstructionPattern tryParseDeconstructionPatternExpression(TreeBuilder&amp;);
</span><span class="cx"> 
</span><span class="cx">     template &lt;class TreeBuilder&gt; NEVER_INLINE bool parseFunctionInfo(TreeBuilder&amp;, FunctionRequirements, FunctionParseMode, bool nameIsInContainingScope, ParserFunctionInfo&lt;TreeBuilder&gt;&amp;);
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    template &lt;class TreeBuilder&gt; NEVER_INLINE TreeClassExpression parseClass(TreeBuilder&amp;, FunctionRequirements);
+#endif
</ins><span class="cx"> 
</span><span class="cx">     ALWAYS_INLINE int isBinaryOperator(JSTokenType);
</span><span class="cx">     bool allowAutomaticSemicolon();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreparserSyntaxCheckerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/parser/SyntaxChecker.h (179370 => 179371)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/parser/SyntaxChecker.h        2015-01-29 22:58:22 UTC (rev 179370)
+++ trunk/Source/JavaScriptCore/parser/SyntaxChecker.h        2015-01-29 22:59:19 UTC (rev 179371)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     enum { NoneExpr = 0,
</span><span class="cx">         ResolveEvalExpr, ResolveExpr, NumberExpr, StringExpr,
</span><span class="cx">         ThisExpr, NullExpr, BoolExpr, RegExpExpr, ObjectLiteralExpr,
</span><del>-        FunctionExpr, BracketExpr, DotExpr, CallExpr,
</del><ins>+        FunctionExpr, ClassExpr, BracketExpr, DotExpr, CallExpr,
</ins><span class="cx">         NewExpr, PreExpr, PostExpr, UnaryExpr, BinaryExpr,
</span><span class="cx">         ConditionalExpr, AssignmentExpr, TypeofExpr,
</span><span class="cx">         DeleteExpr, ArrayLiteralExpr, BindingDeconstruction,
</span><span class="lines">@@ -113,6 +113,9 @@
</span><span class="cx">     typedef int ArgumentsList;
</span><span class="cx">     typedef int FormalParameterList;
</span><span class="cx">     typedef int FunctionBody;
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    typedef int ClassExpression;
+#endif
</ins><span class="cx">     typedef int Statement;
</span><span class="cx">     typedef int ClauseList;
</span><span class="cx">     typedef int Clause;
</span><span class="lines">@@ -160,6 +163,9 @@
</span><span class="cx">     ExpressionType createConditionalExpr(const JSTokenLocation&amp;, ExpressionType, ExpressionType, ExpressionType) { return ConditionalExpr; }
</span><span class="cx">     ExpressionType createAssignResolve(const JSTokenLocation&amp;, const Identifier&amp;, ExpressionType, int, int, int) { return AssignmentExpr; }
</span><span class="cx">     ExpressionType createEmptyVarExpression(const JSTokenLocation&amp;, const Identifier&amp;) { return AssignmentExpr; }
</span><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    ClassExpression createClassExpr(const JSTokenLocation&amp;, const Identifier&amp;, ExpressionType, ExpressionType, PropertyList, PropertyList) { return ClassExpr; }
+#endif
</ins><span class="cx">     ExpressionType createFunctionExpr(const JSTokenLocation&amp;, const ParserFunctionInfo&lt;SyntaxChecker&gt;&amp;, int) { return FunctionExpr; }
</span><span class="cx">     int createFunctionBody(const JSTokenLocation&amp;, const JSTokenLocation&amp;, int, int, bool) { return FunctionBodyResult; }
</span><span class="cx">     void setFunctionNameStart(int, int) { }
</span><span class="lines">@@ -195,7 +201,10 @@
</span><span class="cx">     int createClauseList(int) { return ClauseListResult; }
</span><span class="cx">     int createClauseList(int, int) { return ClauseListResult; }
</span><span class="cx">     int createFuncDeclStatement(const JSTokenLocation&amp;, const ParserFunctionInfo&lt;SyntaxChecker&gt;&amp;, int) { return StatementResult; }
</span><del>-    int createClassDeclStatement(const JSTokenLocation&amp;, const Identifier&amp;, ExpressionType, ExpressionType, PropertyList, PropertyList, int, int) { return StatementResult; }
</del><ins>+#if ENABLE(ES6_CLASS_SYNTAX)
+    int createClassDeclStatement(const JSTokenLocation&amp;, ClassExpression,
+        const JSTextPosition&amp;, const JSTextPosition&amp;, int, int) { return StatementResult; }
+#endif
</ins><span class="cx">     int createBlockStatement(const JSTokenLocation&amp;, int, int, int) { return StatementResult; }
</span><span class="cx">     int createExprStatement(const JSTokenLocation&amp;, int, int, int) { return StatementResult; }
</span><span class="cx">     int createIfStatement(const JSTokenLocation&amp;, int, int, int, int) { return StatementResult; }
</span></span></pre>
</div>
</div>

</body>
</html>