}
// Section 8.12.2
-PropertyDescriptor *Object::__getPropertyDescriptor__(ExecutionContext *ctx, String *name)
+PropertyDescriptor *Object::__getPropertyDescriptor__(const ExecutionContext *ctx, String *name) const
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
return __getPropertyDescriptor__(ctx, idx);
- Object *o = this;
+ const Object *o = this;
while (o) {
uint idx = o->internalClass->find(name);
if (idx < UINT_MAX)
return 0;
}
-PropertyDescriptor *Object::__getPropertyDescriptor__(ExecutionContext *ctx, uint index)
+PropertyDescriptor *Object::__getPropertyDescriptor__(const ExecutionContext *ctx, uint index) const
{
- Object *o = this;
+ const Object *o = this;
while (o) {
PropertyDescriptor *p = o->arrayAt(index);
if(p && p->type != PropertyDescriptor::Generic)
return p;
if (o->isStringObject()) {
- p = static_cast<StringObject *>(o)->getIndex(ctx, index);
+ p = static_cast<const StringObject *>(o)->getIndex(ctx, index);
if (p)
return p;
}
ctx->throwTypeError();
}
-// Section 8.12.6
-bool Object::__hasProperty__(const ExecutionContext *ctx, String *name) const
-{
- uint idx = name->asArrayIndex();
- if (idx != UINT_MAX)
- return __hasProperty__(ctx, idx);
-
- name->makeIdentifier(ctx);
-
- if (internalClass->find(name) != UINT_MAX)
- return true;
-
- return prototype ? prototype->__hasProperty__(ctx, name) : false;
-}
-
-bool Object::__hasProperty__(const ExecutionContext *ctx, uint index) const
-{
- const PropertyDescriptor *p = arrayAt(index);
- if (p && p->type != PropertyDescriptor::Generic)
- return true;
-
- return prototype ? prototype->__hasProperty__(ctx, index) : false;
-}
-
// Section 8.12.7
bool Object::__delete__(ExecutionContext *ctx, String *name)
{
PropertyDescriptor *__getOwnProperty__(ExecutionContext *ctx, String *name);
PropertyDescriptor *__getOwnProperty__(ExecutionContext *ctx, uint index);
- PropertyDescriptor *__getPropertyDescriptor__(ExecutionContext *ctx, String *name);
- PropertyDescriptor *__getPropertyDescriptor__(ExecutionContext *ctx, uint index);
+
+ // -> vtable
+ PropertyDescriptor *__getPropertyDescriptor__(const ExecutionContext *ctx, String *name) const;
+ PropertyDescriptor *__getPropertyDescriptor__(const ExecutionContext *ctx, uint index) const;
Value __get__(ExecutionContext *ctx, String *name, bool *hasProperty = 0);
Value __get__(ExecutionContext *ctx, uint index, bool *hasProperty = 0);
+ // -> vtable
void __put__(ExecutionContext *ctx, String *name, const Value &value);
void __put__(ExecutionContext *ctx, uint index, const Value &value);
- bool __hasProperty__(const ExecutionContext *ctx, String *name) const;
- bool __hasProperty__(const ExecutionContext *ctx, uint index) const;
+ bool __hasProperty__(const ExecutionContext *ctx, String *name) const {
+ PropertyDescriptor *pd = __getPropertyDescriptor__(ctx, name);
+ return pd && pd->type != PropertyDescriptor::Generic;
+ }
+ bool __hasProperty__(const ExecutionContext *ctx, uint index) const {
+ PropertyDescriptor *pd = __getPropertyDescriptor__(ctx, index);
+ return pd && pd->type != PropertyDescriptor::Generic;
+ }
bool __delete__(ExecutionContext *ctx, String *name);
bool __delete__(ExecutionContext *ctx, uint index);
bool __defineOwnProperty__(ExecutionContext *ctx, PropertyDescriptor *current, const PropertyDescriptor *desc);
defineReadonlyProperty(ctx->engine->id_length, Value::fromUInt32(value.stringValue()->toQString().length()));
}
-PropertyDescriptor *StringObject::getIndex(ExecutionContext *ctx, uint index)
+PropertyDescriptor *StringObject::getIndex(const ExecutionContext *ctx, uint index) const
{
QString str = value.stringValue()->toQString();
if (index >= (uint)str.length())
struct StringObject: Object {
Value value;
- PropertyDescriptor tmpProperty;
+ mutable PropertyDescriptor tmpProperty;
StringObject(ExecutionContext *ctx, const Value &value);
- PropertyDescriptor *getIndex(ExecutionContext *ctx, uint index);
+ PropertyDescriptor *getIndex(const ExecutionContext *ctx, uint index) const;
protected:
static const ManagedVTable static_vtbl;