Class syntax should allow string and numeric identifiers for method names
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 May 2015 02:23:01 +0000 (02:23 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 2 May 2015 02:23:01 +0000 (02:23 +0000)
commitdfa7d9f1fcd734ec17d516c0ae59a25bca4c1cc5
tree6490371adfd005b5af8cc61e87e247ee10038c3e
parentf7999dd0e525a482a2ff6008fd8e60bc0e147569
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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183709 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/js/class-syntax-declaration-expected.txt
LayoutTests/js/class-syntax-expression-expected.txt
LayoutTests/js/class-syntax-string-and-numeric-names-expected.txt [new file with mode: 0644]
LayoutTests/js/class-syntax-string-and-numeric-names.html [new file with mode: 0644]
LayoutTests/js/class-syntax-super-expected.txt
LayoutTests/js/script-tests/class-syntax-declaration.js
LayoutTests/js/script-tests/class-syntax-expression.js
LayoutTests/js/script-tests/class-syntax-string-and-numeric-names.js [new file with mode: 0644]
LayoutTests/js/script-tests/class-syntax-super.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/Parser.h