Skip to content
  • oliver@apple.com's avatar
    Support iteration of the Arguments object · 125f4cff
    oliver@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=123835
    
    Reviewed by Mark Lam.
    
    Source/JavaScriptCore:
    
    Add an ArgumentsIterator object, and associated classes so that we can support
    iteration of the arguments object.
    
    This is a largely mechanical patch.  The only gnarliness is in the
    logic to avoid reifying the Arguments object in for(... of arguments)
    scenarios.
    
    * GNUmakefile.list.am:
    * JavaScriptCore.xcodeproj/project.pbxproj:
    * bytecompiler/BytecodeGenerator.cpp:
    (JSC::BytecodeGenerator::emitEnumeration):
    * runtime/Arguments.cpp:
    (JSC::Arguments::getOwnPropertySlot):
    (JSC::argumentsFuncIterator):
    * runtime/Arguments.h:
    * runtime/ArgumentsIteratorConstructor.cpp: Added.
    (JSC::ArgumentsIteratorConstructor::finishCreation):
    * runtime/ArgumentsIteratorConstructor.h: Added.
    (JSC::ArgumentsIteratorConstructor::create):
    (JSC::ArgumentsIteratorConstructor::createStructure):
    (JSC::ArgumentsIteratorConstructor::ArgumentsIteratorConstructor):
    * runtime/ArgumentsIteratorPrototype.cpp: Added.
    (JSC::ArgumentsIteratorPrototype::finishCreation):
    (JSC::argumentsIteratorPrototypeFuncIterator):
    (JSC::argumentsIteratorPrototypeFuncNext):
    * runtime/ArgumentsIteratorPrototype.h: Added.
    (JSC::ArgumentsIteratorPrototype::create):
    (JSC::ArgumentsIteratorPrototype::createStructure):
    (JSC::ArgumentsIteratorPrototype::ArgumentsIteratorPrototype):
    * runtime/CommonIdentifiers.h:
    * runtime/JSArgumentsIterator.cpp: Added.
    (JSC::JSArgumentsIterator::finishCreation):
    * runtime/JSArgumentsIterator.h: Added.
    (JSC::JSArgumentsIterator::createStructure):
    (JSC::JSArgumentsIterator::create):
    (JSC::JSArgumentsIterator::next):
    (JSC::JSArgumentsIterator::JSArgumentsIterator):
    * runtime/JSArrayIterator.cpp:
    (JSC::createIteratorResult):
    * runtime/JSGlobalObject.cpp:
    * runtime/JSGlobalObject.h:
    
    LayoutTests:
    
    Add test cases
    
    * js/arguments-iterator-expected.txt: Added.
    * js/arguments-iterator.html: Added.
    * js/script-tests/arguments-iterator.js: Added.
    (shouldThrow.test):
    (testAlias):
    (testStrict):
    (testReifiedArguments):
    (testOverwrittenArguments):
    (testNullArguments):
    (testNonArrayLikeArguments):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@158793 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    125f4cff