aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4internalclass_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-23 15:46:25 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-27 08:33:59 +0000
commit7cc66a996e70c52bc274ae9f15f65e8a638894d9 (patch)
tree6b493e26e775db2c6ef5b3c22a031e8dbaad01d0 /src/qml/jsruntime/qv4internalclass_p.h
parentf63d48d474db7e9eff7583f1b8478228b13d3c82 (diff)
Get rid of remaining assumptions about setter being next to getters
The only place where we now assume that getters and setters are next to each other in the MemberData is in the internal class. Change-Id: I3285f3abb1cbfe051853e808339cd360eb602262 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4internalclass_p.h')
-rw-r--r--src/qml/jsruntime/qv4internalclass_p.h30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4internalclass_p.h b/src/qml/jsruntime/qv4internalclass_p.h
index cced746568..febc1561f9 100644
--- a/src/qml/jsruntime/qv4internalclass_p.h
+++ b/src/qml/jsruntime/qv4internalclass_p.h
@@ -63,6 +63,13 @@ namespace QV4 {
struct VTable;
struct MarkStack;
+struct InternalClassEntry {
+ uint index;
+ uint setterIndex;
+ PropertyAttributes attributes;
+ bool isValid() const { return !attributes.isEmpty(); }
+};
+
struct PropertyHashData;
struct PropertyHash
{
@@ -347,10 +354,10 @@ struct InternalClass : Base {
Q_QML_PRIVATE_EXPORT QString keyAt(uint index) const;
Q_REQUIRED_RESULT InternalClass *nonExtensible();
- static void addMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index);
- Q_REQUIRED_RESULT InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, uint *index = nullptr);
- Q_REQUIRED_RESULT InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, uint *index = nullptr);
- static void changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, uint *index = nullptr);
+ static void addMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry);
+ Q_REQUIRED_RESULT InternalClass *addMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr);
+ Q_REQUIRED_RESULT InternalClass *changeMember(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry = nullptr);
+ static void changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry = nullptr);
static void removeMember(QV4::Object *object, PropertyKey identifier);
PropertyHash::Entry *findEntry(const PropertyKey id)
{
@@ -363,6 +370,19 @@ struct InternalClass : Base {
return nullptr;
}
+ InternalClassEntry find(const PropertyKey id)
+ {
+ Q_ASSERT(id.isStringOrSymbol());
+
+ PropertyHash::Entry *e = propertyTable.lookup(id);
+ if (e && e->index < size) {
+ PropertyAttributes a = propertyData.at(e->index);
+ return { e->index, (a.isAccessor() ? e->index + 1 : UINT_MAX), a };
+ }
+
+ return { UINT_MAX, UINT_MAX, Attr_Invalid };
+ }
+
struct IndexAndAttribute {
uint index;
PropertyAttributes attrs;
@@ -439,7 +459,7 @@ struct InternalClass : Base {
private:
Q_QML_EXPORT InternalClass *changeVTableImpl(const VTable *vt);
Q_QML_EXPORT InternalClass *changePrototypeImpl(Heap::Object *proto);
- InternalClass *addMemberImpl(PropertyKey identifier, PropertyAttributes data, uint *index);
+ InternalClass *addMemberImpl(PropertyKey identifier, PropertyAttributes data, InternalClassEntry *entry);
void removeChildEntry(InternalClass *child);
friend struct ExecutionEngine;