Move the StringValue members of ExecutionEngine onto the JS stack

Change-Id: Ib55c05f1730b7659e2f6fee7e1fa79c10c759167
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
This commit is contained in:
Lars Knoll 2015-04-26 09:22:17 +02:00 committed by Simon Hausmann
parent 58e712a9dd
commit 864988474a
31 changed files with 270 additions and 265 deletions

View File

@ -1028,7 +1028,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const
if (!o)
return QJSValue();
QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax) : o->getIndexed(arrayIndex));
QV4::ScopedValue result(scope, arrayIndex == UINT_MAX ? o->get(engine->id_uintMax()) : o->getIndexed(arrayIndex));
if (engine->hasException)
engine->catchException();
return QJSValue(engine, result->asReturnedValue());
@ -1107,7 +1107,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value)
if (arrayIndex != UINT_MAX)
o->putIndexed(arrayIndex, v);
else
o->put(engine->id_uintMax, v);
o->put(engine->id_uintMax(), v);
if (engine->hasException)
engine->catchException();
}

View File

@ -54,8 +54,8 @@ Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context)
args->setArrayType(Heap::ArrayData::Complex);
if (context->d()->strictMode) {
Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee));
Q_ASSERT(CallerPropertyIndex == args->internalClass()->find(context->d()->engine->id_caller));
Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee()));
Q_ASSERT(CallerPropertyIndex == args->internalClass()->find(context->d()->engine->id_caller()));
args->propertyAt(CalleePropertyIndex)->value = v4->thrower();
args->propertyAt(CalleePropertyIndex)->set = v4->thrower();
args->propertyAt(CallerPropertyIndex)->value = v4->thrower();
@ -65,10 +65,10 @@ Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context)
args->arrayPut(0, context->args(), context->argc());
args->d()->fullyCreated = true;
} else {
Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee));
Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee()));
args->memberData()->data[CalleePropertyIndex] = context->d()->function->asReturnedValue();
}
Q_ASSERT(LengthPropertyIndex == args->internalClass()->find(context->d()->engine->id_length));
Q_ASSERT(LengthPropertyIndex == args->internalClass()->find(context->d()->engine->id_length()));
args->memberData()->data[LengthPropertyIndex] = Primitive::fromInt32(context->d()->callData->argc);
}

View File

@ -139,10 +139,10 @@ void ArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineDefaultProperty(QStringLiteral("isView"), ArrayBufferCtor::method_isView, 1);
defineDefaultProperty(engine->id_constructor, (o = ctor));
defineDefaultProperty(engine->id_constructor(), (o = ctor));
defineAccessorProperty(QStringLiteral("byteLength"), method_get_byteLength, 0);
defineDefaultProperty(QStringLiteral("slice"), method_slice, 2);
}
@ -173,7 +173,7 @@ ReturnedValue ArrayBufferPrototype::method_slice(CallContext *ctx)
double first = (start < 0) ? qMax(a->d()->data->size + start, 0.) : qMin(start, (double)a->d()->data->size);
double final = (end < 0) ? qMax(a->d()->data->size + end, 0.) : qMin(end, (double)a->d()->data->size);
ScopedFunctionObject constructor(scope, a->get(scope.engine->id_constructor));
ScopedFunctionObject constructor(scope, a->get(scope.engine->id_constructor()));
if (!constructor)
return scope.engine->throwTypeError();

View File

@ -82,11 +82,11 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineDefaultProperty(QStringLiteral("isArray"), method_isArray, 1);
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString, method_toString, 0);
defineDefaultProperty(engine->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);
defineDefaultProperty(QStringLiteral("join"), method_join, 1);
@ -186,7 +186,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx)
r4 = arg->toQString();
ScopedObject self(scope, ctx->thisObject());
ScopedValue length(scope, self->get(ctx->d()->engine->id_length));
ScopedValue length(scope, self->get(ctx->d()->engine->id_length()));
const quint32 r2 = length->isUndefined() ? 0 : length->toUInt32();
if (!r2)
@ -243,7 +243,7 @@ ReturnedValue ArrayPrototype::method_pop(CallContext *ctx)
if (!len) {
if (!instance->isArrayObject())
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0)));
instance->put(ctx->d()->engine->id_length(), ScopedValue(scope, Primitive::fromInt32(0)));
return Encode::undefined();
}
@ -257,7 +257,7 @@ ReturnedValue ArrayPrototype::method_pop(CallContext *ctx)
if (instance->isArrayObject())
instance->setArrayLength(len - 1);
else
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1)));
instance->put(ctx->d()->engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - 1)));
return result->asReturnedValue();
}
@ -283,7 +283,7 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx)
}
double newLen = l + ctx->argc();
if (!instance->isArrayObject())
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen)));
instance->put(ctx->d()->engine->id_length(), ScopedValue(scope, Primitive::fromDouble(newLen)));
else {
ScopedString str(scope, ctx->d()->engine->newString(QStringLiteral("Array.prototype.push: Overflow")));
return ctx->engine()->throwRangeError(str);
@ -304,7 +304,7 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx)
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len);
else
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len)));
instance->put(ctx->d()->engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len)));
return Encode(len);
}
@ -355,7 +355,7 @@ ReturnedValue ArrayPrototype::method_shift(CallContext *ctx)
if (!len) {
if (!instance->isArrayObject())
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0)));
instance->put(ctx->d()->engine->id_length(), ScopedValue(scope, Primitive::fromInt32(0)));
return Encode::undefined();
}
@ -389,7 +389,7 @@ ReturnedValue ArrayPrototype::method_shift(CallContext *ctx)
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(len - 1);
else
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1)));
instance->put(ctx->d()->engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - 1)));
return result->asReturnedValue();
}
@ -524,7 +524,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx)
}
ctx->d()->strictMode = true;
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount)));
instance->put(ctx->d()->engine->id_length(), ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount)));
return newArray.asReturnedValue();
}
@ -562,7 +562,7 @@ ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx)
if (instance->isArrayObject())
instance->setArrayLengthUnchecked(newLen);
else
instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen)));
instance->put(ctx->d()->engine->id_length(), ScopedValue(scope, Primitive::fromDouble(newLen)));
return Encode(newLen);
}

View File

@ -61,11 +61,11 @@ void BooleanPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString, method_toString);
defineDefaultProperty(engine->id_valueOf, method_valueOf);
defineDefaultProperty(engine->id_toString(), method_toString);
defineDefaultProperty(engine->id_valueOf(), method_valueOf);
}
ReturnedValue BooleanPrototype::method_toString(CallContext *ctx)

View File

