From 56bff8f7abc2f0eeadd4d197667132af6eed6f3a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 23 Jun 2018 23:07:23 +0200 Subject: Clean up the property key API in StringOrSymbol Get rid of makeIdentifier(), as toPropertyKey() will take care of it. Rename identifier() to propertyKey() and check that the key is valid. Remove String/StringOrSymbol::asArrayIndex(), we don't need it anymore. Change-Id: I3c490fabc1475c9ea288b49b1638b6fa1bc237b7 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4object.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/qml/jsruntime/qv4object.cpp') diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 0ce5328193..a59d278f7d 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -251,8 +251,8 @@ void Heap::Object::markObjects(Heap::Base *b, MarkStack *stack) void Object::insertMember(StringOrSymbol *s, const Property *p, PropertyAttributes attributes) { uint idx; - s->makeIdentifier(); - Heap::InternalClass::addMember(this, s->identifier(), attributes, &idx); + PropertyKey key = s->toPropertyKey(); + Heap::InternalClass::addMember(this, key, attributes, &idx); if (attributes.isAccessor()) { setProperty(idx + GetterOffset, p->value); @@ -410,10 +410,9 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, Value *name, uint * // Section 8.12.3 ReturnedValue Object::internalGet(StringOrSymbol *name, const Value *receiver, bool *hasProperty) const { - Q_ASSERT(name->asArrayIndex() == UINT_MAX); + PropertyKey id = name->toPropertyKey(); - name->makeIdentifier(); - PropertyKey id = name->identifier(); + Q_ASSERT(!id.isArrayIndex()); Heap::Object *o = d(); while (o) { @@ -506,7 +505,7 @@ bool Object::internalPut(PropertyKey id, const Value &value, Value *receiver) return false; } else if (!attrs.isWritable()) return false; - else if (isArrayObject() && id == engine->id_length()->identifier()) { + else if (isArrayObject() && id == engine->id_length()->propertyKey()) { bool ok; uint l = value.asArrayLength(&ok); if (!ok) { @@ -672,7 +671,7 @@ bool Object::internalDefineOwnProperty(ExecutionEngine *engine, uint index, Stri current->merge(cattrs, p, attrs); if (member) { - Heap::InternalClass::changeMember(this, member->identifier(), cattrs); + Heap::InternalClass::changeMember(this, member->propertyKey(), cattrs); setProperty(index, current); } else { setArrayAttributes(index, cattrs); @@ -998,9 +997,9 @@ bool ArrayObject::defineOwnProperty(Managed *m, PropertyKey id, const Property * } ExecutionEngine *engine = m->engine(); - if (id == engine->id_length()->identifier()) { + if (id == engine->id_length()->propertyKey()) { Scope scope(engine); - Q_ASSERT(Heap::ArrayObject::LengthPropertyIndex == a->internalClass()->find(engine->id_length()->identifier())); + Q_ASSERT(Heap::ArrayObject::LengthPropertyIndex == a->internalClass()->find(engine->id_length()->propertyKey())); ScopedProperty lp(scope); PropertyAttributes cattrs; a->getProperty(Heap::ArrayObject::LengthPropertyIndex, lp, &cattrs); @@ -1021,7 +1020,7 @@ bool ArrayObject::defineOwnProperty(Managed *m, PropertyKey id, const Property * } if (attrs.hasWritable() && !attrs.isWritable()) { cattrs.setWritable(false); - Heap::InternalClass::changeMember(a, engine->id_length()->identifier(), cattrs); + Heap::InternalClass::changeMember(a, engine->id_length()->propertyKey(), cattrs); } if (!succeeded) return false; -- cgit v1.2.3