diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-06-23 20:08:40 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-07-02 19:29:32 +0000 |
commit | 56602df447c5f16257874f2e97b078dcf76f2467 (patch) | |
tree | 901c76eb6262dad80e6ab94af810c645355cb6d5 /src/qml/jsruntime/qv4identifier.cpp | |
parent | db695c5b1d07275f208446dad178b1131b20bb0a (diff) |
Cleanups in the Identifier API
Rename from/asHeapObject to from/asStringOrSymbol and fix
the signature.
Add a isStringOrSymbol() method and redefine isValid() to also
include array indices.
Change-Id: Ic8272bfbe84d15421e2ebe86ddda7fdaa8db4f3e
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4identifier.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4identifier.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4identifier.cpp b/src/qml/jsruntime/qv4identifier.cpp index 7efd980139..1e9a807848 100644 --- a/src/qml/jsruntime/qv4identifier.cpp +++ b/src/qml/jsruntime/qv4identifier.cpp @@ -46,26 +46,26 @@ namespace QV4 { bool Identifier::isString() const { - return isValid() && asHeapObject()->internalClass->vtable->isString; + return isStringOrSymbol() && asStringOrSymbol()->internalClass->vtable->isString; } bool Identifier::isSymbol() const { - return isValid() && !asHeapObject()->internalClass->vtable->isString && asHeapObject()->internalClass->vtable->isStringOrSymbol; + return isStringOrSymbol() && !asStringOrSymbol()->internalClass->vtable->isString && asStringOrSymbol()->internalClass->vtable->isStringOrSymbol; } Heap::StringOrSymbol *Identifier::toStringOrSymbol(ExecutionEngine *e) { if (isArrayIndex()) return Primitive::fromUInt32(asArrayIndex()).toString(e); - return static_cast<Heap::StringOrSymbol *>(asHeapObject()); + return static_cast<Heap::StringOrSymbol *>(asStringOrSymbol()); } QString Identifier::toQString() const { if (isArrayIndex()) return QString::number(asArrayIndex()); - Heap::Base *b = asHeapObject(); + Heap::Base *b = asStringOrSymbol(); Q_ASSERT(b->internalClass->vtable->isStringOrSymbol); Heap::StringOrSymbol *s = static_cast<Heap::StringOrSymbol *>(b); return s->toQString(); @@ -130,7 +130,7 @@ void IdentifierHash::detach() IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) { - Q_ASSERT(identifier.isValid()); + Q_ASSERT(identifier.isStringOrSymbol()); // fill up to max 50% bool grow = (d->alloc <= d->size*2); @@ -169,7 +169,7 @@ IdentifierHashEntry *IdentifierHash::addEntry(Identifier identifier) const IdentifierHashEntry *IdentifierHash::lookup(Identifier identifier) const { - if (!d || !identifier.isValid()) + if (!d || !identifier.isStringOrSymbol()) return nullptr; Q_ASSERT(d->entries); @@ -232,7 +232,7 @@ void IdentifierHashData::markObjects(MarkStack *markStack) const IdentifierHashEntry *e = entries; IdentifierHashEntry *end = e + alloc; while (e < end) { - if (Heap::Base *o = e->identifier.asHeapObject()) + if (Heap::Base *o = e->identifier.asStringOrSymbol()) o->mark(markStack); ++e; } |