@ -328,7 +328,7 @@ void ExecutionContext::setProperty(String *name, const Value &value)
}
}
}
if (d()->strictMode || name->equals(d()->engine->id_this)) {
if (d()->strictMode || name->equals(d()->engine->id_this())) {
ScopedValue n(scope, name->asReturnedValue());
engine()->throwReferenceError(n);
return;
@ -342,7 +342,7 @@ ReturnedValue ExecutionContext::getProperty(String *name)
ScopedValue v(scope);
name->makeIdentifier(scope.engine);
if (name->equals(d()->engine->id_this))
if (name->equals(d()->engine->id_this()))
return thisObject().asReturnedValue();
bool hasWith = false;
@ -409,7 +409,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Heap::Object **
*base = (Heap::Object *)0;
name->makeIdentifier(scope.engine);
if (name->equals(d()->engine->id_this))
if (name->equals(d()->engine->id_this()))
return thisObject().asReturnedValue();
bool hasWith = false;

View File

@ -95,9 +95,9 @@ void DataViewPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(3));
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
defineDefaultProperty(engine->id_constructor, (o = ctor));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(3));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineDefaultProperty(engine->id_constructor(), (o = ctor));
defineAccessorProperty(QStringLiteral("buffer"), method_get_buffer, 0);
defineAccessorProperty(QStringLiteral("byteLength"), method_get_byteLength, 0);
defineAccessorProperty(QStringLiteral("byteOffset"), method_get_byteOffset, 0);

View File

@ -695,8 +695,8 @@ void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(7));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(7));
LocalTZA = getLocalTZA();
ctor->defineDefaultProperty(QStringLiteral("parse"), method_parse, 1);
@ -704,13 +704,13 @@ void DatePrototype::init(ExecutionEngine *engine, Object *ctor)
ctor->defineDefaultProperty(QStringLiteral("now"), method_now, 0);
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString, method_toString, 0);
defineDefaultProperty(engine->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("toDateString"), method_toDateString, 0);
defineDefaultProperty(QStringLiteral("toTimeString"), method_toTimeString, 0);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
defineDefaultProperty(QStringLiteral("toLocaleDateString"), method_toLocaleDateString, 0);
defineDefaultProperty(QStringLiteral("toLocaleTimeString"), method_toLocaleTimeString, 0);
defineDefaultProperty(engine->id_valueOf, method_valueOf, 0);
defineDefaultProperty(engine->id_valueOf(), method_valueOf, 0);
defineDefaultProperty(QStringLiteral("getTime"), method_getTime, 0);
defineDefaultProperty(QStringLiteral("getYear"), method_getYear, 0);
defineDefaultProperty(QStringLiteral("getFullYear"), method_getFullYear, 0);

View File

