d()->fullyCreated = true;
}
-bool ArgumentsObject::defineOwnProperty(ExecutionContext *ctx, uint index, const Property &desc, PropertyAttributes attrs)
+bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, const Property &desc, PropertyAttributes attrs)
{
fullyCreate();
- Scope scope(ctx);
+ Scope scope(engine);
Property *pd = arrayData() ? arrayData()->getProperty(index) : 0;
Property map;
PropertyAttributes mapAttrs;
pd->value = mappedArguments()->data[index];
}
- bool strict = ctx->d()->strictMode;
- ctx->d()->strictMode = false;
- bool result = Object::defineOwnProperty2(ctx, index, desc, attrs);
- ctx->d()->strictMode = strict;
+ bool strict = engine->currentContext()->d()->strictMode;
+ engine->currentContext()->d()->strictMode = false;
+ bool result = Object::defineOwnProperty2(scope.engine, index, desc, attrs);
+ engine->currentContext()->d()->strictMode = strict;
if (isMapped && attrs.isData()) {
Q_ASSERT(arrayData());
}
}
- if (ctx->d()->strictMode && !result)
- return ctx->engine()->throwTypeError();
+ if (engine->currentContext()->d()->strictMode && !result)
+ return engine->throwTypeError();
return result;
}
!static_cast<ArgumentsObject *>(m)->context()->strictMode;
}
- bool defineOwnProperty(ExecutionContext *ctx, uint index, const Property &desc, PropertyAttributes attrs);
+ bool defineOwnProperty(ExecutionEngine *engine, uint index, const Property &desc, PropertyAttributes attrs);
static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty);
static void putIndexed(Managed *m, uint index, const ValueRef value);
static bool deleteIndexedProperty(Managed *m, uint index);
Property desc(Primitive::undefinedValue());
PropertyAttributes attrs(Attr_Data);
attrs.setConfigurable(deletable);
- activation->__defineOwnProperty__(this, name, desc, attrs);
+ activation->__defineOwnProperty__(scope.engine, name, desc, attrs);
}
if (replacerFunction) {
ScopedObject holder(scope, ctx->d()->engine->newObject());
- holder->put(ctx, QString(), value);
+ holder->put(scope.engine, QString(), value);
ScopedCallData callData(scope, 2);
callData->args[0] = Value::fromHeapObject(ctx->d()->engine->newString(key));
callData->args[1] = value;
return true;
}
-void Object::put(ExecutionContext *ctx, const QString &name, const ValueRef value)
+void Object::put(ExecutionEngine *engine, const QString &name, const ValueRef value)
{
- Scope scope(ctx);
- ScopedString n(scope, ctx->d()->engine->newString(name));
+ Scope scope(engine);
+ ScopedString n(scope, engine->newString(name));
put(n.getPointer(), value);
}
}
// Section 8.12.9
-bool Object::__defineOwnProperty__(ExecutionContext *ctx, String *name, const Property &p, PropertyAttributes attrs)
+bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const Property &p, PropertyAttributes attrs)
{
uint idx = name->asArrayIndex();
if (idx != UINT_MAX)
- return __defineOwnProperty__(ctx, idx, p, attrs);
+ return __defineOwnProperty__(engine, idx, p, attrs);
name->makeIdentifier();
- Scope scope(ctx);
+ Scope scope(engine);
Property *current;
PropertyAttributes *cattrs;
uint memberIndex;
- if (isArrayObject() && name->equals(ctx->d()->engine->id_length)) {
- assert(Heap::ArrayObject::LengthPropertyIndex == internalClass()->find(ctx->d()->engine->id_length));
+ if (isArrayObject() && name->equals(engine->id_length)) {
+ Q_ASSERT(Heap::ArrayObject::LengthPropertyIndex == internalClass()->find(engine->id_length));
Property *lp = propertyAt(Heap::ArrayObject::LengthPropertyIndex);
cattrs = internalClass()->propertyData.constData() + Heap::ArrayObject::LengthPropertyIndex;
if (attrs.isEmpty() || p.isSubset(attrs, *lp, *cattrs))
uint l = p.value.asArrayLength(&ok);
if (!ok) {
ScopedValue v(scope, p.value);
- ctx->engine()->throwRangeError(v);
+ engine->throwRangeError(v);
return false;
}
succeeded = setArrayLength(l);
return true;
}
- return __defineOwnProperty__(ctx, memberIndex, name, p, attrs);
+ return __defineOwnProperty__(engine, memberIndex, name, p, attrs);
reject:
- if (ctx->d()->strictMode)
- ctx->engine()->throwTypeError();
+ if (engine->currentContext()->d()->strictMode)
+ engine->throwTypeError();
return false;
}
-bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Property &p, PropertyAttributes attrs)
+bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, const Property &p, PropertyAttributes attrs)
{
// 15.4.5.1, 4b
if (isArrayObject() && index >= getLength() && !internalClass()->propertyData[Heap::ArrayObject::LengthPropertyIndex].isWritable())
goto reject;
if (ArgumentsObject::isNonStrictArgumentsObject(this))
- return static_cast<ArgumentsObject *>(this)->defineOwnProperty(ctx, index, p, attrs);
+ return static_cast<ArgumentsObject *>(this)->defineOwnProperty(engine, index, p, attrs);
- return defineOwnProperty2(ctx, index, p, attrs);
+ return defineOwnProperty2(engine, index, p, attrs);
reject:
- if (ctx->d()->strictMode)
- ctx->engine()->throwTypeError();
+ if (engine->currentContext()->d()->strictMode)
+ engine->throwTypeError();
return false;
}
-bool Object::defineOwnProperty2(ExecutionContext *ctx, uint index, const Property &p, PropertyAttributes attrs)
+bool Object::defineOwnProperty2(ExecutionEngine *engine, uint index, const Property &p, PropertyAttributes attrs)
{
Property *current = 0;
pp.copy(p, attrs);
pp.fullyPopulated(&attrs);
if (attrs == Attr_Data) {
- Scope scope(ctx);
+ Scope scope(engine);
ScopedValue v(scope, pp.value);
arraySet(index, v);
} else {
return true;
}
- return __defineOwnProperty__(ctx, index, 0, p, attrs);
+ return __defineOwnProperty__(engine, index, 0, p, attrs);
reject:
- if (ctx->d()->strictMode)
- ctx->engine()->throwTypeError();
+ if (engine->currentContext()->d()->strictMode)
+ engine->throwTypeError();
return false;
}
-bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, String *member, const Property &p, PropertyAttributes attrs)
+bool Object::__defineOwnProperty__(ExecutionEngine *engine, uint index, String *member, const Property &p, PropertyAttributes attrs)
{
// clause 5
if (attrs.isEmpty())
setHasAccessorProperty();
return true;
reject:
- if (ctx->d()->strictMode)
- ctx->engine()->throwTypeError();
+ if (engine->currentContext()->d()->strictMode)
+ engine->throwTypeError();
return false;
}
-bool Object::__defineOwnProperty__(ExecutionContext *ctx, const QString &name, const Property &p, PropertyAttributes attrs)
+bool Object::__defineOwnProperty__(ExecutionEngine *engine, const QString &name, const Property &p, PropertyAttributes attrs)
{
- Scope scope(ctx);
- ScopedString s(scope, ctx->d()->engine->newString(name));
- return __defineOwnProperty__(ctx, s.getPointer(), p, attrs);
+ Scope scope(engine);
+ ScopedString s(scope, engine->newString(name));
+ return __defineOwnProperty__(engine, s.getPointer(), p, attrs);
}
bool hasOwnProperty(String *name) const;
bool hasOwnProperty(uint index) const;
- bool __defineOwnProperty__(ExecutionContext *ctx, uint index, String *member, const Property &p, PropertyAttributes attrs);
- bool __defineOwnProperty__(ExecutionContext *ctx, String *name, const Property &p, PropertyAttributes attrs);
- bool __defineOwnProperty__(ExecutionContext *ctx, uint index, const Property &p, PropertyAttributes attrs);
- bool __defineOwnProperty__(ExecutionContext *ctx, const QString &name, const Property &p, PropertyAttributes attrs);
- bool defineOwnProperty2(ExecutionContext *ctx, uint index, const Property &p, PropertyAttributes attrs);
+ bool __defineOwnProperty__(ExecutionEngine *engine, uint index, String *member, const Property &p, PropertyAttributes attrs);
+ bool __defineOwnProperty__(ExecutionEngine *engine, String *name, const Property &p, PropertyAttributes attrs);
+ bool __defineOwnProperty__(ExecutionEngine *engine, uint index, const Property &p, PropertyAttributes attrs);
+ bool __defineOwnProperty__(ExecutionEngine *engine, const QString &name, const Property &p, PropertyAttributes attrs);
+ bool defineOwnProperty2(ExecutionEngine *engine, uint index, const Property &p, PropertyAttributes attrs);
//
// helpers
//
- void put(ExecutionContext *ctx, const QString &name, const ValueRef value);
+ void put(ExecutionEngine *engine, const QString &name, const ValueRef value);
static ReturnedValue getValue(const ValueRef thisObject, const Property *p, PropertyAttributes attrs);
ReturnedValue getValue(const Property *p, PropertyAttributes attrs) const {
if (scope.engine->hasException)
return Encode::undefined();
- if (!O->__defineOwnProperty__(ctx, name.getPointer(), pd, attrs))
+ if (!O->__defineOwnProperty__(scope.engine, name.getPointer(), pd, attrs))
return ctx->engine()->throwTypeError();
return O.asReturnedValue();
return Encode::undefined();
bool ok;
if (name)
- ok = O->__defineOwnProperty__(ctx, name.getPointer(), n, nattrs);
+ ok = O->__defineOwnProperty__(scope.engine, name.getPointer(), n, nattrs);
else
- ok = O->__defineOwnProperty__(ctx, index, n, nattrs);
+ ok = O->__defineOwnProperty__(scope.engine, index, n, nattrs);
if (!ok)
return ctx->engine()->throwTypeError();
}
Property pd;
pd.value = f;
pd.set = Primitive::emptyValue();
- o->__defineOwnProperty__(ctx, prop.getPointer(), pd, Attr_Accessor);
+ o->__defineOwnProperty__(scope.engine, prop.getPointer(), pd, Attr_Accessor);
return Encode::undefined();
}
Property pd;
pd.value = Primitive::emptyValue();
pd.set = f;
- o->__defineOwnProperty__(ctx, prop.getPointer(), pd, Attr_Accessor);
+ o->__defineOwnProperty__(scope.engine, prop.getPointer(), pd, Attr_Accessor);
return Encode::undefined();
}
if (attrs.isData()) {
pd.value = desc->value;
s = engine->newString(QStringLiteral("value"));
- o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
+ o->__defineOwnProperty__(scope.engine, s.getPointer(), pd, Attr_Data);
pd.value = Primitive::fromBoolean(attrs.isWritable());
s = engine->newString(QStringLiteral("writable"));
- o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
+ o->__defineOwnProperty__(scope.engine, s.getPointer(), pd, Attr_Data);
} else {
pd.value = desc->getter() ? desc->getter()->asReturnedValue() : Encode::undefined();
s = engine->newString(QStringLiteral("get"));
- o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
+ o->__defineOwnProperty__(scope.engine, s.getPointer(), pd, Attr_Data);
pd.value = desc->setter() ? desc->setter()->asReturnedValue() : Encode::undefined();
s = engine->newString(QStringLiteral("set"));
- o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
+ o->__defineOwnProperty__(scope.engine, s.getPointer(), pd, Attr_Data);
}
pd.value = Primitive::fromBoolean(attrs.isEnumerable());
s = engine->newString(QStringLiteral("enumerable"));
- o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
+ o->__defineOwnProperty__(scope.engine, s.getPointer(), pd, Attr_Data);
pd.value = Primitive::fromBoolean(attrs.isConfigurable());
s = engine->newString(QStringLiteral("configurable"));
- o->__defineOwnProperty__(ctx, s.getPointer(), pd, Attr_Data);
+ o->__defineOwnProperty__(scope.engine, s.getPointer(), pd, Attr_Data);
return o.asReturnedValue();
}