haikuwebkit/LayoutTests/js/class-syntax-expression-exp...

43 lines
3.0 KiB
Plaintext
Raw Permalink Normal View History

Enable ES6 classes by default https://bugs.webkit.org/show_bug.cgi?id=142774 Reviewed by Gavin Barraclough. .: * Source/cmake/WebKitFeatures.cmake: Source/JavaScriptCore: Enabled the feature and unskipped tests. * Configurations/FeatureDefines.xcconfig: * tests/stress/class-syntax-no-loop-tdz.js: * tests/stress/class-syntax-no-tdz-in-catch.js: * tests/stress/class-syntax-no-tdz-in-conditional.js: * tests/stress/class-syntax-no-tdz-in-loop-no-inline-super.js: * tests/stress/class-syntax-no-tdz-in-loop.js: * tests/stress/class-syntax-no-tdz.js: * tests/stress/class-syntax-tdz-in-catch.js: * tests/stress/class-syntax-tdz-in-conditional.js: * tests/stress/class-syntax-tdz-in-loop.js: * tests/stress/class-syntax-tdz.js: Source/WebCore: * Configurations/FeatureDefines.xcconfig: Source/WebKit/mac: * Configurations/FeatureDefines.xcconfig: Source/WebKit2: * Configurations/FeatureDefines.xcconfig: Source/WTF: * wtf/FeatureDefines.h: Tools: * Scripts/webkitperl/FeatureList.pm: LayoutTests: Unskipped tests and also fixed tests so that they can run under run-javascript-tests. * TestExpectations: Unskipped tests. * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-expression-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-super-expected.txt: * js/dom/reserved-words-as-property-expected.txt: Rebaselined now that "class" is a non-reserved keyword. * js/script-tests/class-syntax-call.js: Don't refer to "window" object as it doesn't exit when ran inside jsc. * js/script-tests/class-syntax-declaration.js: Rebaselined after r181611, which added default constructor support. * js/script-tests/class-syntax-default-constructor.js: Don't refer to "window" object. Also replaced shouldNotBe by an explicit !== check as the former is not supported when ran inside jsc. * js/script-tests/class-syntax-expression.js: Rebaselined after r181611. * js/script-tests/class-syntax-extends.js: Ditto. Also replaced evalAndLog by shouldNotThrow as the former is not supported inside jsc. * js/script-tests/class-syntax-super.js: Don't refer to "window" object as it doesn't exist inside jsc. * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.11-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.27-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.5-expected.txt: Canonical link: https://commits.webkit.org/160789@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181618 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-17 05:55:46 +00:00
Tests for ES6 class syntax expressions
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
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 "extends" 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<LexerType>::parseStatement): Added the support for class declaration. (JSC::stringForFunctionMode): Return "method" for MethodMode. (JSC::Parser<LexerType>::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps it with ClassDeclNode as described above. (JSC::Parser<LexerType>::parseClass): Parses a class expression. (JSC::Parser<LexerType>::parseProperty): (JSC::Parser<LexerType>::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty and parseClass. (JSC::Parser<LexerType>::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. Canonical link: https://commits.webkit.org/159052@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-29 22:59:19 +00:00
PASS constructorCallCount is 0
PASS A.someStaticMethod() is staticMethodValue
PASS A.someStaticGetter is getterValue
PASS setterValue = undefined; A.someStaticSetter = 123; setterValue is 123
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 "extends" 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<LexerType>::parseStatement): Added the support for class declaration. (JSC::stringForFunctionMode): Return "method" for MethodMode. (JSC::Parser<LexerType>::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps it with ClassDeclNode as described above. (JSC::Parser<LexerType>::parseClass): Parses a class expression. (JSC::Parser<LexerType>::parseProperty): (JSC::Parser<LexerType>::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty and parseClass. (JSC::Parser<LexerType>::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. Canonical link: https://commits.webkit.org/159052@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-29 22:59:19 +00:00
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 = undefined; (new A).someSetter = 789; setterValue is 789
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 "extends" 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<LexerType>::parseStatement): Added the support for class declaration. (JSC::stringForFunctionMode): Return "method" for MethodMode. (JSC::Parser<LexerType>::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps it with ClassDeclNode as described above. (JSC::Parser<LexerType>::parseClass): Parses a class expression. (JSC::Parser<LexerType>::parseProperty): (JSC::Parser<LexerType>::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty and parseClass. (JSC::Parser<LexerType>::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. Canonical link: https://commits.webkit.org/159052@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-29 22:59:19 +00:00
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.
Class syntax should allow string and numeric identifiers for method names https://bugs.webkit.org/show_bug.cgi?id=144254 Reviewed by Darin Adler. Source/JavaScriptCore: Added the support for string and numeric identifiers in class syntax. * parser/Parser.cpp: (JSC::Parser<LexerType>::parseFunctionInfo): Instead of using ConstructorKind to indicate whether we're inside a class or not, use the newly added SuperBinding argument instead. ConstructorKind is now None outside a class constructor as it should be. (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): No longer expects an identifier at the beginning of every class element to allow numeric and string method names. For both of those method names, parse it here instead of parseFunctionInfo since it doesn't support either type. Also pass in SuperBinding::Needed. (JSC::Parser<LexerType>::parsePropertyMethod): Call parseFunctionInfo with SuperBinding::NotNeeded since this function is never used to parse a class method. (JSC::Parser<LexerType>::parseGetterSetter): Pass in superBinding argument to parseFunctionInfo. (JSC::Parser<LexerType>::parsePrimaryExpression): Call parseFunctionInfo with SuperBinding::NotNeeded. * parser/Parser.h: * parser/SyntaxChecker.h: (JSC::SyntaxChecker::createProperty): LayoutTests: Added a test and rebaselined other tests per syntax error message change. * js/class-syntax-declaration-expected.txt: * js/class-syntax-expression-expected.txt: * js/class-syntax-string-and-numeric-names-expected.txt: Added. * js/class-syntax-string-and-numeric-names.html: Added. * js/class-syntax-super-expected.txt: * js/script-tests/class-syntax-declaration.js: * js/script-tests/class-syntax-expression.js: * js/script-tests/class-syntax-string-and-numeric-names.js: Added. * js/script-tests/class-syntax-super.js: Canonical link: https://commits.webkit.org/162546@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183709 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-05-02 02:23:01 +00:00
PASS x = class { ( } threw exception SyntaxError: Unexpected token '('.
Enable ES6 classes by default https://bugs.webkit.org/show_bug.cgi?id=142774 Reviewed by Gavin Barraclough. .: * Source/cmake/WebKitFeatures.cmake: Source/JavaScriptCore: Enabled the feature and unskipped tests. * Configurations/FeatureDefines.xcconfig: * tests/stress/class-syntax-no-loop-tdz.js: * tests/stress/class-syntax-no-tdz-in-catch.js: * tests/stress/class-syntax-no-tdz-in-conditional.js: * tests/stress/class-syntax-no-tdz-in-loop-no-inline-super.js: * tests/stress/class-syntax-no-tdz-in-loop.js: * tests/stress/class-syntax-no-tdz.js: * tests/stress/class-syntax-tdz-in-catch.js: * tests/stress/class-syntax-tdz-in-conditional.js: * tests/stress/class-syntax-tdz-in-loop.js: * tests/stress/class-syntax-tdz.js: Source/WebCore: * Configurations/FeatureDefines.xcconfig: Source/WebKit/mac: * Configurations/FeatureDefines.xcconfig: Source/WebKit2: * Configurations/FeatureDefines.xcconfig: Source/WTF: * wtf/FeatureDefines.h: Tools: * Scripts/webkitperl/FeatureList.pm: LayoutTests: Unskipped tests and also fixed tests so that they can run under run-javascript-tests. * TestExpectations: Unskipped tests. * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-expression-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-super-expected.txt: * js/dom/reserved-words-as-property-expected.txt: Rebaselined now that "class" is a non-reserved keyword. * js/script-tests/class-syntax-call.js: Don't refer to "window" object as it doesn't exit when ran inside jsc. * js/script-tests/class-syntax-declaration.js: Rebaselined after r181611, which added default constructor support. * js/script-tests/class-syntax-default-constructor.js: Don't refer to "window" object. Also replaced shouldNotBe by an explicit !== check as the former is not supported when ran inside jsc. * js/script-tests/class-syntax-expression.js: Rebaselined after r181611. * js/script-tests/class-syntax-extends.js: Ditto. Also replaced evalAndLog by shouldNotThrow as the former is not supported inside jsc. * js/script-tests/class-syntax-super.js: Don't refer to "window" object as it doesn't exist inside jsc. * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.11-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.27-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.5-expected.txt: Canonical link: https://commits.webkit.org/160789@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181618 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-17 05:55:46 +00:00
PASS x = class {} did not throw exception.
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 "extends" 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<LexerType>::parseStatement): Added the support for class declaration. (JSC::stringForFunctionMode): Return "method" for MethodMode. (JSC::Parser<LexerType>::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps it with ClassDeclNode as described above. (JSC::Parser<LexerType>::parseClass): Parses a class expression. (JSC::Parser<LexerType>::parseProperty): (JSC::Parser<LexerType>::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty and parseClass. (JSC::Parser<LexerType>::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. Canonical link: https://commits.webkit.org/159052@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-29 22:59:19 +00:00
PASS x = class { constructor() {} constructor() {} } threw exception SyntaxError: Cannot declare multiple constructors in a single class..
PASS x = class { get constructor() {} } threw exception SyntaxError: Cannot declare a getter or setter named 'constructor'..
PASS x = class { set constructor() {} } threw exception SyntaxError: Cannot declare a getter or setter named 'constructor'..
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 "extends" 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<LexerType>::parseStatement): Added the support for class declaration. (JSC::stringForFunctionMode): Return "method" for MethodMode. (JSC::Parser<LexerType>::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps it with ClassDeclNode as described above. (JSC::Parser<LexerType>::parseClass): Parses a class expression. (JSC::Parser<LexerType>::parseProperty): (JSC::Parser<LexerType>::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty and parseClass. (JSC::Parser<LexerType>::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. Canonical link: https://commits.webkit.org/159052@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-29 22:59:19 +00:00
PASS x = class { constructor() {} static constructor() { return staticMethodValue; } } did not throw exception.
PASS x = class { constructor() {} static constructor() { return staticMethodValue; } }; x.constructor() is staticMethodValue
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 "extends" 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<LexerType>::parseStatement): Added the support for class declaration. (JSC::stringForFunctionMode): Return "method" for MethodMode. (JSC::Parser<LexerType>::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps it with ClassDeclNode as described above. (JSC::Parser<LexerType>::parseClass): Parses a class expression. (JSC::Parser<LexerType>::parseProperty): (JSC::Parser<LexerType>::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty and parseClass. (JSC::Parser<LexerType>::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. Canonical link: https://commits.webkit.org/159052@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-29 22:59:19 +00:00
PASS x = class { constructor() {} static prototype() {} } threw exception SyntaxError: Cannot declare a static method named 'prototype'..
PASS x = class { constructor() {} static get prototype() {} } threw exception SyntaxError: Cannot declare a static method named 'prototype'..
PASS x = class { constructor() {} static set prototype() {} } threw exception SyntaxError: Cannot declare a static method named 'prototype'..
PASS x = class { constructor() {} prototype() { return instanceMethodValue; } } did not throw exception.
PASS x = class { constructor() {} prototype() { return instanceMethodValue; } }; (new x).prototype() is instanceMethodValue
PASS x = class { constructor() {} set foo(a) {} } did not throw exception.
PASS x = class { constructor() {} set foo({x, y}) {} } did not throw exception.
PASS x = class { constructor() {} set foo() {} } threw exception SyntaxError: Unexpected token ')'. setter functions must have one parameter..
PASS x = class { constructor() {} set foo(a, b) {} } threw exception SyntaxError: Unexpected token ','. setter functions must have one parameter..
PASS x = class { constructor() {} get foo() {} } did not throw exception.
PASS x = class { constructor() {} get foo(x) {} } threw exception SyntaxError: Unexpected identifier 'x'. getter functions must have no parameters..
PASS x = class { constructor() {} get foo({x, y}) {} } threw exception SyntaxError: Unexpected token '{'. getter functions must have no parameters..
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 "extends" 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<LexerType>::parseStatement): Added the support for class declaration. (JSC::stringForFunctionMode): Return "method" for MethodMode. (JSC::Parser<LexerType>::parseClassDeclaration): Added. Uses parseClass to create a class expression and wraps it with ClassDeclNode as described above. (JSC::Parser<LexerType>::parseClass): Parses a class expression. (JSC::Parser<LexerType>::parseProperty): (JSC::Parser<LexerType>::parseGetterSetter): Extracted from parseProperty to share the code between parseProperty and parseClass. (JSC::Parser<LexerType>::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. Canonical link: https://commits.webkit.org/159052@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179371 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-01-29 22:59:19 +00:00
PASS successfullyParsed is true
TEST COMPLETE