@ -239,6 +239,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
jsObjects = jsAlloca(NJSObjects);
typedArrayPrototype = static_cast<Object *>(jsAlloca(NTypedArrayTypes));
typedArrayCtors = static_cast<FunctionObject *>(jsAlloca(NTypedArrayTypes));
jsStrings = jsAlloca(NJSStrings);
#ifdef V4_USE_VALGRIND
VALGRIND_MAKE_MEM_UNDEFINED(jsStackBase, 2*JSStackLimit);
@ -256,52 +257,52 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
emptyClass = new (classPool) InternalClass(this);
id_empty = newIdentifier(QString());
id_undefined = newIdentifier(QStringLiteral("undefined"));
id_null = newIdentifier(QStringLiteral("null"));
id_true = newIdentifier(QStringLiteral("true"));
id_false = newIdentifier(QStringLiteral("false"));
id_boolean = newIdentifier(QStringLiteral("boolean"));
id_number = newIdentifier(QStringLiteral("number"));
id_string = newIdentifier(QStringLiteral("string"));
id_object = newIdentifier(QStringLiteral("object"));
id_function = newIdentifier(QStringLiteral("function"));
id_length = newIdentifier(QStringLiteral("length"));
id_prototype = newIdentifier(QStringLiteral("prototype"));
id_constructor = newIdentifier(QStringLiteral("constructor"));
id_arguments = newIdentifier(QStringLiteral("arguments"));
id_caller = newIdentifier(QStringLiteral("caller"));
id_callee = newIdentifier(QStringLiteral("callee"));
id_this = newIdentifier(QStringLiteral("this"));
id___proto__ = newIdentifier(QStringLiteral("__proto__"));
id_enumerable = newIdentifier(QStringLiteral("enumerable"));
id_configurable = newIdentifier(QStringLiteral("configurable"));
id_writable = newIdentifier(QStringLiteral("writable"));
id_value = newIdentifier(QStringLiteral("value"));
id_get = newIdentifier(QStringLiteral("get"));
id_set = newIdentifier(QStringLiteral("set"));
id_eval = newIdentifier(QStringLiteral("eval"));
id_uintMax = newIdentifier(QStringLiteral("4294967295"));
id_name = newIdentifier(QStringLiteral("name"));
id_index = newIdentifier(QStringLiteral("index"));
id_input = newIdentifier(QStringLiteral("input"));
id_toString = newIdentifier(QStringLiteral("toString"));
id_destroy = newIdentifier(QStringLiteral("destroy"));
id_valueOf = newIdentifier(QStringLiteral("valueOf"));
id_byteLength = newIdentifier(QStringLiteral("byteLength"));
id_byteOffset = newIdentifier(QStringLiteral("byteOffset"));
id_buffer = newIdentifier(QStringLiteral("buffer"));
id_lastIndex = newIdentifier(QStringLiteral("lastIndex"));
jsStrings[String_Empty] = newIdentifier(QString());
jsStrings[String_undefined] = newIdentifier(QStringLiteral("undefined"));
jsStrings[String_null] = newIdentifier(QStringLiteral("null"));
jsStrings[String_true] = newIdentifier(QStringLiteral("true"));
jsStrings[String_false] = newIdentifier(QStringLiteral("false"));
jsStrings[String_boolean] = newIdentifier(QStringLiteral("boolean"));
jsStrings[String_number] = newIdentifier(QStringLiteral("number"));
jsStrings[String_string] = newIdentifier(QStringLiteral("string"));
jsStrings[String_object] = newIdentifier(QStringLiteral("object"));
jsStrings[String_function] = newIdentifier(QStringLiteral("function"));
jsStrings[String_length] = newIdentifier(QStringLiteral("length"));
jsStrings[String_prototype] = newIdentifier(QStringLiteral("prototype"));
jsStrings[String_constructor] = newIdentifier(QStringLiteral("constructor"));
jsStrings[String_arguments] = newIdentifier(QStringLiteral("arguments"));
jsStrings[String_caller] = newIdentifier(QStringLiteral("caller"));
jsStrings[String_callee] = newIdentifier(QStringLiteral("callee"));
jsStrings[String_this] = newIdentifier(QStringLiteral("this"));
jsStrings[String___proto__] = newIdentifier(QStringLiteral("__proto__"));
jsStrings[String_enumerable] = newIdentifier(QStringLiteral("enumerable"));
jsStrings[String_configurable] = newIdentifier(QStringLiteral("configurable"));
jsStrings[String_writable] = newIdentifier(QStringLiteral("writable"));
jsStrings[String_value] = newIdentifier(QStringLiteral("value"));
jsStrings[String_get] = newIdentifier(QStringLiteral("get"));
jsStrings[String_set] = newIdentifier(QStringLiteral("set"));
jsStrings[String_eval] = newIdentifier(QStringLiteral("eval"));
jsStrings[String_uintMax] = newIdentifier(QStringLiteral("4294967295"));
jsStrings[String_name] = newIdentifier(QStringLiteral("name"));
jsStrings[String_index] = newIdentifier(QStringLiteral("index"));
jsStrings[String_input] = newIdentifier(QStringLiteral("input"));
jsStrings[String_toString] = newIdentifier(QStringLiteral("toString"));
jsStrings[String_destroy] = newIdentifier(QStringLiteral("destroy"));
jsStrings[String_valueOf] = newIdentifier(QStringLiteral("valueOf"));
jsStrings[String_byteLength] = newIdentifier(QStringLiteral("byteLength"));
jsStrings[String_byteOffset] = newIdentifier(QStringLiteral("byteOffset"));
jsStrings[String_buffer] = newIdentifier(QStringLiteral("buffer"));
jsStrings[String_lastIndex] = newIdentifier(QStringLiteral("lastIndex"));
jsObjects[ObjectProto] = memoryManager->alloc<ObjectPrototype>(emptyClass, (QV4::Object *)0);
arrayClass = emptyClass->addMember(id_length, Attr_NotConfigurable|Attr_NotEnumerable);
arrayClass = emptyClass->addMember(id_length(), Attr_NotConfigurable|Attr_NotEnumerable);
jsObjects[ArrayProto] = memoryManager->alloc<ArrayPrototype>(arrayClass, objectPrototype());
InternalClass *argsClass = emptyClass->addMember(id_length, Attr_NotEnumerable);
argumentsObjectClass = argsClass->addMember(id_callee, Attr_Data|Attr_NotEnumerable);
strictArgumentsObjectClass = argsClass->addMember(id_callee, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
strictArgumentsObjectClass = strictArgumentsObjectClass->addMember(id_caller, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
InternalClass *argsClass = emptyClass->addMember(id_length(), Attr_NotEnumerable);
argumentsObjectClass = argsClass->addMember(id_callee(), Attr_Data|Attr_NotEnumerable);
strictArgumentsObjectClass = argsClass->addMember(id_callee(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
strictArgumentsObjectClass = strictArgumentsObjectClass->addMember(id_caller(), Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
*static_cast<Value *>(globalObject) = newObject();
Q_ASSERT(globalObject->d()->vtable);
@ -313,22 +314,22 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
jsObjects[DateProto] = memoryManager->alloc<DatePrototype>(emptyClass, objectPrototype());
uint index;
InternalClass *functionProtoClass = emptyClass->addMember(id_prototype, Attr_NotEnumerable, &index);
InternalClass *functionProtoClass = emptyClass->addMember(id_prototype(), Attr_NotEnumerable, &index);
Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
jsObjects[FunctionProto] = memoryManager->alloc<FunctionPrototype>(functionProtoClass, objectPrototype());
functionClass = emptyClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
functionClass = emptyClass->addMember(id_prototype(), Attr_NotEnumerable|Attr_NotConfigurable, &index);
Q_ASSERT(index == Heap::FunctionObject::Index_Prototype);
simpleScriptFunctionClass = functionClass->addMember(id_name, Attr_ReadOnly, &index);
simpleScriptFunctionClass = functionClass->addMember(id_name(), Attr_ReadOnly, &index);
Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Name);
simpleScriptFunctionClass = simpleScriptFunctionClass->addMember(id_length, Attr_ReadOnly, &index);
simpleScriptFunctionClass = simpleScriptFunctionClass->addMember(id_length(), Attr_ReadOnly, &index);
Q_ASSERT(index == Heap::SimpleScriptFunction::Index_Length);
protoClass = emptyClass->addMember(id_constructor, Attr_NotEnumerable, &index);
protoClass = emptyClass->addMember(id_constructor(), Attr_NotEnumerable, &index);
Q_ASSERT(index == Heap::FunctionObject::Index_ProtoConstructor);
jsObjects[RegExpProto] = memoryManager->alloc<RegExpPrototype>(this);
regExpExecArrayClass = arrayClass->addMember(id_index, Attr_Data, &index);
regExpExecArrayClass = arrayClass->addMember(id_index(), Attr_Data, &index);
Q_ASSERT(index == RegExpObject::Index_ArrayIndex);
regExpExecArrayClass = regExpExecArrayClass->addMember(id_input, Attr_Data, &index);
regExpExecArrayClass = regExpExecArrayClass->addMember(id_input(), Attr_Data, &index);
Q_ASSERT(index == RegExpObject::Index_ArrayInput);
jsObjects[ErrorProto] = memoryManager->alloc<ErrorPrototype>(emptyClass, objectPrototype());
@ -905,43 +906,6 @@ void ExecutionEngine::markObjects()
c = c->parent;
}
id_empty->mark(this);
id_undefined->mark(this);
id_null->mark(this);
id_true->mark(this);
id_false->mark(this);
id_boolean->mark(this);
id_number->mark(this);
id_string->mark(this);
id_object->mark(this);
id_function->mark(this);
id_length->mark(this);
id_prototype->mark(this);
id_constructor->mark(this);
id_arguments->mark(this);
id_caller->mark(this);
id_callee->mark(this);
id_this->mark(this);
id___proto__->mark(this);
id_enumerable->mark(this);
id_configurable->mark(this);
id_writable->mark(this);
id_value->mark(this);
id_get->mark(this);
id_set->mark(this);
id_eval->mark(this);
id_uintMax->mark(this);
id_name->mark(this);
id_index->mark(this);
id_input->mark(this);
id_toString->mark(this);
id_destroy->mark(this);
id_valueOf->mark(this);
id_byteLength->mark(this);
id_byteOffset->mark(this);
id_buffer->mark(this);
id_lastIndex->mark(this);
for (int i = 0; i < Heap::TypedArray::NTypes; ++i)
typedArrayCtors[i].mark(this);

View File

@ -235,42 +235,83 @@ public:
Property *argumentsAccessors;
int nArgumentsAccessors;
StringValue id_empty;
StringValue id_undefined;
StringValue id_null;
StringValue id_true;
StringValue id_false;
StringValue id_boolean;
StringValue id_number;
StringValue id_string;
StringValue id_object;
StringValue id_function;
StringValue id_length;
StringValue id_prototype;
StringValue id_constructor;
StringValue id_arguments;
StringValue id_caller;
StringValue id_callee;
StringValue id_this;
StringValue id___proto__;
StringValue id_enumerable;
StringValue id_configurable;
StringValue id_writable;
StringValue id_value;
StringValue id_get;
StringValue id_set;
StringValue id_eval;
StringValue id_uintMax;
StringValue id_name;
StringValue id_index;
StringValue id_input;
StringValue id_toString;
StringValue id_destroy;
StringValue id_valueOf;
StringValue id_byteLength;
StringValue id_byteOffset;
StringValue id_buffer;
StringValue id_lastIndex;
enum JSStrings {
String_Empty,
String_undefined,
String_null,
String_true,
String_false,
String_boolean,
String_number,
String_string,
String_object,
String_function,
String_length,
String_prototype,
String_constructor,
String_arguments,
String_caller,
String_callee,
String_this,
String___proto__,
String_enumerable,
String_configurable,
String_writable,
String_value,
String_get,
String_set,
String_eval,
String_uintMax,
String_name,
String_index,
String_input,
String_toString,
String_destroy,
String_valueOf,
String_byteLength,
String_byteOffset,
String_buffer,
String_lastIndex,
NJSStrings
};
Value *jsStrings;
String *id_empty() const { return reinterpret_cast<String *>(jsStrings + String_Empty); }
String *id_undefined() const { return reinterpret_cast<String *>(jsStrings + String_undefined); }
String *id_null() const { return reinterpret_cast<String *>(jsStrings + String_null); }
String *id_true() const { return reinterpret_cast<String *>(jsStrings + String_true); }
String *id_false() const { return reinterpret_cast<String *>(jsStrings + String_false); }
String *id_boolean() const { return reinterpret_cast<String *>(jsStrings + String_boolean); }
String *id_number() const { return reinterpret_cast<String *>(jsStrings + String_number); }
String *id_string() const { return reinterpret_cast<String *>(jsStrings + String_string); }
String *id_object() const { return reinterpret_cast<String *>(jsStrings + String_object); }
String *id_function() const { return reinterpret_cast<String *>(jsStrings + String_function); }
String *id_length() const { return reinterpret_cast<String *>(jsStrings + String_length); }
String *id_prototype() const { return reinterpret_cast<String *>(jsStrings + String_prototype); }
String *id_constructor() const { return reinterpret_cast<String *>(jsStrings + String_constructor); }
String *id_arguments() const { return reinterpret_cast<String *>(jsStrings + String_arguments); }
String *id_caller() const { return reinterpret_cast<String *>(jsStrings + String_caller); }
String *id_callee() const { return reinterpret_cast<String *>(jsStrings + String_callee); }
String *id_this() const { return reinterpret_cast<String *>(jsStrings + String_this); }
String *id___proto__() const { return reinterpret_cast<String *>(jsStrings + String___proto__); }
String *id_enumerable() const { return reinterpret_cast<String *>(jsStrings + String_enumerable); }
String *id_configurable() const { return reinterpret_cast<String *>(jsStrings + String_configurable); }
String *id_writable() const { return reinterpret_cast<String *>(jsStrings + String_writable); }
String *id_value() const { return reinterpret_cast<String *>(jsStrings + String_value); }
String *id_get() const { return reinterpret_cast<String *>(jsStrings + String_get); }
String *id_set() const { return reinterpret_cast<String *>(jsStrings + String_set); }
String *id_eval() const { return reinterpret_cast<String *>(jsStrings + String_eval); }
String *id_uintMax() const { return reinterpret_cast<String *>(jsStrings + String_uintMax); }
String *id_name() const { return reinterpret_cast<String *>(jsStrings + String_name); }
String *id_index() const { return reinterpret_cast<String *>(jsStrings + String_index); }
String *id_input() const { return reinterpret_cast<String *>(jsStrings + String_input); }
String *id_toString() const { return reinterpret_cast<String *>(jsStrings + String_toString); }
String *id_destroy() const { return reinterpret_cast<String *>(jsStrings + String_destroy); }
String *id_valueOf() const { return reinterpret_cast<String *>(jsStrings + String_valueOf); }
String *id_byteLength() const { return reinterpret_cast<String *>(jsStrings + String_byteLength); }
String *id_byteOffset() const { return reinterpret_cast<String *>(jsStrings + String_byteOffset); }
String *id_buffer() const { return reinterpret_cast<String *>(jsStrings + String_buffer); }
String *id_lastIndex() const { return reinterpret_cast<String *>(jsStrings + String_lastIndex); }
QSet<CompiledData::CompilationUnit*> compilationUnits;

View File

@ -343,10 +343,10 @@ void ErrorPrototype::init(ExecutionEngine *engine, Object *ctor, Object *obj)
Scope scope(engine);
ScopedString s(scope);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype, (o = obj));
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = obj));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
obj->defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
obj->defineDefaultProperty(engine->id_toString, method_toString, 0);
obj->defineDefaultProperty(engine->id_toString(), method_toString, 0);
obj->defineDefaultProperty(QStringLiteral("message"), (s = engine->newString()));
}
@ -358,7 +358,7 @@ ReturnedValue ErrorPrototype::method_toString(CallContext *ctx)
if (!o)
return ctx->engine()->throwTypeError();
ScopedValue name(scope, o->get(ctx->d()->engine->id_name));
ScopedValue name(scope, o->get(ctx->d()->engine->id_name()));
QString qname;
if (name->isUndefined())
qname = QString::fromLatin1("Error");

