4#ifndef QV4PROPERTYDESCRIPTOR_H
5#define QV4PROPERTYDESCRIPTOR_H
33 if (!attrs->hasType()) {
34 value = Value::undefinedValue();
36 if (attrs->type() == PropertyAttributes::Accessor) {
37 attrs->clearWritable();
39 value = Value::undefinedValue();
41 set = Value::undefinedValue();
49 value = Encode::undefined();
50 if (attrs->isGeneric() || attrs->isData()) {
51 attrs->setType(PropertyAttributes::Data);
52 if (!attrs->hasWritable())
53 attrs->setWritable(
false);
56 set = Encode::undefined();
58 if (!attrs->hasEnumerable())
59 attrs->setEnumerable(
false);
60 if (!attrs->hasConfigurable())
61 attrs->setConfigurable(
false);
64 inline bool isSubset(
const PropertyAttributes &attrs,
const Property *other, PropertyAttributes otherAttrs)
const;
65 inline void merge(PropertyAttributes &attrs,
const Property *other, PropertyAttributes otherAttrs);
67 inline Heap::FunctionObject *
getter()
const {
return reinterpret_cast<Heap::FunctionObject *>(value.heapObject()); }
68 inline Heap::FunctionObject *
setter()
const {
return reinterpret_cast<Heap::FunctionObject *>(set.heapObject()); }
69 inline void setGetter(FunctionObject *g) { value =
reinterpret_cast<Managed *>(g); }
70 inline void setSetter(FunctionObject *s) { set = (s ?
reinterpret_cast<Managed *>(s) :
nullptr); }
74 if (attrs.isAccessor())
80 if (otherAttrs.isEmpty())
82 if (!attrs.isConfigurable()) {
83 if (otherAttrs.hasConfigurable() && otherAttrs.isConfigurable())
85 if (otherAttrs.hasEnumerable() && otherAttrs.isEnumerable() != attrs.isEnumerable())
88 if (otherAttrs.isGeneric())
90 if (attrs.isData() != otherAttrs.isData()) {
91 if (!attrs.isConfigurable())
93 }
else if (attrs.isData() && otherAttrs.isData()) {
94 if (!attrs.isConfigurable() && !attrs.isWritable()) {
95 if (otherAttrs.hasWritable() && otherAttrs.isWritable())
97 if (!other->value.isEmpty() && !value.sameValue(other->value))
100 }
else if (attrs.isAccessor() && otherAttrs.isAccessor()) {
101 if (!attrs.isConfigurable()) {
102 if (!other->value.isEmpty() && !value.sameValue(other->value))
104 if (!other->set.isEmpty() && !set.sameValue(other->set))
112 explicit Property() { value = Encode::undefined(); set = Value::fromHeapObject(
nullptr); }
114 value.setM(
reinterpret_cast<Heap::Base *>(getter));
115 set.setM(
reinterpret_cast<Heap::Base *>(setter));
123 if (attrs.type() != PropertyAttributes::Generic && attrs.type() != otherAttrs.type())
125 if (attrs.hasEnumerable() && attrs.isEnumerable() != otherAttrs.isEnumerable())
127 if (attrs.hasConfigurable() && attrs.isConfigurable() != otherAttrs.isConfigurable())
129 if (attrs.hasWritable() && attrs.isWritable() != otherAttrs.isWritable())
131 if (attrs.type() == PropertyAttributes::Data && !value.sameValue(other->value))
133 if (attrs.type() == PropertyAttributes::Accessor) {
134 if (value.heapObject() != other->value.heapObject())
136 if (set.heapObject() != other->set.heapObject())
144 if (otherAttrs.hasEnumerable())
145 attrs.setEnumerable(otherAttrs.isEnumerable());
146 if (otherAttrs.hasConfigurable())
147 attrs.setConfigurable(otherAttrs.isConfigurable());
148 if (otherAttrs.hasWritable())
149 attrs.setWritable(otherAttrs.isWritable());
150 if (otherAttrs.type() == PropertyAttributes::Accessor) {
151 attrs.setType(PropertyAttributes::Accessor);
152 if (!other->value.isEmpty())
153 value = other->value;
154 if (!other->set.isEmpty())
156 }
else if (otherAttrs.type() == PropertyAttributes::Data){
157 attrs.setType(PropertyAttributes::Data);
158 value = other->value;
166 void set(EngineBase *e, Value newVal) {
167 WriteBarrier::write(e, base, slot->data_ptr(), newVal.asReturnedValue());
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)
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
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)
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
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
const Value * operator->() const
const Value & operator*() const
void set(EngineBase *e, Value newVal)
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)
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