__defineOwnProperty__(context, i, &pd);
}
defineDefaultProperty(context, QStringLiteral("callee"), Value::fromObject(context->function));
- isArgumentsObject = true;
+ isNonStrictArgumentsObject = true;
}
}
pd->value = mappedArguments.at(index);
}
- isArgumentsObject = false;
+ isNonStrictArgumentsObject = false;
bool strict = ctx->strictMode;
ctx->strictMode = false;
bool result = Object::__defineOwnProperty__(ctx, index, desc);
ctx->strictMode = strict;
- isArgumentsObject = true;
+ isNonStrictArgumentsObject = true;
if (isMapped && desc->isData()) {
if (desc->type != PropertyDescriptor::Generic) {
uint ArrayPrototype::getLength(ExecutionContext *ctx, Object *o)
{
- if (o->isArray)
+ if (o->isArrayObject())
return o->array.length();
return o->__get__(ctx, ctx->engine->id_length).toUInt32(ctx);
}
uint len = getLength(ctx, instance);
if (!len) {
- if (!instance->isArray)
+ if (!instance->isArrayObject())
instance->__put__(ctx, ctx->engine->id_length, Value::fromInt32(0));
return Value::undefinedValue();
}
Value result = instance->__get__(ctx, len - 1);
instance->__delete__(ctx, len - 1);
- if (instance->isArray)
+ if (instance->isArrayObject())
instance->array.setLengthUnchecked(len - 1);
else
instance->__put__(ctx, ctx->engine->id_length, Value::fromDouble(len - 1));
instance->__put__(ctx, idx.toString(ctx), ctx->argument(i));
}
double newLen = l + ctx->argumentCount;
- if (!instance->isArray)
+ if (!instance->isArrayObject())
instance->__put__(ctx, ctx->engine->id_length, Value::fromDouble(newLen));
else
ctx->throwRangeError(Value::fromString(ctx, QStringLiteral("Array.prototype.push: Overflow")));
instance->__put__(ctx, len + i, ctx->argument(i));
}
uint newLen = len + ctx->argumentCount;
- if (!instance->isArray)
+ if (!instance->isArrayObject())
instance->__put__(ctx, ctx->engine->id_length, Value::fromDouble(newLen));
if (newLen < INT_MAX)
uint len = getLength(ctx, instance);
if (!len) {
- if (!instance->isArray)
+ if (!instance->isArrayObject())
instance->__put__(ctx, ctx->engine->id_length, Value::fromInt32(0));
return Value::undefinedValue();
}
instance->__delete__(ctx, len - 1);
}
- if (!instance->isArray)
+ if (!instance->isArrayObject())
instance->__put__(ctx, ctx->engine->id_length, Value::fromDouble(len - 1));
return result;
}
instance->__put__(ctx, i, ctx->argument(i));
}
uint newLen = len + ctx->argumentCount;
- if (!instance->isArray)
+ if (!instance->isArrayObject())
instance->__put__(ctx, ctx->engine->id_length, Value::fromDouble(newLen));
if (newLen < INT_MAX)
fromIndex = (uint) f;
}
- if (instance->isString) {
+ if (instance->isStringObject()) {
for (uint k = fromIndex; k < len; ++k) {
bool exists;
Value v = instance->__get__(ctx, k, &exists);
Object *o = ctx->argument(1).asObject();
if (o) {
stringify.replacerFunction = o->asFunctionObject();
- if (o->isArray) {
+ if (o->isArrayObject()) {
for (uint i = 0; i < o->array.length(); ++i) {
Value v = o->__get__(ctx, i);
if (v.asNumberObject() || v.asStringObject() || v.isNumber())
protected:
Managed() : markBit(0), inUse(1), extensible(true),
- isArray(false), isArgumentsObject(false), isString(false), isBuiltinFunction(false), type(Type_Object), unused(0) { }
+ isNonStrictArgumentsObject(false), isBuiltinFunction(false), type(Type_Object), unused(0) { }
virtual ~Managed();
public:
ArgumentsObject *asArgumentsObject() { return type == Type_ArgumentsObject ? reinterpret_cast<ArgumentsObject *>(this) : 0; }
ForeachIteratorObject *asForeachIteratorObject() { return type == Type_ForeachIteratorObject ? reinterpret_cast<ForeachIteratorObject *>(this) : 0; }
+ bool isArrayObject() const { return type == Type_ArrayObject; }
+ bool isStringObject() const { return type == Type_StringObject; }
+
protected:
virtual void markObjects() = 0;
quintptr markBit : 1;
quintptr inUse : 1;
quintptr extensible : 1; // used by Object
- quintptr isArray : 1; // used by Object & Array
- quintptr isArgumentsObject : 1;
- quintptr isString : 1; // used by Object & StringObject
+ quintptr isNonStrictArgumentsObject : 1;
quintptr isBuiltinFunction : 1; // used by FunctionObject
quintptr needsActivation : 1; // used by FunctionObject
quintptr usesArgumentsObject : 1; // used by FunctionObject
quintptr strictMode : 1; // used by FunctionObject
quintptr type : 4;
#if CPU(X86_64)
- quintptr unused : 50;
+ quintptr unused : 51;
#elif CPU(X86)
- quintptr unused : 18;
+ quintptr unused : 19;
#else
#error "implement me"
#endif
PropertyDescriptor *p = array.at(index);
if(p && p->type != PropertyDescriptor::Generic)
return p;
- if (isString)
+ if (isStringObject())
return static_cast<StringObject *>(this)->getIndex(ctx, index);
return 0;
PropertyDescriptor *p = o->array.at(index);
if(p && p->type != PropertyDescriptor::Generic)
return p;
- if (o->isString) {
+ if (o->isStringObject()) {
p = static_cast<StringObject *>(o)->getIndex(ctx, index);
if (p)
return p;
goto reject;
} else if (!pd->isWritable())
goto reject;
- else if (isArray && name->isEqualTo(ctx->engine->id_length)) {
+ else if (isArrayObject() && name->isEqualTo(ctx->engine->id_length)) {
bool ok;
uint l = value.asArrayLength(ctx, &ok);
if (!ok)
PropertyDescriptor *current;
- if (isArray && name->isEqualTo(ctx->engine->id_length)) {
+ if (isArrayObject() && name->isEqualTo(ctx->engine->id_length)) {
PropertyDescriptor *lp = array.getLengthProperty();
if (desc->isEmpty() || desc->isSubset(lp))
return true;
PropertyDescriptor *current;
// 15.4.5.1, 4b
- if (isArray && index >= array.length() && !array.getLengthProperty()->isWritable())
+ if (isArrayObject() && index >= array.length() && !array.getLengthProperty()->isWritable())
goto reject;
- if (isArgumentsObject)
+ if (isNonStrictArgumentsObject)
return static_cast<ArgumentsObject *>(this)->defineOwnProperty(ctx, index, desc);
// Clause 1
void ArrayObject::init(ExecutionContext *context)
{
type = Type_ArrayObject;
- isArray = true;
if (!members)
members.reset(new PropertyTable());
: value(value)
{
type = Type_StringObject;
- isString = true;
tmpProperty.type = PropertyDescriptor::Data;
tmpProperty.enumberable = PropertyDescriptor::Enabled;