Support for-of syntax
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Oct 2013 20:35:24 +0000 (20:35 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Oct 2013 20:35:24 +0000 (20:35 +0000)
commite685f763f4b1b05570ce7ddc2815d6feaa9fd04a
tree8e41ba0fb729d7d5f68315787e6b1b58d54c8f0b
parentb98890451edcd7615df38d885433b0f547ce63e6
Support for-of syntax
https://bugs.webkit.org/show_bug.cgi?id=122339

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Add support for for-of syntax to JSC.  As part of doing this I had to make
us support unique empty strings as identifiers.  In a follow on patch i'm
going to remove the distinction entirely as it's purely a complicating
separation.

Otherwise the logic here is fairly self-explanatory.

* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::addConstant):
(JSC::BytecodeGenerator::emitCall):
* bytecompiler/BytecodeGenerator.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::CallArguments::CallArguments):
(JSC::ForOfNode::emitBytecode):
* jit/JITOperations.cpp:
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createForOfLoop):
* parser/NodeConstructors.h:
(JSC::EnumerationNode::EnumerationNode):
(JSC::ForInNode::ForInNode):
(JSC::ForOfNode::ForOfNode):
* parser/Nodes.h:
* parser/Parser.cpp:
(JSC::::parseVarDeclarationList):
(JSC::::parseForStatement):
* parser/Parser.h:
(JSC::Parser::isofToken):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createForOfLoop):
* runtime/ArrayIteratorPrototype.cpp:
(JSC::ArrayIteratorPrototype::finishCreation):
(JSC::arrayIteratorPrototypeIterate):
* runtime/ArrayPrototype.cpp:
(JSC::ArrayPrototype::create):
(JSC::ArrayPrototype::finishCreation):
* runtime/ArrayPrototype.h:
* runtime/CommonIdentifiers.cpp:
(JSC::CommonIdentifiers::CommonIdentifiers):
* runtime/CommonIdentifiers.h:
* runtime/Identifier.h:
(JSC::Identifier::from):
* runtime/JSCJSValue.cpp:
(JSC::JSValue::dumpInContext):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
* runtime/JSObject.cpp:
(JSC::JSObject::putDirectNativeFunction):
* runtime/PrivateName.h:
(JSC::PrivateName::PrivateName):
* runtime/PropertyName.h:
(JSC::PropertyName::PropertyName):

Source/WTF:

Update assertions and add a helper function to StringImpl
to save repeated unique or identifier calls.

* wtf/text/StringImpl.h:
(WTF::StringImpl::isIdentifierOrUnique):
(WTF::StringImpl::setIsIdentifier):
(WTF::StringImpl::setIsAtomic):

LayoutTests:

Add test cases for the one type that supports for-of so far

* js/basic-for-of-expected.txt: Added.
* js/basic-for-of.html: Added.
* js/regress/for-of-iterate-array-entries.html: Added.
* js/regress/for-of-iterate-array-keys.html: Added.
* js/regress/for-of-iterate-array-values.html: Added.
* js/regress/script-tests/for-of-iterate-array-entries.js: Added.
(foo):
* js/regress/script-tests/for-of-iterate-array-keys.js: Added.
(foo):
* js/regress/script-tests/for-of-iterate-array-values.js: Added.
(foo):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@156910 268f45cc-cd09-0410-ab3c-d52691b4dbfc
40 files changed:
LayoutTests/ChangeLog
LayoutTests/js/basic-for-of-expected.txt [new file with mode: 0644]
LayoutTests/js/basic-for-of.html [new file with mode: 0644]
LayoutTests/js/parser-syntax-check-expected.txt
LayoutTests/js/regress/for-of-iterate-array-entries-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/for-of-iterate-array-entries.html [new file with mode: 0644]
LayoutTests/js/regress/for-of-iterate-array-keys-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/for-of-iterate-array-keys.html [new file with mode: 0644]
LayoutTests/js/regress/for-of-iterate-array-values-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/for-of-iterate-array-values.html [new file with mode: 0644]
LayoutTests/js/regress/script-tests/for-of-iterate-array-entries.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/for-of-iterate-array-keys.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/for-of-iterate-array-values.js [new file with mode: 0644]
LayoutTests/js/script-tests/parser-syntax-check.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
Source/JavaScriptCore/jit/JITOperations.cpp
Source/JavaScriptCore/parser/ASTBuilder.h
Source/JavaScriptCore/parser/NodeConstructors.h
Source/JavaScriptCore/parser/Nodes.h
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/Parser.h
Source/JavaScriptCore/parser/SyntaxChecker.h
Source/JavaScriptCore/runtime/ArrayIteratorPrototype.cpp
Source/JavaScriptCore/runtime/ArrayPrototype.cpp
Source/JavaScriptCore/runtime/ArrayPrototype.h
Source/JavaScriptCore/runtime/CommonIdentifiers.cpp
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/JavaScriptCore/runtime/Identifier.h
Source/JavaScriptCore/runtime/JSArrayIterator.cpp
Source/JavaScriptCore/runtime/JSArrayIterator.h
Source/JavaScriptCore/runtime/JSCJSValue.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/PrivateName.h
Source/JavaScriptCore/runtime/PropertyName.h
Source/WTF/ChangeLog
Source/WTF/wtf/text/StringImpl.h