View File

@ -161,12 +161,12 @@ void FunctionObject::init(String *n, bool createProto)
}
ScopedValue v(s, n);
defineReadonlyProperty(s.engine->id_name, v);
defineReadonlyProperty(s.engine->id_name(), v);
}
ReturnedValue FunctionObject::name() const
{
return get(scope()->engine->id_name);
return get(scope()->engine->id_name());
}
@ -303,12 +303,12 @@ void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
defineReadonlyProperty(engine->id_length, Primitive::fromInt32(0));
defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(0));
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString, method_toString, 0);
defineDefaultProperty(engine->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("apply"), method_apply, 2);
defineDefaultProperty(QStringLiteral("call"), method_call, 1);
defineDefaultProperty(QStringLiteral("bind"), method_bind, 1);
@ -480,7 +480,7 @@ Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, F
if (createProto) {
ScopedString name(s, function->name());
f->init(name, createProto);
f->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(f->formalParameterCount()));
f->defineReadonlyProperty(scope->d()->engine->id_length(), Primitive::fromInt32(f->formalParameterCount()));
} else {
f->ensureMemberIndex(s.engine, Index_Length);
memberData->data[Index_Name] = function->name();
@ -491,8 +491,8 @@ Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, F
ScopedProperty pd(s);
pd->value = s.engine->thrower();
pd->set = s.engine->thrower();
f->insertMember(scope->d()->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
f->insertMember(scope->d()->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
f->insertMember(scope->d()->engine->id_caller(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
f->insertMember(scope->d()->engine->id_arguments(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
}
@ -649,19 +649,19 @@ Heap::BoundFunction::BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionOb
Scope s(scope);
ScopedObject f(s, this);
ScopedValue l(s, target->get(s.engine->id_length));
ScopedValue l(s, target->get(s.engine->id_length()));
int len = l->toUInt32();
if (boundArgs)
len -= boundArgs->size();
if (len < 0)
len = 0;
f->defineReadonlyProperty(s.engine->id_length, Primitive::fromInt32(len));
f->defineReadonlyProperty(s.engine->id_length(), Primitive::fromInt32(len));
ScopedProperty pd(s);
pd->value = s.engine->thrower();
pd->set = s.engine->thrower();
f->insertMember(s.engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
f->insertMember(s.engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
f->insertMember(s.engine->id_arguments(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
f->insertMember(s.engine->id_caller(), pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
}
ReturnedValue BoundFunction::call(const Managed *that, CallData *dd)

View File

@ -340,11 +340,11 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
DEFINE_OBJECT_VTABLE(EvalFunction);
Heap::EvalFunction::EvalFunction(QV4::ExecutionContext *scope)
: Heap::FunctionObject(scope, scope->d()->engine->id_eval)
: Heap::FunctionObject(scope, scope->d()->engine->id_eval())
{
Scope s(scope);
ScopedFunctionObject f(s, this);
f->defineReadonlyProperty(s.engine->id_length, Primitive::fromInt32(1));
f->defineReadonlyProperty(s.engine->id_length(), Primitive::fromInt32(1));
}
ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const

View File

@ -252,7 +252,7 @@ ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Va
proto = engine->stringPrototype();
Scope scope(engine);
ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
if (name->equals(engine->id_length)) {
if (name->equals(engine->id_length())) {
// special case, as the property is on the object itself
l->getter = stringLengthGetter;
return stringLengthGetter(l, engine, object);

View File

@ -68,8 +68,8 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
ctor->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qSNaN()));
ctor->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Primitive::fromDouble(-qInf()));
@ -86,9 +86,9 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor)
#endif
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString, method_toString);
defineDefaultProperty(engine->id_toString(), method_toString);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString);
defineDefaultProperty(engine->id_valueOf, method_valueOf);
defineDefaultProperty(engine->id_valueOf(), method_valueOf);
defineDefaultProperty(QStringLiteral("toFixed"), method_toFixed, 1);
defineDefaultProperty(QStringLiteral("toExponential"), method_toExponential);
defineDefaultProperty(QStringLiteral("toPrecision"), method_toPrecision);

View File

@ -139,7 +139,7 @@ void Object::defineDefaultProperty(const QString &name, ReturnedValue (*code)(Ca
ScopedString s(scope, e->newIdentifier(name));
ScopedContext global(scope, e->rootContext());
ScopedFunctionObject function(scope, BuiltinFunction::create(global, s, code));
function->defineReadonlyProperty(e->id_length, Primitive::fromInt32(argumentCount));
function->defineReadonlyProperty(e->id_length(), Primitive::fromInt32(argumentCount));
defineDefaultProperty(s, function);
}
@ -149,7 +149,7 @@ void Object::defineDefaultProperty(String *name, ReturnedValue (*code)(CallConte
Scope scope(e);
ScopedContext global(scope, e->rootContext());
ScopedFunctionObject function(scope, BuiltinFunction::create(global, name, code));
function->defineReadonlyProperty(e->id_length, Primitive::fromInt32(argumentCount));
function->defineReadonlyProperty(e->id_length(), Primitive::fromInt32(argumentCount));
defineDefaultProperty(name, function);
}
@ -675,7 +675,7 @@ void Object::internalPut(String *name, const Value &value)
goto reject;
} else if (!attrs.isWritable())
goto reject;
else if (isArrayObject() && name->equals(engine()->id_length)) {
else if (isArrayObject() && name->equals(engine()->id_length())) {
bool ok;
uint l = value.asArrayLength(&ok);
if (!ok) {
@ -859,8 +859,8 @@ bool Object::__defineOwnProperty__(ExecutionEngine *engine, String *name, const
PropertyAttributes *cattrs;
uint memberIndex;
if (isArrayObject() && name->equals(engine->id_length)) {
Q_ASSERT(Heap::ArrayObject::LengthPropertyIndex == internalClass()->find(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))
@ -1098,7 +1098,7 @@ void Object::copyArrayData(Object *other)
uint Object::getLength(const Managed *m)
{
Scope scope(static_cast<const Object *>(m)->engine());
ScopedValue v(scope, static_cast<Object *>(const_cast<Managed *>(m))->get(scope.engine->id_length));
ScopedValue v(scope, static_cast<Object *>(const_cast<Managed *>(m))->get(scope.engine->id_length()));
return v->toUInt32();
}
@ -1160,7 +1160,7 @@ ReturnedValue ArrayObject::getLookup(const Managed *m, Lookup *l)
{
Scope scope(static_cast<const Object *>(m)->engine());
ScopedString name(scope, scope.engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
if (name->equals(scope.engine->id_length)) {
if (name->equals(scope.engine->id_length())) {
// special case, as the property is on the object itself
l->getter = Lookup::arrayLengthGetter;
const ArrayObject *a = static_cast<const ArrayObject *>(m);

View File

@ -60,7 +60,7 @@ ReturnedValue ObjectCtor::construct(const Managed *that, CallData *callData)
Scope scope(v4);
if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull()) {
ScopedObject obj(scope, v4->newObject());
ScopedObject proto(scope, ctor->get(v4->id_prototype));
ScopedObject proto(scope, ctor->get(v4->id_prototype()));
if (!!proto)
obj->setPrototype(proto);
return obj.asReturnedValue();
@ -82,8 +82,8 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
Scope scope(v4);
ScopedObject o(scope, this);
ctor->defineReadonlyProperty(v4->id_prototype, o);
ctor->defineReadonlyProperty(v4->id_length, Primitive::fromInt32(1));
ctor->defineReadonlyProperty(v4->id_prototype(), o);
ctor->defineReadonlyProperty(v4->id_length(), Primitive::fromInt32(1));
ctor->defineDefaultProperty(QStringLiteral("getPrototypeOf"), method_getPrototypeOf, 1);
ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyDescriptor"), method_getOwnPropertyDescriptor, 2);
ctor->defineDefaultProperty(QStringLiteral("getOwnPropertyNames"), method_getOwnPropertyNames, 1);
@ -99,9 +99,9 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
ctor->defineDefaultProperty(QStringLiteral("keys"), method_keys, 1);
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(v4->id_toString, method_toString, 0);
defineDefaultProperty(v4->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0);
defineDefaultProperty(v4->id_valueOf, method_valueOf, 0);
defineDefaultProperty(v4->id_valueOf(), method_valueOf, 0);
defineDefaultProperty(QStringLiteral("hasOwnProperty"), method_hasOwnProperty, 1);
defineDefaultProperty(QStringLiteral("isPrototypeOf"), method_isPrototypeOf, 1);
defineDefaultProperty(QStringLiteral("propertyIsEnumerable"), method_propertyIsEnumerable, 1);
@ -110,9 +110,9 @@ void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor)
ScopedContext global(scope, scope.engine->rootContext());
ScopedProperty p(scope);
p->value = BuiltinFunction::create(global, v4->id___proto__, method_get_proto);
p->set = BuiltinFunction::create(global, v4->id___proto__, method_set_proto);
insertMember(v4->id___proto__, p, Attr_Accessor|Attr_NotEnumerable);
p->value = BuiltinFunction::create(global, v4->id___proto__(), method_get_proto);
p->set = BuiltinFunction::create(global, v4->id___proto__(), method_set_proto);
insertMember(v4->id___proto__(), p, Attr_Accessor|Attr_NotEnumerable);
}
ReturnedValue ObjectPrototype::method_getPrototypeOf(CallContext *ctx)
@ -401,7 +401,7 @@ ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx)
ScopedObject o(scope, ctx->thisObject().toObject(scope.engine));
if (!o)
return Encode::undefined();
ScopedFunctionObject f(scope, o->get(ctx->d()->engine->id_toString));
ScopedFunctionObject f(scope, o->get(ctx->d()->engine->id_toString()));
if (!f)
return ctx->engine()->throwTypeError();
ScopedCallData callData(scope);
@ -573,14 +573,14 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
desc->set = Primitive::emptyValue();
ScopedValue tmp(scope);
if (o->hasProperty(engine->id_enumerable))
attrs->setEnumerable((tmp = o->get(engine->id_enumerable))->toBoolean());
if (o->hasProperty(engine->id_enumerable()))
attrs->setEnumerable((tmp = o->get(engine->id_enumerable()))->toBoolean());
if (o->hasProperty(engine->id_configurable))
attrs->setConfigurable((tmp = o->get(engine->id_configurable))->toBoolean());
if (o->hasProperty(engine->id_configurable()))
attrs->setConfigurable((tmp = o->get(engine->id_configurable()))->toBoolean());
if (o->hasProperty(engine->id_get)) {
ScopedValue get(scope, o->get(engine->id_get));
if (o->hasProperty(engine->id_get())) {
ScopedValue get(scope, o->get(engine->id_get()));
FunctionObject *f = get->as<FunctionObject>();
if (f || get->isUndefined()) {
desc->value = get;
@ -591,8 +591,8 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
attrs->setType(PropertyAttributes::Accessor);
}
if (o->hasProperty(engine->id_set)) {
ScopedValue set(scope, o->get(engine->id_set));
if (o->hasProperty(engine->id_set())) {
ScopedValue set(scope, o->get(engine->id_set()));
FunctionObject *f = set->as<FunctionObject>();
if (f || set->isUndefined()) {
desc->set = set;
@ -603,22 +603,22 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value
attrs->setType(PropertyAttributes::Accessor);
}
if (o->hasProperty(engine->id_writable)) {
if (o->hasProperty(engine->id_writable())) {
if (attrs->isAccessor()) {
engine->throwTypeError();
return;
}
attrs->setWritable((tmp = o->get(engine->id_writable))->toBoolean());
attrs->setWritable((tmp = o->get(engine->id_writable()))->toBoolean());
// writable forces it to be a data descriptor
desc->value = Primitive::undefinedValue();
}
if (o->hasProperty(engine->id_value)) {
if (o->hasProperty(engine->id_value())) {
if (attrs->isAccessor()) {
engine->throwTypeError();
return;
}
desc->value = o->get(engine->id_value);
desc->value = o->get(engine->id_value());
attrs->setType(PropertyAttributes::Data);
}

View File

@ -272,8 +272,8 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String
QV4::Scope scope(engine());
QV4::ScopedString name(scope, n);
if (name->equals(scope.engine->id_destroy) || name->equals(scope.engine->id_toString)) {
int index = name->equals(scope.engine->id_destroy) ? QV4::QObjectMethod::DestroyMethod : QV4::QObjectMethod::ToStringMethod;
if (name->equals(scope.engine->id_destroy()) || name->equals(scope.engine->id_toString())) {
int index = name->equals(scope.engine->id_destroy()) ? QV4::QObjectMethod::DestroyMethod : QV4::QObjectMethod::ToStringMethod;
ScopedContext global(scope, scope.engine->rootContext());
QV4::ScopedValue method(scope, QV4::QObjectMethod::create(global, d()->object, index));
if (hasProperty)
@ -727,7 +727,7 @@ PropertyAttributes QObjectWrapper::query(const Managed *m, String *name)
QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(engine);
QQmlPropertyData local;
if (that->findProperty(engine, qmlContext, name, IgnoreRevision, &local)
|| name->equals(engine->id_destroy) || name->equals(engine->id_toString))
|| name->equals(engine->id_destroy()) || name->equals(engine->id_toString()))
return QV4::Attr_Data;
else
return QV4::Object::query(m, name);

View File

@ -174,7 +174,7 @@ void RegExpObject::markObjects(Heap::Base *that, ExecutionEngine *e)
Property *RegExpObject::lastIndexProperty()
{
Q_ASSERT(0 == internalClass()->find(engine()->id_lastIndex));
Q_ASSERT(0 == internalClass()->find(engine()->id_lastIndex()));
return propertyAt(0);
}
@ -231,7 +231,7 @@ Heap::RegExpCtor::RegExpCtor(QV4::ExecutionContext *scope)
void Heap::RegExpCtor::clearLastMatch()
{
lastMatch = Primitive::nullValue();
lastInput = internalClass->engine->id_empty->d();
lastInput = internalClass->engine->id_empty()->d();
lastMatchStart = 0;
lastMatchEnd = 0;
}
@ -310,8 +310,8 @@ void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor)
ScopedObject o(scope);
ScopedObject ctor(scope, constructor);
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(2));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(2));
// Properties deprecated in the spec but required by "the web" :(
ctor->defineAccessorProperty(QStringLiteral("lastMatch"), method_get_lastMatch_n<0>, 0);
@ -337,7 +337,7 @@ void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor)
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(QStringLiteral("exec"), method_exec, 1);
defineDefaultProperty(QStringLiteral("test"), method_test, 1);
defineDefaultProperty(engine->id_toString, method_toString, 0);
defineDefaultProperty(engine->id_toString(), method_toString, 0);
defineDefaultProperty(QStringLiteral("compile"), method_compile, 2);
}

View File

@ -394,8 +394,8 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH
if (engine->hasException)
return Encode::undefined();
StringValue *meth1 = &engine->id_toString;
StringValue *meth2 = &engine->id_valueOf;
String *meth1 = engine->id_toString();
String *meth2 = engine->id_valueOf();
if (typeHint == NUMBER_HINT)
qSwap(meth1, meth2);
@ -404,7 +404,7 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH
ScopedCallData callData(scope, 0);
callData->thisObject = *object;
ScopedValue conv(scope, object->get(*meth1));
ScopedValue conv(scope, object->get(meth1));
if (FunctionObject *o = conv->as<FunctionObject>()) {
ScopedValue r(scope, o->call(callData));
if (r->isPrimitive())
@ -414,7 +414,7 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH
if (engine->hasException)
return Encode::undefined();
conv = object->get(*meth2);
conv = object->get(meth2);
if (FunctionObject *o = conv->as<FunctionObject>()) {
ScopedValue r(scope, o->call(callData));
if (r->isPrimitive())
@ -451,14 +451,14 @@ Heap::String *RuntimeHelpers::convertToString(ExecutionEngine *engine, const Val
case Value::Empty_Type:
Q_ASSERT(!"empty Value encountered");
case Value::Undefined_Type:
return engine->id_undefined->d();
return engine->id_undefined()->d();
case Value::Null_Type:
return engine->id_null->d();
return engine->id_null()->d();
case Value::Boolean_Type:
if (value.booleanValue())
return engine->id_true->d();
return engine->id_true()->d();
else
return engine->id_false->d();
return engine->id_false()->d();
case Value::Managed_Type:
if (value.isString())
return value.stringValue()->d();
@ -482,14 +482,14 @@ static Heap::String *convert_to_string_add(ExecutionEngine *engine, const Value
case Value::Empty_Type:
Q_ASSERT(!"empty Value encountered");
case Value::Undefined_Type:
return engine->id_undefined->d();
return engine->id_undefined()->d();
case Value::Null_Type:
return engine->id_null->d();
return engine->id_null()->d();
case Value::Boolean_Type:
if (value.booleanValue())
return engine->id_true->d();
return engine->id_true()->d();
else
return engine->id_false->d();
return engine->id_false()->d();
case Value::Managed_Type:
if (value.isString())
return value.stringValue()->d();
@ -910,7 +910,7 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionEngine *engine, uint index, Cal
return engine->throwTypeError();
ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
if (o->d() == scope.engine->evalFunction()->d() && name->equals(scope.engine->id_eval))
if (o->d() == scope.engine->evalFunction()->d() && name->equals(scope.engine->id_eval()))
return static_cast<EvalFunction *>(o.getPointer())->evalCall(callData, true);
return o->call(callData);
@ -941,7 +941,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameI
return engine->throwTypeError(msg);
}
if (o->d() == scope.engine->evalFunction()->d() && name->equals(scope.engine->id_eval)) {
if (o->d() == scope.engine->evalFunction()->d() && name->equals(scope.engine->id_eval())) {
return static_cast<EvalFunction *>(o)->evalCall(callData, true);
}
@ -1090,24 +1090,24 @@ ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const Value &value)
ScopedString res(scope);
switch (value.type()) {
case Value::Undefined_Type:
res = engine->id_undefined;
res = engine->id_undefined();
break;
case Value::Null_Type:
res = engine->id_object;
res = engine->id_object();
break;
case Value::Boolean_Type:
res = engine->id_boolean;
res = engine->id_boolean();
break;
case Value::Managed_Type:
if (value.isString())
res = engine->id_string;
res = engine->id_string();
else if (value.objectValue()->as<FunctionObject>())
res = engine->id_function;
res = engine->id_function();
else
res = engine->id_object; // ### implementation-defined
res = engine->id_object(); // ### implementation-defined
break;
default:
res = engine->id_number;
res = engine->id_number();
break;
}
return res.asReturnedValue();

View File

@ -87,7 +87,7 @@ DEFINE_OBJECT_VTABLE(QmlBindingWrapper);
DEFINE_OBJECT_VTABLE(CompilationUnitHolder);
Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, Function *f, QV4::Object *qml)
: Heap::FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false)
: Heap::FunctionObject(scope, scope->d()->engine->id_eval(), /*createProto = */ false)
, qml(qml->d())
{
Q_ASSERT(scope->inUse());
@ -99,7 +99,7 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, Functio
Scope s(scope);
Scoped<QV4::QmlBindingWrapper> o(s, this);
o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
o->defineReadonlyProperty(scope->d()->engine->id_length(), Primitive::fromInt32(1));
ScopedContext ctx(s, s.engine->currentContext());
o->d()->qmlContext = ctx->newQmlContext(o, qml);
@ -107,7 +107,7 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, Functio
}
Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Object *qml)
: Heap::FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false)
: Heap::FunctionObject(scope, scope->d()->engine->id_eval(), /*createProto = */ false)
, qml(qml->d())
{
Q_ASSERT(scope->inUse());
@ -115,7 +115,7 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Ob
Scope s(scope);
Scoped<QV4::QmlBindingWrapper> o(s, this);
o->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
o->defineReadonlyProperty(scope->d()->engine->id_length(), Primitive::fromInt32(1));
ScopedContext ctx(s, s.engine->currentContext());
o->d()->qmlContext = ctx->newQmlContext(o, qml);

View File

@ -605,7 +605,7 @@ void SequencePrototype::init()
{
FOREACH_QML_SEQUENCE_TYPE(REGISTER_QML_SEQUENCE_METATYPE)
defineDefaultProperty(QStringLiteral("sort"), method_sort, 1);
defineDefaultProperty(engine()->id_valueOf, method_valueOf, 0);
defineDefaultProperty(engine()->id_valueOf(), method_valueOf, 0);
}
#undef REGISTER_QML_SEQUENCE_METATYPE

View File

@ -234,7 +234,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine
} else if (const Object *o = v.as<Object>()) {
if (o->isListType()) {
// valid sequence. we generate a length (sequence length + 1 for the sequence type)
uint seqLength = ScopedValue(scope, o->get(engine->id_length))->toUInt32();
uint seqLength = ScopedValue(scope, o->get(engine->id_length()))->toUInt32();
uint length = seqLength + 1;
if (length > 0xFFFFFF) {
push(data, valueheader(WorkerUndefined));

View File

@ -76,7 +76,7 @@ Heap::StringObject::StringObject(InternalClass *ic, QV4::Object *prototype)
Scope scope(ic->engine);
ScopedObject s(scope, this);
s->defineReadonlyProperty(ic->engine->id_length, Primitive::fromInt32(0));
s->defineReadonlyProperty(ic->engine->id_length(), Primitive::fromInt32(0));
}
Heap::StringObject::StringObject(ExecutionEngine *engine, const Value &val)
@ -88,7 +88,7 @@ Heap::StringObject::StringObject(ExecutionEngine *engine, const Value &val)
Scope scope(engine);
ScopedObject s(scope, this);
s->defineReadonlyProperty(engine->id_length, Primitive::fromUInt32(value.stringValue()->toQString().length()));
s->defineReadonlyProperty(engine->id_length(), Primitive::fromUInt32(value.stringValue()->toQString().length()));
}
Property *Heap::StringObject::getIndex(uint index) const
@ -187,13 +187,13 @@ void StringPrototype::init(ExecutionEngine *engine, Object *ctor)
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(1));
ctor->defineDefaultProperty(QStringLiteral("fromCharCode"), method_fromCharCode, 1);
defineDefaultProperty(QStringLiteral("constructor"), (o = ctor));
defineDefaultProperty(engine->id_toString, method_toString);
defineDefaultProperty(engine->id_valueOf, method_toString); // valueOf and toString are identical
defineDefaultProperty(engine->id_toString(), method_toString);
defineDefaultProperty(engine->id_valueOf(), method_toString); // valueOf and toString are identical
defineDefaultProperty(QStringLiteral("charAt"), method_charAt, 1);
defineDefaultProperty(QStringLiteral("charCodeAt"), method_charCodeAt, 1);
defineDefaultProperty(QStringLiteral("concat"), method_concat, 1);

View File

@ -300,7 +300,7 @@ ReturnedValue TypedArrayCtor::construct(const Managed *m, CallData *callData)
// ECMA 6 22.2.1.3
ScopedObject o(scope, callData->argument(0));
uint l = (uint) qBound(0., ScopedValue(scope, o->get(scope.engine->id_length))->toInteger(), (double)UINT_MAX);
uint l = (uint) qBound(0., ScopedValue(scope, o->get(scope.engine->id_length()))->toInteger(), (double)UINT_MAX);
if (scope.engine->hasException)
return scope.engine->throwTypeError();
@ -391,10 +391,10 @@ void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor)
{
Scope scope(engine);
ScopedObject o(scope);
ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(3));
ctor->defineReadonlyProperty(engine->id_prototype, (o = this));
ctor->defineReadonlyProperty(engine->id_length(), Primitive::fromInt32(3));
ctor->defineReadonlyProperty(engine->id_prototype(), (o = this));
ctor->defineReadonlyProperty(QStringLiteral("BYTES_PER_ELEMENT"), Primitive::fromInt32(operations[ctor->d()->type].bytesPerElement));
defineDefaultProperty(engine->id_constructor, (o = ctor));
defineDefaultProperty(engine->id_constructor(), (o = ctor));
defineAccessorProperty(QStringLiteral("buffer"), method_get_buffer, 0);
defineAccessorProperty(QStringLiteral("byteLength"), method_get_byteLength, 0);
defineAccessorProperty(QStringLiteral("byteOffset"), method_get_byteOffset, 0);
@ -471,7 +471,7 @@ ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx)
if (scope.engine->hasException || !o)
return scope.engine->throwTypeError();
double len = ScopedValue(scope, o->get(scope.engine->id_length))->toNumber();
double len = ScopedValue(scope, o->get(scope.engine->id_length()))->toNumber();
uint l = (uint)len;
if (scope.engine->hasException || l != len)
return scope.engine->throwTypeError();
@ -564,7 +564,7 @@ ReturnedValue TypedArrayPrototype::method_subarray(CallContext *ctx)
int newLen = end - begin;
ScopedFunctionObject constructor(scope, a->get(scope.engine->id_constructor));
ScopedFunctionObject constructor(scope, a->get(scope.engine->id_constructor()));
if (!constructor)
return scope.engine->throwTypeError();

View File

@ -96,8 +96,8 @@ void VariantPrototype::init()
{
defineDefaultProperty(QStringLiteral("preserve"), method_preserve, 0);
defineDefaultProperty(QStringLiteral("destroy"), method_destroy, 0);
defineDefaultProperty(engine()->id_valueOf, method_valueOf, 0);
defineDefaultProperty(engine()->id_toString, method_toString, 0);
defineDefaultProperty(engine()->id_valueOf(), method_valueOf, 0);
defineDefaultProperty(engine()->id_toString(), method_toString, 0);
}
QV4::ReturnedValue VariantPrototype::method_preserve(CallContext *ctx)

View File

@ -98,7 +98,7 @@ ReturnedValue QmlListWrapper::get(const Managed *m, String *name, bool *hasPrope
const QmlListWrapper *w = static_cast<const QmlListWrapper *>(m);
QV4::ExecutionEngine *v4 = w->engine();
if (name->equals(v4->id_length) && !w->d()->object.isNull()) {
if (name->equals(v4->id_length()) && !w->d()->object.isNull()) {
quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
return Primitive::fromUInt32(count).asReturnedValue();
}

View File

@ -170,7 +170,7 @@ void QQmlValueTypeWrapper::initProto(ExecutionEngine *v4)
Scope scope(v4);
ScopedObject o(scope, v4->newObject());
o->defineDefaultProperty(v4->id_toString, method_toString, 1);
o->defineDefaultProperty(v4->id_toString(), method_toString, 1);
v4->qmlExtensions()->valueTypeWrapperPrototype = o->d();
}

View File

@ -895,7 +895,7 @@ ReturnedValue NamedNodeMap::get(const Managed *m, String *name, bool *hasPropert
QV4::ExecutionEngine *v4 = r->engine();
name->makeIdentifier(v4);
if (name->equals(v4->id_length))
if (name->equals(v4->id_length()))
return Primitive::fromInt32(r->d()->list.count()).asReturnedValue();
QString str = name->toQString();
@ -941,7 +941,7 @@ ReturnedValue NodeList::get(const Managed *m, String *name, bool *hasProperty)
name->makeIdentifier(v4);
if (name->equals(v4->id_length))
if (name->equals(v4->id_length()))
return Primitive::fromInt32(r->d()->d->children.count()).asReturnedValue();
return Object::get(m, name, hasProperty);
}
@ -1702,7 +1702,7 @@ Heap::QQmlXMLHttpRequestCtor::QQmlXMLHttpRequestCtor(ExecutionEngine *engine)
ctor->defineReadonlyProperty(QStringLiteral("DONE"), Primitive::fromInt32(4));
if (!ctor->d()->proto)
ctor->setupProto();
ScopedString s(scope, engine->id_prototype);
ScopedString s(scope, engine->id_prototype());
ctor->defineDefaultProperty(s, ScopedObject(scope, ctor->d()->proto));
}

View File

@ -3311,7 +3311,7 @@ public:
Q_ASSERT(m->as<QQmlDelegateModelGroupChangeArray>());
const QQmlDelegateModelGroupChangeArray *array = static_cast<const QQmlDelegateModelGroupChangeArray *>(m);
if (name->equals(array->engine()->id_length)) {
if (name->equals(array->engine()->id_length())) {
if (hasProperty)
*hasProperty = true;
return QV4::Encode(array->count());

View File

@ -4235,7 +4235,7 @@ QQuickContext2DEngineData::QQuickContext2DEngineData(QV4::ExecutionEngine *v4)
gradientProto = proto;
proto = scope.engine->newObject();
proto->defineAccessorProperty(scope.engine->id_length, QQuickJSContext2DPixelData::proto_get_length, 0);
proto->defineAccessorProperty(scope.engine->id_length(), QQuickJSContext2DPixelData::proto_get_length, 0);
pixelArrayProto = proto;
}