haikuwebkit/LayoutTests/js/class-syntax-default-constr...

21 lines
614 B
Plaintext
Raw Permalink Normal View History

Source/JavaScriptCore: Add support for default constructor https://bugs.webkit.org/show_bug.cgi?id=142388 Reviewed by Filip Pizlo. Added the support for default constructors. They're generated by ClassExprNode::emitBytecode via BuiltinExecutables::createDefaultConstructor. UnlinkedFunctionExecutable now has the ability to override SourceCode provided by the owner executable. We can't make store SourceCode in UnlinkedFunctionExecutable since CodeCache can use the same UnlinkedFunctionExecutable to generate code blocks for multiple functions. Parser now has the ability to treat any function expression as a constructor of the kind specified by m_defaultConstructorKind member variable. * builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::createDefaultConstructor): Added. (JSC::BuiltinExecutables::createExecutableInternal): Generalized from createBuiltinExecutable. Parse default constructors as normal non-builtin functions. Override SourceCode in the unlinked function executable since the Miranda function's code is definitely not in the owner executable's source code. That's the whole point. * builtins/BuiltinExecutables.h: (UnlinkedFunctionExecutable::createBuiltinExecutable): Added. Wraps createExecutableInternal. * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): (JSC::UnlinkedFunctionExecutable::linkInsideExecutable): (JSC::UnlinkedFunctionExecutable::linkGlobalCode): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedFunctionExecutable::create): (JSC::UnlinkedFunctionExecutable::symbolTable): Deleted. * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitNewDefaultConstructor): Added. * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::ClassExprNode::emitBytecode): Generate the default constructor if needed. * parser/Parser.cpp: (JSC::Parser<LexerType>::Parser): (JSC::Parser<LexerType>::parseFunctionInfo): Override ownerClassKind and assume the function as a constructor if we're parsing a default constructor. (JSC::Parser<LexerType>::parseClass): Allow omission of the class constructor. * parser/Parser.h: (JSC::parse): LayoutTests: Implement default constructor Add support for default constructor https://bugs.webkit.org/show_bug.cgi?id=142388 Reviewed by Filip Pizlo. Added tests for default constructors. * TestExpectations: Skipped the test since ES6 class syntax isn't enabled by default. * js/class-syntax-default-constructor-expected.txt: Added. * js/class-syntax-default-constructor.html: Added. * js/script-tests/class-syntax-default-constructor.js: Added. Canonical link: https://commits.webkit.org/160782@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181611 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-17 04:02:52 +00:00
Tests for ES6 class syntax default constructor
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
ES6 class syntax should use block scoping https://bugs.webkit.org/show_bug.cgi?id=142567 Reviewed by Geoffrey Garen. Source/JavaScriptCore: We treat class declarations like we do "let" declarations. The class name is under TDZ until the class declaration statement is evaluated. Class declarations also follow the same rules as "let": No duplicate definitions inside a lexical environment. * parser/ASTBuilder.h: (JSC::ASTBuilder::createClassDeclStatement): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClassDeclaration): * tests/stress/class-syntax-block-scoping.js: Added. (assert): (truth): (.): * tests/stress/class-syntax-definition-semantics.js: Added. (shouldBeSyntaxError): (shouldNotBeSyntaxError): (truth): * tests/stress/class-syntax-tdz.js: (assert): (shouldThrowTDZ): (truth): (.): LayoutTests: * js/class-constructor-return-expected.txt: * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-name-expected.txt: * js/class-syntax-super-expected.txt: * js/script-tests/class-constructor-return.js: (shouldThrow): (shouldNotThrow): (shouldBeTrue): (shouldBeFalse): * js/script-tests/class-syntax-call.js: (A): (B): (shouldThrow): (shouldNotThrow): * js/script-tests/class-syntax-declaration.js: (shouldThrow): (shouldNotThrow): (shouldBe): * js/script-tests/class-syntax-default-constructor.js: (shouldThrow): (shouldBe): (shouldBeTrue): (assert): (A): (B): * js/script-tests/class-syntax-extends.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (Base): (Base.prototype.baseMethod): * js/script-tests/class-syntax-name.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (runTestShouldBe): * js/script-tests/class-syntax-super.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (shouldBeFalse): Canonical link: https://commits.webkit.org/165577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-07-31 21:05:19 +00:00
PASS new A instanceof A
PASS A():::TypeError: Cannot call a class constructor without |new|
ES6 class syntax should use block scoping https://bugs.webkit.org/show_bug.cgi?id=142567 Reviewed by Geoffrey Garen. Source/JavaScriptCore: We treat class declarations like we do "let" declarations. The class name is under TDZ until the class declaration statement is evaluated. Class declarations also follow the same rules as "let": No duplicate definitions inside a lexical environment. * parser/ASTBuilder.h: (JSC::ASTBuilder::createClassDeclStatement): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClassDeclaration): * tests/stress/class-syntax-block-scoping.js: Added. (assert): (truth): (.): * tests/stress/class-syntax-definition-semantics.js: Added. (shouldBeSyntaxError): (shouldNotBeSyntaxError): (truth): * tests/stress/class-syntax-tdz.js: (assert): (shouldThrowTDZ): (truth): (.): LayoutTests: * js/class-constructor-return-expected.txt: * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-name-expected.txt: * js/class-syntax-super-expected.txt: * js/script-tests/class-constructor-return.js: (shouldThrow): (shouldNotThrow): (shouldBeTrue): (shouldBeFalse): * js/script-tests/class-syntax-call.js: (A): (B): (shouldThrow): (shouldNotThrow): * js/script-tests/class-syntax-declaration.js: (shouldThrow): (shouldNotThrow): (shouldBe): * js/script-tests/class-syntax-default-constructor.js: (shouldThrow): (shouldBe): (shouldBeTrue): (assert): (A): (B): * js/script-tests/class-syntax-extends.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (Base): (Base.prototype.baseMethod): * js/script-tests/class-syntax-name.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (runTestShouldBe): * js/script-tests/class-syntax-super.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (shouldBeFalse): Canonical link: https://commits.webkit.org/165577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-07-31 21:05:19 +00:00
PASS A.prototype.constructor instanceof Function
PASS A.prototype.constructor.name:::"A"
PASS new B instanceof A; new B instanceof A
PASS B():::TypeError: Cannot call a class constructor without |new|
ES6 class syntax should use block scoping https://bugs.webkit.org/show_bug.cgi?id=142567 Reviewed by Geoffrey Garen. Source/JavaScriptCore: We treat class declarations like we do "let" declarations. The class name is under TDZ until the class declaration statement is evaluated. Class declarations also follow the same rules as "let": No duplicate definitions inside a lexical environment. * parser/ASTBuilder.h: (JSC::ASTBuilder::createClassDeclStatement): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClassDeclaration): * tests/stress/class-syntax-block-scoping.js: Added. (assert): (truth): (.): * tests/stress/class-syntax-definition-semantics.js: Added. (shouldBeSyntaxError): (shouldNotBeSyntaxError): (truth): * tests/stress/class-syntax-tdz.js: (assert): (shouldThrowTDZ): (truth): (.): LayoutTests: * js/class-constructor-return-expected.txt: * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-name-expected.txt: * js/class-syntax-super-expected.txt: * js/script-tests/class-constructor-return.js: (shouldThrow): (shouldNotThrow): (shouldBeTrue): (shouldBeFalse): * js/script-tests/class-syntax-call.js: (A): (B): (shouldThrow): (shouldNotThrow): * js/script-tests/class-syntax-declaration.js: (shouldThrow): (shouldNotThrow): (shouldBe): * js/script-tests/class-syntax-default-constructor.js: (shouldThrow): (shouldBe): (shouldBeTrue): (assert): (A): (B): * js/script-tests/class-syntax-extends.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (Base): (Base.prototype.baseMethod): * js/script-tests/class-syntax-name.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (runTestShouldBe): * js/script-tests/class-syntax-super.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (shouldBeFalse): Canonical link: https://commits.webkit.org/165577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-07-31 21:05:19 +00:00
PASS B.prototype.constructor.name:::"B"
PASS A !== B
PASS A.prototype.constructor !== B.prototype.constructor
PASS Passed assert
PASS Passed assert
PASS successfullyParsed
Source/JavaScriptCore: Add support for default constructor https://bugs.webkit.org/show_bug.cgi?id=142388 Reviewed by Filip Pizlo. Added the support for default constructors. They're generated by ClassExprNode::emitBytecode via BuiltinExecutables::createDefaultConstructor. UnlinkedFunctionExecutable now has the ability to override SourceCode provided by the owner executable. We can't make store SourceCode in UnlinkedFunctionExecutable since CodeCache can use the same UnlinkedFunctionExecutable to generate code blocks for multiple functions. Parser now has the ability to treat any function expression as a constructor of the kind specified by m_defaultConstructorKind member variable. * builtins/BuiltinExecutables.cpp: (JSC::BuiltinExecutables::createDefaultConstructor): Added. (JSC::BuiltinExecutables::createExecutableInternal): Generalized from createBuiltinExecutable. Parse default constructors as normal non-builtin functions. Override SourceCode in the unlinked function executable since the Miranda function's code is definitely not in the owner executable's source code. That's the whole point. * builtins/BuiltinExecutables.h: (UnlinkedFunctionExecutable::createBuiltinExecutable): Added. Wraps createExecutableInternal. * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): (JSC::UnlinkedFunctionExecutable::linkInsideExecutable): (JSC::UnlinkedFunctionExecutable::linkGlobalCode): * bytecode/UnlinkedCodeBlock.h: (JSC::UnlinkedFunctionExecutable::create): (JSC::UnlinkedFunctionExecutable::symbolTable): Deleted. * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::emitNewDefaultConstructor): Added. * bytecompiler/BytecodeGenerator.h: * bytecompiler/NodesCodegen.cpp: (JSC::ClassExprNode::emitBytecode): Generate the default constructor if needed. * parser/Parser.cpp: (JSC::Parser<LexerType>::Parser): (JSC::Parser<LexerType>::parseFunctionInfo): Override ownerClassKind and assume the function as a constructor if we're parsing a default constructor. (JSC::Parser<LexerType>::parseClass): Allow omission of the class constructor. * parser/Parser.h: (JSC::parse): LayoutTests: Implement default constructor Add support for default constructor https://bugs.webkit.org/show_bug.cgi?id=142388 Reviewed by Filip Pizlo. Added tests for default constructors. * TestExpectations: Skipped the test since ES6 class syntax isn't enabled by default. * js/class-syntax-default-constructor-expected.txt: Added. * js/class-syntax-default-constructor.html: Added. * js/script-tests/class-syntax-default-constructor.js: Added. Canonical link: https://commits.webkit.org/160782@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181611 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-17 04:02:52 +00:00
TEST COMPLETE