4#ifndef QV4INTERNALCLASS_H
5#define QV4INTERNALCLASS_H
21#include <QVarLengthArray>
23#include <private/qv4propertykey_p.h>
24#include <private/qv4heap_p.h>
37 bool isValid()
const {
return !attributes.isEmpty(); }
58 void detach(
bool grow,
int classSize);
107 uint idx = identifier.id() %
d->alloc;
186 template<
typename StringOrSymbol =
Heap::StringOrSymbol>
197 void mark(MarkStack *s);
201 ExecutionEngine *engine;
202 WriteBarrier::Pointer<Heap::MemberData> data;
205template<
typename StringOrSymbol>
208 QV4::WriteBarrier::markCustom(engine, [&](QV4::MarkStack *stack) {
209 if constexpr (QV4::WriteBarrier::isInsertionBarrier) {
210 if (
auto s = value.asStringOrSymbol<StringOrSymbol>())
242 void add(uint pos, T value) {
243 d->markIfNecessary(value);
244 if (pos <
d->size()) {
245 Q_ASSERT(
d->refcount > 1);
252 Q_ASSERT(pos ==
d->size());
253 if (pos ==
d->alloc())
255 if (pos >=
d->alloc()) {
258 d->setSize(
d->size() + 1);
263 void set(uint pos, T value) {
264 Q_ASSERT(pos <
d->size());
265 d->markIfNecessary(value);
266 if (
d->refcount > 1) {
276 Q_ASSERT(i <
d->size());
280 Q_ASSERT(i <
d->size());
284 void mark(MarkStack *s) {
d->mark(s); }
309 {
return id == other.id && flags == other.flags; }
312 {
return flags < other.flags || (flags == other.flags && id < other.id); }
351 void init(ExecutionEngine *engine);
381 PropertyAttributes a = propertyData.at(e->index);
386 return { UINT_MAX, UINT_MAX, Attr_Invalid };
392 bool isValid()
const {
return index != UINT_MAX; }
401 PropertyAttributes a = propertyData.at(e->index);
406 return { UINT_MAX, Attr_Invalid };
415 PropertyAttributes a = propertyData.at(e->index);
417 if (a.isAccessor()) {
418 Q_ASSERT(e->setterIndex != UINT_MAX);
425 return { UINT_MAX, Attr_Invalid };
434 Q_ASSERT(!propertyData.at(e->index).isEmpty());
447 Q_ASSERT(!propertyData.at(e->index).isEmpty());
483 friend struct ::
QV4::ExecutionEngine;
ArrayElementLessThan(ExecutionEngine *engine, const Value &comparefn)
bool operator()(Value v1, Value v2) const
ReturnedValue operator*() const
OptionalReturnedValue(ReturnedValue v)
ReturnedValue operator->() const
DECLARE_HEAP_OBJECT(StrictArgumentsObject, Object)
DECLARE_EXPORTED_HEAP_OBJECT(Object, Base)
DECLARE_HEAP_OBJECT(ArgumentsObject, Object)
DECLARE_HEAP_OBJECT(MemberData, Base)
DECLARE_HEAP_OBJECT(ArrayData, Base)
Q_STATIC_ASSERT(std::is_trivial_v< ArrayData >)
Scoped< FunctionObject > ScopedFunctionObject
void sortHelper(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
QVector< StackFrame > StackTrace
int qYouForgotTheQ_MANAGED_Macro(T, T)
bool hasExceptionOrIsInterrupted(ExecutionEngine *engine)
Scoped< Object > ScopedObject
ReturnedValue value_convert(ExecutionEngine *e, const Value &v)
Scoped< ArrayObject > ScopedArrayObject
Scoped< String > ScopedString
Scoped< StringOrSymbol > ScopedStringOrSymbol
void qYouForgotTheQ_MANAGED_Macro(T1, T2)
@ Attr_ReadOnly_ButConfigurable
CallData * callDatafromJS(const Scope &scope, const Args *args, const FunctionObject *f)
Q_STATIC_ASSERT(sizeof(CppStackFrame)==sizeof(JSTypesStackFrame))
Scoped< ExecutionContext > ScopedContext
Q_DECLARE_TYPEINFO(QObjectPrivate::ConnectionList, Q_RELOCATABLE_TYPE)
DEFINE_OBJECT_VTABLE(StrictArgumentsObject)
DEFINE_OBJECT_VTABLE(ArgumentsObject)
#define V4_ARRAYDATA(DataClass)
#define V4_MANAGED(DataClass, superClass)
#define V4_MANAGED_SIZE_TEST
#define V4_MANAGED_ITSELF(DataClass, superClass)
#define Q_MANAGED_TYPE(type)
#define V4_INTERNALCLASS(c)
static qint64 virtualGetLength(const Managed *m)
static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *desc, PropertyAttributes attrs)
Heap::CallContext * context() const
static ReturnedValue virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty)
static OwnPropertyKeyIterator * virtualOwnPropertyKeys(const Object *m, Value *target)
static bool isNonStrictArgumentsObject(Managed *m)
static bool virtualDeleteProperty(Managed *m, PropertyKey id)
bool fullyCreated() const
void removeMapping(uint arg)
static PropertyAttributes virtualGetOwnProperty(const Managed *m, PropertyKey id, Property *p)
bool isMapped(uint arg) const
static bool virtualPut(Managed *m, PropertyKey id, const Value &value, Value *receiver)
static bool virtualDefineOwnProperty(Managed *m, PropertyKey id, const Property *p, PropertyAttributes attrs)
static qint64 virtualGetLength(const Managed *m)
QStringList toQStringList() const
void(* setAttribute)(Object *o, uint index, PropertyAttributes attrs)
bool(* putArray)(Object *o, uint index, const Value *values, uint n)
bool(* put)(Object *o, uint index, const Value &value)
void(* push_front)(Object *o, const Value *values, uint n)
ReturnedValue(* get)(const Heap::ArrayData *d, uint index)
bool(* del)(Object *o, uint index)
ReturnedValue(* pop_front)(Object *o)
static constexpr size_t offset
void set(EngineBase *e, HeapBasePtr b)
void set(EngineBase *e, const Value &newVal)
void init(const QStringList &list)
void init(InternalClass *other)
IndexAndAttribute findValueOrSetter(const PropertyKey id)
void init(ExecutionEngine *engine)
static void addMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry)
InternalClassEntry find(const PropertyKey id)
bool verifyIndex(const PropertyKey id, uint index)
PropertyHash propertyTable
QVarLengthArray< Transition, 1 > transitions
SharedInternalClassData< PropertyKey > nameMap
bool isUsedAsProto() const
IndexAndAttribute findValueOrGetter(const PropertyKey id)
bool isImplicitlyFrozen() const
quint8 numRedundantTransitions
InternalClassTransition Transition
bool isExtensible() const
uint indexOfValueOrGetter(const PropertyKey id)
@ MaxRedundantTransitions
InternalClassTransition & lookupOrInsertTransition(const InternalClassTransition &t)
static void markObjects(Heap::Base *ic, MarkStack *stack)
static void removeMember(QV4::Object *object, PropertyKey identifier)
static void changeMember(QV4::Object *object, PropertyKey id, PropertyAttributes data, InternalClassEntry *entry=nullptr)
PropertyHash::Entry * findEntry(const PropertyKey id)
SharedInternalClassData< PropertyAttributes > propertyData
PropertyAttributes attributes(uint i) const
uint mappedIndex(uint index) const
void setData(EngineBase *e, uint index, Value newVal)
const Value & data(uint index) const
uint mappedIndex(uint index) const
PropertyAttributes attributes(uint i) const
PropertyAttributes attributes
Heap::InternalClass * lookup
bool operator<(const InternalClassTransition &other) const
bool operator==(const InternalClassTransition &other) const
static Heap::MemberData * allocate(QV4::ExecutionEngine *e, uint n, Heap::MemberData *old=nullptr)
const Value * data() const
void set(EngineBase *e, uint index, Value v)
const Value & operator[](uint idx) const
void set(EngineBase *e, uint index, Heap::Base *b)
PropertyKey next(const Object *o, Property *pd=nullptr, PropertyAttributes *attrs=nullptr) override
PropertyHashData(int numBits)
PropertyHash::Entry * entries
void addEntry(const Entry &entry, int classSize)
PropertyHash(const PropertyHash &other)
PropertyHash & operator=(const PropertyHash &other)
void detach(bool grow, int classSize)
Entry * lookup(PropertyKey identifier) const
const Value * operator->() const
const Value & operator*() const
void set(EngineBase *e, Value newVal)
bool isStringOrSymbol() const
bool isArrayIndex() const
static PropertyKey fromId(quint64 id)
Heap::StringOrSymbol * toStringOrSymbol(ExecutionEngine *e)
bool isCanonicalNumericIndexString() const
Q_QML_EXPORT bool isSymbol() const
bool operator<(const PropertyKey &other) const
Q_QML_EXPORT bool isString() const
StringOrSymbol * asStringOrSymbol() const
uint asArrayIndex() const
bool operator==(const PropertyKey &other) const
static PropertyKey invalid()
static PropertyKey fromStringOrSymbol(Engine *engine, StringOrSymbol *b)
friend size_t qHash(const PropertyKey &key, size_t seed=0)
static PropertyKey fromArrayIndex(uint idx)
Heap::String * asFunctionName(ExecutionEngine *e, FunctionNamePrefix prefix) const
bool operator!=(const PropertyKey &other) const
void setGetter(FunctionObject *g)
Heap::FunctionObject * getter() const
bool isSubset(const PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const
void setSetter(FunctionObject *s)
void fullyPopulated(PropertyAttributes *attrs)
bool isCompatible(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs) const
void copy(const Property *other, PropertyAttributes attrs)
void completed(PropertyAttributes *attrs)
Property(Heap::FunctionObject *getter, Heap::FunctionObject *setter)
Heap::FunctionObject * setter() const
void merge(PropertyAttributes &attrs, const Property *other, PropertyAttributes otherAttrs)
Scope(ExecutionEngine *e)
Scope(ExecutionContext *ctx)
PropertyKey * operator->()
ScopedPropertyKey & operator=(const PropertyKey &other)
ScopedPropertyKey(const Scope &scope)
ScopedPropertyKey(const Scope &scope, const PropertyKey &v)
operator PropertyKey() const
bool operator==(const PropertyKey &other) const
bool operator==(const ScopedPropertyKey &other) const
bool operator!=(const ScopedPropertyKey &other) const
bool operator!=(const PropertyKey &other) const
operator const Property *() const
ScopedProperty(Scope &scope)
ScopedValue(const Scope &scope, Managed *m)
ScopedValue & operator=(Managed *m)
ScopedValue & operator=(const Value &v)
ScopedValue(const Scope &scope, const Value &v)
ScopedValue(ScopedValue &&)=default
ScopedValue(const Scope &scope)
ScopedValue(const ScopedValue &)=default
ScopedValue(const Scope &scope, const ReturnedValue &v)
ScopedValue & operator=(const ScopedValue &other)
operator const Value &() const
const Value * operator->() const
ScopedValue(const Scope &scope, Heap::Base *o)
ScopedValue & operator=(const ReturnedValue &v)
ScopedValue & operator=(Heap::Base *o)
void markIfNecessary(const PropertyKey &value)
SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate &other, uint pos, PropertyKey value)
void set(uint i, PropertyKey t)
~SharedInternalClassDataPrivate()
SharedInternalClassDataPrivate(ExecutionEngine *e)
PropertyKey at(uint i) const
SharedInternalClassDataPrivate(const SharedInternalClassDataPrivate &other)
void set(uint pos, T value)
SharedInternalClassData(ExecutionEngine *e)
void add(uint pos, T value)
SharedInternalClassData & operator=(const SharedInternalClassData &other)
SharedInternalClassDataPrivate< T > Private
~SharedInternalClassData()
SharedInternalClassData(const SharedInternalClassData &other)
SparseArrayNode * copy(SparseArray *d) const
SparseArrayNode * lowerBound(uint key)
const SparseArrayNode * previousNode() const
SparseArrayNode * parent() const
SparseArrayNode * nextNode()
SparseArrayNode * upperBound(uint key)
const SparseArrayNode * nextNode() const
SparseArrayNode * previousNode()
void setParent(SparseArrayNode *pp)
SparseArrayNode * upperBound(uint key)
SparseArrayNode * erase(SparseArrayNode *n)
void push_back(uint at, uint len)
SparseArrayNode * lowerBound(uint key)
const SparseArrayNode * begin() const
SparseArrayNode * insert(uint akey)
QList< int > keys() const
SparseArrayNode * findNode(uint akey) const
void freeTree(SparseArrayNode *root, int alignment)
const SparseArrayNode * end() const
const Value * data() const
void set(EngineBase *e, uint index, Value v)
void set(EngineBase *e, uint index, Value::HeapBasePtr b)
void mark(MarkStack *markStack)
Value::HeapBasePtr base()
const Value & operator[](uint index) const
static constexpr size_t offset