17PropertyKey ObjectIterator::next(Property *pd, PropertyAttributes *attrs)
19 if (!object || !iterator)
20 return PropertyKey::invalid();
23 ScopedPropertyKey key(scope);
26 key = iterator->next(object, pd, attrs);
27 if (!key->isValid()) {
31 if ((!(flags & WithSymbols) && key->isSymbol()) ||
32 ((flags & EnumerableOnly) && !attrs->isEnumerable()))
38ReturnedValue ObjectIterator::nextPropertyName(Value *value)
41 return Encode::null();
43 PropertyAttributes attrs;
45 ScopedProperty p(scope);
46 ScopedPropertyKey key(scope, next(p, &attrs));
48 return Encode::null();
50 *value = object->getValue(p->value, attrs);
51 if (key->isArrayIndex())
52 return Encode(key->asArrayIndex());
53 Q_ASSERT(key->isStringOrSymbol());
54 return key->asStringOrSymbol()->asReturnedValue();
57ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value)
60 return Encode::null();
62 PropertyAttributes attrs;
64 ScopedProperty p(scope);
65 ScopedPropertyKey key(scope, next(p, &attrs));
67 return Encode::null();
69 *value = object->getValue(p->value, attrs);
71 return key->toStringOrSymbol(engine)->asReturnedValue();
74ReturnedValue ObjectIterator::nextPropertyNameAsString()
77 return Encode::null();
79 PropertyAttributes attrs;
81 ScopedPropertyKey key(scope, next(
nullptr, &attrs));
83 return Encode::null();
85 return key->toStringOrSymbol(engine)->asReturnedValue();
110ReturnedValue ForInIteratorPrototype::method_next(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
112 const ForInIteratorObject *forIn =
static_cast<
const ForInIteratorObject *>(thisObject);
116 ScopedPropertyKey key(scope, forIn->nextProperty());
120 ScopedStringOrSymbol s(scope, key->toStringOrSymbol(scope.engine));
121 return IteratorPrototype::createIterResultObject(scope.engine, s, done);
125PropertyKey ForInIteratorObject::nextProperty()
const
128 return PropertyKey::invalid();
131 ScopedObject c(scope, d()->current);
132 ScopedObject t(scope, d()->target);
133 ScopedObject o(scope);
134 ScopedProperty p(scope);
135 ScopedPropertyKey key(scope);
136 PropertyAttributes attrs;
140 key = d()->iterator->next(t, p, &attrs);
143 if (!attrs.isEnumerable() || key->isSymbol())
146 if (d()->current != d()->object) {
148 bool shadowed =
false;
149 while (o && o->d() != c->heapObject()) {
150 if (o->getOwnProperty(key) != Attr_Invalid) {
154 o = o->getPrototypeOf();
162 c = c->getPrototypeOf();
163 d()->current.set(scope.engine, c ? c->d() :
nullptr);
166 delete d()->iterator;
167 d()->iterator = c->ownPropertyKeys(t.getRef());
168 d()->target.set(scope.engine, t->d());
169 if (!d()->iterator) {
170 scope.engine->throwTypeError();
171 return PropertyKey::invalid();
174 return PropertyKey::invalid();