16PropertyKey ObjectIterator::next(Property *pd, PropertyAttributes *attrs)
18 if (!object || !iterator)
19 return PropertyKey::invalid();
22 ScopedPropertyKey key(scope);
25 key = iterator->next(object, pd, attrs);
26 if (!key->isValid()) {
30 if ((!(flags & WithSymbols) && key->isSymbol()) ||
31 ((flags & EnumerableOnly) && !attrs->isEnumerable()))
37ReturnedValue ObjectIterator::nextPropertyName(Value *value)
40 return Encode::null();
42 PropertyAttributes attrs;
44 ScopedProperty p(scope);
45 ScopedPropertyKey key(scope, next(p, &attrs));
47 return Encode::null();
49 *value = object->getValue(p->value, attrs);
50 if (key->isArrayIndex())
51 return Encode(key->asArrayIndex());
52 Q_ASSERT(key->isStringOrSymbol());
53 return key->asStringOrSymbol()->asReturnedValue();
56ReturnedValue ObjectIterator::nextPropertyNameAsString(Value *value)
59 return Encode::null();
61 PropertyAttributes attrs;
63 ScopedProperty p(scope);
64 ScopedPropertyKey key(scope, next(p, &attrs));
66 return Encode::null();
68 *value = object->getValue(p->value, attrs);
70 return key->toStringOrSymbol(engine)->asReturnedValue();
73ReturnedValue ObjectIterator::nextPropertyNameAsString()
76 return Encode::null();
78 PropertyAttributes attrs;
80 ScopedPropertyKey key(scope, next(
nullptr, &attrs));
82 return Encode::null();
84 return key->toStringOrSymbol(engine)->asReturnedValue();
109ReturnedValue ForInIteratorPrototype::method_next(
const FunctionObject *b,
const Value *thisObject,
const Value *,
int)
111 const ForInIteratorObject *forIn =
static_cast<
const ForInIteratorObject *>(thisObject);
115 ScopedPropertyKey key(scope, forIn->nextProperty());
119 ScopedStringOrSymbol s(scope, key->toStringOrSymbol(scope.engine));
120 return IteratorPrototype::createIterResultObject(scope.engine, s, done);
124PropertyKey ForInIteratorObject::nextProperty()
const
127 return PropertyKey::invalid();
130 ScopedObject c(scope, d()->current);
131 ScopedObject t(scope, d()->target);
132 ScopedObject o(scope);
133 ScopedProperty p(scope);
134 ScopedPropertyKey key(scope);
135 PropertyAttributes attrs;
139 key = d()->iterator->next(t, p, &attrs);
142 if (!attrs.isEnumerable() || key->isSymbol())
145 if (d()->current != d()->object) {
147 bool shadowed =
false;
148 while (o && o->d() != c->heapObject()) {
149 if (o->getOwnProperty(key) != Attr_Invalid) {
153 o = o->getPrototypeOf();
161 c = c->getPrototypeOf();
162 d()->current.set(scope.engine, c->d());
165 delete d()->iterator;
166 d()->iterator = c->ownPropertyKeys(t.getRef());
167 d()->target.set(scope.engine, t->d());
168 if (!d()->iterator) {
169 scope.engine->throwTypeError();
170 return PropertyKey::invalid();
173 return PropertyKey::invalid();