Ignore:
Timestamp:
Jul 27, 2015, 11:01:34 PM (10 years ago)
Author:
Yusuke Suzuki
Message:

[ES6] Implement Reflect.enumerate
https://bugs.webkit.org/show_bug.cgi?id=147347

Reviewed by Sam Weinig.

This patch implements Reflect.enumerate.
It returns the iterator that iterates the enumerable keys of the given object.
It follows the for-in's enumeration order.

To implement it, we write down the same logic to the for-in's enumeration code in C++.

(JSC::JSGlobalObject::init):
(JSC::JSGlobalObject::visitChildren):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::propertyNameIteratorStructure):

  • runtime/JSPropertyNameIterator.cpp: Added.

(JSC::JSPropertyNameIterator::JSPropertyNameIterator):
(JSC::JSPropertyNameIterator::clone):
(JSC::JSPropertyNameIterator::create):
(JSC::JSPropertyNameIterator::finishCreation):
(JSC::JSPropertyNameIterator::visitChildren):
(JSC::JSPropertyNameIterator::next):
(JSC::propertyNameIteratorFuncNext):

  • runtime/JSPropertyNameIterator.h: Added.

(JSC::JSPropertyNameIterator::createStructure):

  • runtime/ReflectObject.cpp:

(JSC::reflectObjectEnumerate):

  • tests/stress/reflect-enumerate.js: Added.

(shouldBe):
(shouldThrow):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r187401 r187483  
    8686#include "JSPromiseConstructor.h"
    8787#include "JSPromisePrototype.h"
     88#include "JSPropertyNameIterator.h"
    8889#include "JSSet.h"
    8990#include "JSSetIterator.h"
     
    360361   
    361362    FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(CREATE_PROTOTYPE_FOR_DERIVED_ITERATOR_TYPE)
     363    m_propertyNameIteratorStructure.set(vm, this, JSPropertyNameIterator::createStructure(vm, this, m_iteratorPrototype.get()));
    362364   
    363365#undef CREATE_PROTOTYPE_FOR_DERIVED_ITERATOR_TYPE
     
    785787    visitor.append(&thisObject->m_callbackFunctionStructure);
    786788    visitor.append(&thisObject->m_callbackObjectStructure);
     789    visitor.append(&thisObject->m_propertyNameIteratorStructure);
    787790#if JSC_OBJC_API_ENABLED
    788791    visitor.append(&thisObject->m_objcCallbackFunctionStructure);
Note: See TracChangeset for help on using the changeset viewer.