Convert remaining FunctionObject's to new constructor scheme
Change-Id: I440d5b128d0ee28566ebfa82c2505a4bd97bba6b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
parent
00fa904911
commit
dba56a752c
|
@ -51,6 +51,12 @@ namespace QV4 {
|
||||||
struct ArgumentsGetterFunction: FunctionObject
|
struct ArgumentsGetterFunction: FunctionObject
|
||||||
{
|
{
|
||||||
struct Data : FunctionObject::Data {
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope, uint index)
|
||||||
|
: FunctionObject::Data(scope)
|
||||||
|
, index(index)
|
||||||
|
{
|
||||||
|
setVTable(staticVTable());
|
||||||
|
}
|
||||||
uint index;
|
uint index;
|
||||||
};
|
};
|
||||||
struct {
|
struct {
|
||||||
|
@ -60,19 +66,18 @@ struct ArgumentsGetterFunction: FunctionObject
|
||||||
|
|
||||||
uint index() const { return d()->index; }
|
uint index() const { return d()->index; }
|
||||||
|
|
||||||
ArgumentsGetterFunction(ExecutionContext *scope, uint index)
|
|
||||||
: FunctionObject(scope)
|
|
||||||
{
|
|
||||||
d()->index = index;
|
|
||||||
setVTable(staticVTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
static ReturnedValue call(Managed *that, CallData *d);
|
static ReturnedValue call(Managed *that, CallData *d);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ArgumentsSetterFunction: FunctionObject
|
struct ArgumentsSetterFunction: FunctionObject
|
||||||
{
|
{
|
||||||
struct Data : FunctionObject::Data {
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope, uint index)
|
||||||
|
: FunctionObject::Data(scope)
|
||||||
|
, index(index)
|
||||||
|
{
|
||||||
|
setVTable(staticVTable());
|
||||||
|
}
|
||||||
uint index;
|
uint index;
|
||||||
};
|
};
|
||||||
struct {
|
struct {
|
||||||
|
@ -82,13 +87,6 @@ struct ArgumentsSetterFunction: FunctionObject
|
||||||
|
|
||||||
uint index() const { return d()->index; }
|
uint index() const { return d()->index; }
|
||||||
|
|
||||||
ArgumentsSetterFunction(ExecutionContext *scope, uint index)
|
|
||||||
: FunctionObject(scope)
|
|
||||||
{
|
|
||||||
d()->index = index;
|
|
||||||
setVTable(staticVTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
static ReturnedValue call(Managed *that, CallData *callData);
|
static ReturnedValue call(Managed *that, CallData *callData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,8 @@ using namespace QV4;
|
||||||
|
|
||||||
DEFINE_OBJECT_VTABLE(ArrayCtor);
|
DEFINE_OBJECT_VTABLE(ArrayCtor);
|
||||||
|
|
||||||
ArrayCtor::ArrayCtor(ExecutionContext *scope)
|
ArrayCtor::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("Array"))
|
: FunctionObject::Data(scope, QStringLiteral("Array"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,11 @@ namespace QV4 {
|
||||||
|
|
||||||
struct ArrayCtor: FunctionObject
|
struct ArrayCtor: FunctionObject
|
||||||
{
|
{
|
||||||
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
|
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
ArrayCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
static ReturnedValue call(Managed *that, CallData *callData);
|
static ReturnedValue call(Managed *that, CallData *callData);
|
||||||
|
|
|
@ -46,8 +46,8 @@ using namespace QV4;
|
||||||
DEFINE_OBJECT_VTABLE(BooleanCtor);
|
DEFINE_OBJECT_VTABLE(BooleanCtor);
|
||||||
DEFINE_OBJECT_VTABLE(BooleanObject);
|
DEFINE_OBJECT_VTABLE(BooleanObject);
|
||||||
|
|
||||||
BooleanCtor::BooleanCtor(ExecutionContext *scope)
|
BooleanCtor::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("Boolean"))
|
: FunctionObject::Data(scope, QStringLiteral("Boolean"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,11 @@ namespace QV4 {
|
||||||
|
|
||||||
struct BooleanCtor: FunctionObject
|
struct BooleanCtor: FunctionObject
|
||||||
{
|
{
|
||||||
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
|
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
BooleanCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *, CallData *callData);
|
static ReturnedValue construct(Managed *, CallData *callData);
|
||||||
static ReturnedValue call(Managed *that, CallData *callData);
|
static ReturnedValue call(Managed *that, CallData *callData);
|
||||||
|
|
|
@ -657,8 +657,8 @@ QDateTime DateObject::toQDateTime() const
|
||||||
|
|
||||||
DEFINE_OBJECT_VTABLE(DateCtor);
|
DEFINE_OBJECT_VTABLE(DateCtor);
|
||||||
|
|
||||||
DateCtor::DateCtor(ExecutionContext *scope)
|
DateCtor::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("Date"))
|
: FunctionObject::Data(scope, QStringLiteral("Date"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,8 +84,10 @@ protected:
|
||||||
|
|
||||||
struct DateCtor: FunctionObject
|
struct DateCtor: FunctionObject
|
||||||
{
|
{
|
||||||
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
DateCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *, CallData *callData);
|
static ReturnedValue construct(Managed *, CallData *callData);
|
||||||
static ReturnedValue call(Managed *that, CallData *);
|
static ReturnedValue call(Managed *that, CallData *);
|
||||||
|
|
|
@ -295,7 +295,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
|
||||||
uint index;
|
uint index;
|
||||||
functionProtoClass = functionProtoClass->addMember(id_prototype, Attr_NotEnumerable, &index);
|
functionProtoClass = functionProtoClass->addMember(id_prototype, Attr_NotEnumerable, &index);
|
||||||
Q_ASSERT(index == FunctionObject::Index_Prototype);
|
Q_ASSERT(index == FunctionObject::Index_Prototype);
|
||||||
FunctionPrototype *functionPrototype = new (memoryManager) FunctionPrototype(functionProtoClass);
|
Scoped<FunctionPrototype> functionPrototype(scope, new (this) FunctionPrototype::Data(functionProtoClass));
|
||||||
functionClass = InternalClass::create(this, FunctionObject::staticVTable(), functionPrototype);
|
functionClass = InternalClass::create(this, FunctionObject::staticVTable(), functionPrototype);
|
||||||
functionClass = functionClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
|
functionClass = functionClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
|
||||||
Q_ASSERT(index == FunctionObject::Index_Prototype);
|
Q_ASSERT(index == FunctionObject::Index_Prototype);
|
||||||
|
@ -331,21 +331,21 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
|
||||||
|
|
||||||
sequencePrototype = new (memoryManager) SequencePrototype(arrayClass);
|
sequencePrototype = new (memoryManager) SequencePrototype(arrayClass);
|
||||||
|
|
||||||
objectCtor = new (memoryManager) ObjectCtor(rootContext);
|
objectCtor = static_cast<HeapObject *>(new (this) ObjectCtor::Data(rootContext));
|
||||||
stringCtor = new (memoryManager) StringCtor(rootContext);
|
stringCtor = static_cast<HeapObject *>(new (this) StringCtor::Data(rootContext));
|
||||||
numberCtor = new (memoryManager) NumberCtor(rootContext);
|
numberCtor = static_cast<HeapObject *>(new (this) NumberCtor::Data(rootContext));
|
||||||
booleanCtor = new (memoryManager) BooleanCtor(rootContext);
|
booleanCtor = static_cast<HeapObject *>(new (this) BooleanCtor::Data(rootContext));
|
||||||
arrayCtor = new (memoryManager) ArrayCtor(rootContext);
|
arrayCtor = static_cast<HeapObject *>(new (this) ArrayCtor::Data(rootContext));
|
||||||
functionCtor = static_cast<HeapObject *>(new (this) FunctionCtor::Data(rootContext));
|
functionCtor = static_cast<HeapObject *>(new (this) FunctionCtor::Data(rootContext));
|
||||||
dateCtor = new (memoryManager) DateCtor(rootContext);
|
dateCtor = static_cast<HeapObject *>(new (this) DateCtor::Data(rootContext));
|
||||||
regExpCtor = new (memoryManager) RegExpCtor(rootContext);
|
regExpCtor = static_cast<HeapObject *>(new (this) RegExpCtor::Data(rootContext));
|
||||||
errorCtor = new (memoryManager) ErrorCtor(rootContext);
|
errorCtor = static_cast<HeapObject *>(new (this) ErrorCtor::Data(rootContext));
|
||||||
evalErrorCtor = new (memoryManager) EvalErrorCtor(rootContext);
|
evalErrorCtor = static_cast<HeapObject *>(new (this) EvalErrorCtor::Data(rootContext));
|
||||||
rangeErrorCtor = new (memoryManager) RangeErrorCtor(rootContext);
|
rangeErrorCtor = static_cast<HeapObject *>(new (this) RangeErrorCtor::Data(rootContext));
|
||||||
referenceErrorCtor = new (memoryManager) ReferenceErrorCtor(rootContext);
|
referenceErrorCtor = static_cast<HeapObject *>(new (this) ReferenceErrorCtor::Data(rootContext));
|
||||||
syntaxErrorCtor = new (memoryManager) SyntaxErrorCtor(rootContext);
|
syntaxErrorCtor = static_cast<HeapObject *>(new (this) SyntaxErrorCtor::Data(rootContext));
|
||||||
typeErrorCtor = new (memoryManager) TypeErrorCtor(rootContext);
|
typeErrorCtor = static_cast<HeapObject *>(new (this) TypeErrorCtor::Data(rootContext));
|
||||||
uRIErrorCtor = new (memoryManager) URIErrorCtor(rootContext);
|
uRIErrorCtor = static_cast<HeapObject *>(new (this) URIErrorCtor::Data(rootContext));
|
||||||
|
|
||||||
objectPrototype->init(this, objectCtor.asObject());
|
objectPrototype->init(this, objectCtor.asObject());
|
||||||
stringPrototype->init(this, stringCtor.asObject());
|
stringPrototype->init(this, stringCtor.asObject());
|
||||||
|
@ -397,7 +397,8 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
|
||||||
globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(std::numeric_limits<double>::quiet_NaN()));
|
globalObject->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(std::numeric_limits<double>::quiet_NaN()));
|
||||||
globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Primitive::fromDouble(Q_INFINITY));
|
globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Primitive::fromDouble(Q_INFINITY));
|
||||||
|
|
||||||
evalFunction = new (memoryManager) EvalFunction(rootContext);
|
|
||||||
|
evalFunction = Scoped<EvalFunction>(scope, new (this) EvalFunction::Data(rootContext));
|
||||||
globalObject->defineDefaultProperty(QStringLiteral("eval"), (o = evalFunction));
|
globalObject->defineDefaultProperty(QStringLiteral("eval"), (o = evalFunction));
|
||||||
|
|
||||||
globalObject->defineDefaultProperty(QStringLiteral("parseInt"), GlobalFunctions::method_parseInt, 2);
|
globalObject->defineDefaultProperty(QStringLiteral("parseInt"), GlobalFunctions::method_parseInt, 2);
|
||||||
|
@ -807,8 +808,8 @@ void ExecutionEngine::requireArgumentsAccessors(int n)
|
||||||
delete [] oldAccessors;
|
delete [] oldAccessors;
|
||||||
}
|
}
|
||||||
for (int i = oldSize; i < nArgumentsAccessors; ++i) {
|
for (int i = oldSize; i < nArgumentsAccessors; ++i) {
|
||||||
argumentsAccessors[i].value = Value::fromManaged(new (memoryManager) ArgumentsGetterFunction(rootContext, i));
|
argumentsAccessors[i].value = ScopedValue(scope, new (scope.engine) ArgumentsGetterFunction::Data(rootContext, i));
|
||||||
argumentsAccessors[i].set = Value::fromManaged(new (memoryManager) ArgumentsSetterFunction(rootContext, i));
|
argumentsAccessors[i].set = ScopedValue(scope, new (scope.engine) ArgumentsSetterFunction::Data(rootContext, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,14 +253,14 @@ DEFINE_OBJECT_VTABLE(SyntaxErrorCtor);
|
||||||
DEFINE_OBJECT_VTABLE(TypeErrorCtor);
|
DEFINE_OBJECT_VTABLE(TypeErrorCtor);
|
||||||
DEFINE_OBJECT_VTABLE(URIErrorCtor);
|
DEFINE_OBJECT_VTABLE(URIErrorCtor);
|
||||||
|
|
||||||
ErrorCtor::ErrorCtor(ExecutionContext *scope)
|
ErrorCtor::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("Error"))
|
: FunctionObject::Data(scope, QStringLiteral("Error"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCtor::ErrorCtor(ExecutionContext *scope, const QString &name)
|
ErrorCtor::Data::Data(ExecutionContext *scope, const QString &name)
|
||||||
: FunctionObject(scope, name)
|
: FunctionObject::Data(scope, name)
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
@ -277,8 +277,8 @@ ReturnedValue ErrorCtor::call(Managed *that, CallData *callData)
|
||||||
return static_cast<Object *>(that)->construct(callData);
|
return static_cast<Object *>(that)->construct(callData);
|
||||||
}
|
}
|
||||||
|
|
||||||
EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope)
|
EvalErrorCtor::Data::Data(ExecutionContext *scope)
|
||||||
: ErrorCtor(scope, QStringLiteral("EvalError"))
|
: ErrorCtor::Data(scope, QStringLiteral("EvalError"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
@ -290,8 +290,8 @@ ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData)
|
||||||
return (new (m->engine()->memoryManager) EvalErrorObject(m->engine(), v))->asReturnedValue();
|
return (new (m->engine()->memoryManager) EvalErrorObject(m->engine(), v))->asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope)
|
RangeErrorCtor::Data::Data(ExecutionContext *scope)
|
||||||
: ErrorCtor(scope, QStringLiteral("RangeError"))
|
: ErrorCtor::Data(scope, QStringLiteral("RangeError"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
@ -303,8 +303,8 @@ ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData)
|
||||||
return (new (m->engine()->memoryManager) RangeErrorObject(scope.engine, v))->asReturnedValue();
|
return (new (m->engine()->memoryManager) RangeErrorObject(scope.engine, v))->asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope)
|
ReferenceErrorCtor::Data::Data(ExecutionContext *scope)
|
||||||
: ErrorCtor(scope, QStringLiteral("ReferenceError"))
|
: ErrorCtor::Data(scope, QStringLiteral("ReferenceError"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
@ -316,8 +316,8 @@ ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData)
|
||||||
return (new (m->engine()->memoryManager) ReferenceErrorObject(scope.engine, v))->asReturnedValue();
|
return (new (m->engine()->memoryManager) ReferenceErrorObject(scope.engine, v))->asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope)
|
SyntaxErrorCtor::Data::Data(ExecutionContext *scope)
|
||||||
: ErrorCtor(scope, QStringLiteral("SyntaxError"))
|
: ErrorCtor::Data(scope, QStringLiteral("SyntaxError"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
@ -329,8 +329,8 @@ ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData)
|
||||||
return (new (m->engine()->memoryManager) SyntaxErrorObject(scope.engine, v))->asReturnedValue();
|
return (new (m->engine()->memoryManager) SyntaxErrorObject(scope.engine, v))->asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope)
|
TypeErrorCtor::Data::Data(ExecutionContext *scope)
|
||||||
: ErrorCtor(scope, QStringLiteral("TypeError"))
|
: ErrorCtor::Data(scope, QStringLiteral("TypeError"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
@ -342,8 +342,8 @@ ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData)
|
||||||
return (new (m->engine()->memoryManager) TypeErrorObject(scope.engine, v))->asReturnedValue();
|
return (new (m->engine()->memoryManager) TypeErrorObject(scope.engine, v))->asReturnedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
URIErrorCtor::URIErrorCtor(ExecutionContext *scope)
|
URIErrorCtor::Data::Data(ExecutionContext *scope)
|
||||||
: ErrorCtor(scope, QStringLiteral("URIError"))
|
: ErrorCtor::Data(scope, QStringLiteral("URIError"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,9 +125,12 @@ struct URIErrorObject: ErrorObject {
|
||||||
|
|
||||||
struct ErrorCtor: FunctionObject
|
struct ErrorCtor: FunctionObject
|
||||||
{
|
{
|
||||||
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
Data(ExecutionContext *scope, const QString &name);
|
||||||
|
};
|
||||||
|
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
ErrorCtor(ExecutionContext *scope);
|
|
||||||
ErrorCtor(ExecutionContext *scope, const QString &name);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *, CallData *callData);
|
static ReturnedValue construct(Managed *, CallData *callData);
|
||||||
static ReturnedValue call(Managed *that, CallData *callData);
|
static ReturnedValue call(Managed *that, CallData *callData);
|
||||||
|
@ -135,49 +138,60 @@ struct ErrorCtor: FunctionObject
|
||||||
|
|
||||||
struct EvalErrorCtor: ErrorCtor
|
struct EvalErrorCtor: ErrorCtor
|
||||||
{
|
{
|
||||||
|
struct Data : ErrorCtor::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
|
|
||||||
EvalErrorCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RangeErrorCtor: ErrorCtor
|
struct RangeErrorCtor: ErrorCtor
|
||||||
{
|
{
|
||||||
|
struct Data : ErrorCtor::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
RangeErrorCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ReferenceErrorCtor: ErrorCtor
|
struct ReferenceErrorCtor: ErrorCtor
|
||||||
{
|
{
|
||||||
|
struct Data : ErrorCtor::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
ReferenceErrorCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SyntaxErrorCtor: ErrorCtor
|
struct SyntaxErrorCtor: ErrorCtor
|
||||||
{
|
{
|
||||||
|
struct Data : ErrorCtor::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
SyntaxErrorCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TypeErrorCtor: ErrorCtor
|
struct TypeErrorCtor: ErrorCtor
|
||||||
{
|
{
|
||||||
|
struct Data : ErrorCtor::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
TypeErrorCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct URIErrorCtor: ErrorCtor
|
struct URIErrorCtor: ErrorCtor
|
||||||
{
|
{
|
||||||
|
struct Data : ErrorCtor::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
URIErrorCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,48 +112,6 @@ FunctionObject::Data::Data(InternalClass *ic)
|
||||||
memberData[Index_Prototype] = Encode::undefined();
|
memberData[Index_Prototype] = Encode::undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionObject::FunctionObject(ExecutionContext *scope, String *name, bool createProto)
|
|
||||||
: Object(scope->d()->engine->functionClass)
|
|
||||||
{
|
|
||||||
d()->scope = scope;
|
|
||||||
d()->function = 0;
|
|
||||||
init(name, createProto);
|
|
||||||
}
|
|
||||||
|
|
||||||
FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto)
|
|
||||||
: Object(scope->d()->engine->functionClass)
|
|
||||||
{
|
|
||||||
d()->scope = scope;
|
|
||||||
d()->function = 0;
|
|
||||||
|
|
||||||
Scope s(scope);
|
|
||||||
ScopedValue protectThis(s, this);
|
|
||||||
ScopedString n(s, s.engine->newString(name));
|
|
||||||
init(n.getPointer(), createProto);
|
|
||||||
}
|
|
||||||
|
|
||||||
FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name)
|
|
||||||
: Object(scope->d()->engine->functionClass)
|
|
||||||
{
|
|
||||||
d()->scope = scope;
|
|
||||||
d()->function = 0;
|
|
||||||
|
|
||||||
Scope s(scope);
|
|
||||||
ScopedValue protectThis(s, this);
|
|
||||||
ScopedString n(s, name);
|
|
||||||
init(n.getPointer(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
FunctionObject::FunctionObject(InternalClass *ic)
|
|
||||||
: Object(ic)
|
|
||||||
{
|
|
||||||
d()->scope = ic->engine->rootContext;
|
|
||||||
d()->function = 0;
|
|
||||||
|
|
||||||
d()->needsActivation = false;
|
|
||||||
d()->strictMode = false;
|
|
||||||
memberData()[Index_Prototype] = Encode::undefined();
|
|
||||||
}
|
|
||||||
|
|
||||||
FunctionObject::Data::~Data()
|
FunctionObject::Data::~Data()
|
||||||
{
|
{
|
||||||
|
@ -288,8 +246,10 @@ ReturnedValue FunctionCtor::call(Managed *that, CallData *callData)
|
||||||
return construct(that, callData);
|
return construct(that, callData);
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionPrototype::FunctionPrototype(InternalClass *ic)
|
DEFINE_OBJECT_VTABLE(FunctionPrototype);
|
||||||
: FunctionObject(ic)
|
|
||||||
|
FunctionPrototype::Data::Data(InternalClass *ic)
|
||||||
|
: FunctionObject::Data(ic)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,10 +134,6 @@ struct Q_QML_EXPORT FunctionObject: Object {
|
||||||
unsigned int formalParameterCount() { return function() ? function()->compiledFunction->nFormals : 0; }
|
unsigned int formalParameterCount() { return function() ? function()->compiledFunction->nFormals : 0; }
|
||||||
unsigned int varCount() { return function() ? function()->compiledFunction->nLocals : 0; }
|
unsigned int varCount() { return function() ? function()->compiledFunction->nLocals : 0; }
|
||||||
|
|
||||||
FunctionObject(ExecutionContext *scope, String *name, bool createProto = false);
|
|
||||||
FunctionObject(ExecutionContext *scope, const QString &name = QString(), bool createProto = false);
|
|
||||||
FunctionObject(ExecutionContext *scope, const ReturnedValue name);
|
|
||||||
|
|
||||||
void init(String *name, bool createProto);
|
void init(String *name, bool createProto);
|
||||||
|
|
||||||
ReturnedValue newInstance();
|
ReturnedValue newInstance();
|
||||||
|
@ -162,9 +158,6 @@ struct Q_QML_EXPORT FunctionObject: Object {
|
||||||
bool strictMode() const { return d()->strictMode; }
|
bool strictMode() const { return d()->strictMode; }
|
||||||
bool bindingKeyFlag() const { return d()->bindingKeyFlag; }
|
bool bindingKeyFlag() const { return d()->bindingKeyFlag; }
|
||||||
|
|
||||||
protected:
|
|
||||||
FunctionObject(InternalClass *ic);
|
|
||||||
|
|
||||||
static void markObjects(Managed *that, ExecutionEngine *e);
|
static void markObjects(Managed *that, ExecutionEngine *e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -187,7 +180,11 @@ struct FunctionCtor: FunctionObject
|
||||||
|
|
||||||
struct FunctionPrototype: FunctionObject
|
struct FunctionPrototype: FunctionObject
|
||||||
{
|
{
|
||||||
FunctionPrototype(InternalClass *ic);
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(InternalClass *ic);
|
||||||
|
};
|
||||||
|
V4_OBJECT
|
||||||
|
|
||||||
void init(ExecutionEngine *engine, Object *ctor);
|
void init(ExecutionEngine *engine, Object *ctor);
|
||||||
|
|
||||||
static ReturnedValue method_toString(CallContext *ctx);
|
static ReturnedValue method_toString(CallContext *ctx);
|
||||||
|
|
|
@ -346,11 +346,13 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
|
||||||
|
|
||||||
DEFINE_OBJECT_VTABLE(EvalFunction);
|
DEFINE_OBJECT_VTABLE(EvalFunction);
|
||||||
|
|
||||||
EvalFunction::EvalFunction(ExecutionContext *scope)
|
EvalFunction::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, scope->d()->engine->id_eval)
|
: FunctionObject::Data(scope, scope->d()->engine->id_eval)
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1));
|
Scope s(scope);
|
||||||
|
ScopedFunctionObject f(s, this);
|
||||||
|
f->defineReadonlyProperty(s.engine->id_length, Primitive::fromInt32(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall)
|
ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall)
|
||||||
|
|
|
@ -50,8 +50,11 @@ namespace QV4 {
|
||||||
|
|
||||||
struct Q_QML_EXPORT EvalFunction : FunctionObject
|
struct Q_QML_EXPORT EvalFunction : FunctionObject
|
||||||
{
|
{
|
||||||
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
|
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
EvalFunction(ExecutionContext *scope);
|
|
||||||
|
|
||||||
ReturnedValue evalCall(CallData *callData, bool directCall);
|
ReturnedValue evalCall(CallData *callData, bool directCall);
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,8 @@ using namespace QV4;
|
||||||
DEFINE_OBJECT_VTABLE(NumberCtor);
|
DEFINE_OBJECT_VTABLE(NumberCtor);
|
||||||
DEFINE_OBJECT_VTABLE(NumberObject);
|
DEFINE_OBJECT_VTABLE(NumberObject);
|
||||||
|
|
||||||
NumberCtor::NumberCtor(ExecutionContext *scope)
|
NumberCtor::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("Number"))
|
: FunctionObject::Data(scope, QStringLiteral("Number"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,10 @@ namespace QV4 {
|
||||||
|
|
||||||
struct NumberCtor: FunctionObject
|
struct NumberCtor: FunctionObject
|
||||||
{
|
{
|
||||||
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
NumberCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *that, CallData *callData);
|
static ReturnedValue construct(Managed *that, CallData *callData);
|
||||||
static ReturnedValue call(Managed *, CallData *callData);
|
static ReturnedValue call(Managed *, CallData *callData);
|
||||||
|
|
|
@ -74,8 +74,8 @@ using namespace QV4;
|
||||||
|
|
||||||
DEFINE_OBJECT_VTABLE(ObjectCtor);
|
DEFINE_OBJECT_VTABLE(ObjectCtor);
|
||||||
|
|
||||||
ObjectCtor::ObjectCtor(ExecutionContext *scope)
|
ObjectCtor::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("Object"))
|
: FunctionObject::Data(scope, QStringLiteral("Object"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,10 @@ namespace QV4 {
|
||||||
|
|
||||||
struct ObjectCtor: FunctionObject
|
struct ObjectCtor: FunctionObject
|
||||||
{
|
{
|
||||||
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
ObjectCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *that, CallData *callData);
|
static ReturnedValue construct(Managed *that, CallData *callData);
|
||||||
static ReturnedValue call(Managed *that, CallData *callData);
|
static ReturnedValue call(Managed *that, CallData *callData);
|
||||||
|
|
|
@ -237,19 +237,19 @@ uint RegExpObject::flags() const
|
||||||
|
|
||||||
DEFINE_OBJECT_VTABLE(RegExpCtor);
|
DEFINE_OBJECT_VTABLE(RegExpCtor);
|
||||||
|
|
||||||
RegExpCtor::RegExpCtor(ExecutionContext *scope)
|
RegExpCtor::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("RegExp"))
|
: FunctionObject::Data(scope, QStringLiteral("RegExp"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
clearLastMatch();
|
clearLastMatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegExpCtor::clearLastMatch()
|
void RegExpCtor::Data::clearLastMatch()
|
||||||
{
|
{
|
||||||
d()->lastMatch = Primitive::nullValue();
|
lastMatch = Primitive::nullValue();
|
||||||
d()->lastInput = engine()->id_empty;
|
lastInput = internalClass->engine->id_empty;
|
||||||
d()->lastMatchStart = 0;
|
lastMatchStart = 0;
|
||||||
d()->lastMatchEnd = 0;
|
lastMatchEnd = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
|
ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
|
||||||
|
@ -379,7 +379,7 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx)
|
||||||
const int result = r->value()->match(s, offset, matchOffsets);
|
const int result = r->value()->match(s, offset, matchOffsets);
|
||||||
|
|
||||||
Scoped<RegExpCtor> regExpCtor(scope, ctx->d()->engine->regExpCtor);
|
Scoped<RegExpCtor> regExpCtor(scope, ctx->d()->engine->regExpCtor);
|
||||||
regExpCtor->clearLastMatch();
|
regExpCtor->d()->clearLastMatch();
|
||||||
|
|
||||||
if (result == -1) {
|
if (result == -1) {
|
||||||
r->lastIndexProperty(ctx)->value = Primitive::fromInt32(0);
|
r->lastIndexProperty(ctx)->value = Primitive::fromInt32(0);
|
||||||
|
|
|
@ -110,10 +110,12 @@ protected:
|
||||||
struct RegExpCtor: FunctionObject
|
struct RegExpCtor: FunctionObject
|
||||||
{
|
{
|
||||||
struct Data : FunctionObject::Data {
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
Value lastMatch;
|
Value lastMatch;
|
||||||
StringValue lastInput;
|
StringValue lastInput;
|
||||||
int lastMatchStart;
|
int lastMatchStart;
|
||||||
int lastMatchEnd;
|
int lastMatchEnd;
|
||||||
|
void clearLastMatch();
|
||||||
};
|
};
|
||||||
struct {
|
struct {
|
||||||
Value lastMatch;
|
Value lastMatch;
|
||||||
|
@ -123,13 +125,11 @@ struct RegExpCtor: FunctionObject
|
||||||
} __data;
|
} __data;
|
||||||
|
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
RegExpCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
Value lastMatch() { return d()->lastMatch; }
|
Value lastMatch() { return d()->lastMatch; }
|
||||||
StringValue lastInput() { return d()->lastInput; }
|
StringValue lastInput() { return d()->lastInput; }
|
||||||
int lastMatchStart() { return d()->lastMatchStart; }
|
int lastMatchStart() { return d()->lastMatchStart; }
|
||||||
int lastMatchEnd() { return d()->lastMatchEnd; }
|
int lastMatchEnd() { return d()->lastMatchEnd; }
|
||||||
void clearLastMatch();
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
static ReturnedValue call(Managed *that, CallData *callData);
|
static ReturnedValue call(Managed *that, CallData *callData);
|
||||||
|
|
|
@ -173,8 +173,8 @@ void StringObject::markObjects(Managed *that, ExecutionEngine *e)
|
||||||
|
|
||||||
DEFINE_OBJECT_VTABLE(StringCtor);
|
DEFINE_OBJECT_VTABLE(StringCtor);
|
||||||
|
|
||||||
StringCtor::StringCtor(ExecutionContext *scope)
|
StringCtor::Data::Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("String"))
|
: FunctionObject::Data(scope, QStringLiteral("String"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,10 @@ protected:
|
||||||
|
|
||||||
struct StringCtor: FunctionObject
|
struct StringCtor: FunctionObject
|
||||||
{
|
{
|
||||||
|
struct Data : FunctionObject::Data {
|
||||||
|
Data(ExecutionContext *scope);
|
||||||
|
};
|
||||||
V4_OBJECT
|
V4_OBJECT
|
||||||
StringCtor(ExecutionContext *scope);
|
|
||||||
|
|
||||||
static ReturnedValue construct(Managed *m, CallData *callData);
|
static ReturnedValue construct(Managed *m, CallData *callData);
|
||||||
static ReturnedValue call(Managed *that, CallData *callData);
|
static ReturnedValue call(Managed *that, CallData *callData);
|
||||||
|
|
|
@ -72,10 +72,13 @@ using namespace QV4;
|
||||||
|
|
||||||
struct Print: FunctionObject
|
struct Print: FunctionObject
|
||||||
{
|
{
|
||||||
V4_OBJECT
|
struct Data : FunctionObject::Data {
|
||||||
Print(ExecutionContext *scope): FunctionObject(scope, QStringLiteral("print")) {
|
Data(ExecutionContext *scope)
|
||||||
|
: FunctionObject::Data(scope, QStringLiteral("print")) {
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
V4_OBJECT
|
||||||
|
|
||||||
static ReturnedValue call(Managed *, CallData *callData)
|
static ReturnedValue call(Managed *, CallData *callData)
|
||||||
{
|
{
|
||||||
|
@ -94,12 +97,16 @@ DEFINE_OBJECT_VTABLE(Print);
|
||||||
|
|
||||||
struct GC: public FunctionObject
|
struct GC: public FunctionObject
|
||||||
{
|
{
|
||||||
V4_OBJECT
|
struct Data : FunctionObject::Data {
|
||||||
GC(ExecutionContext* scope)
|
Data(ExecutionContext *scope)
|
||||||
: FunctionObject(scope, QStringLiteral("gc"))
|
: FunctionObject::Data(scope, QStringLiteral("gc"))
|
||||||
{
|
{
|
||||||
setVTable(staticVTable());
|
setVTable(staticVTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
V4_OBJECT
|
||||||
|
|
||||||
static ReturnedValue call(Managed *m, CallData *)
|
static ReturnedValue call(Managed *m, CallData *)
|
||||||
{
|
{
|
||||||
m->engine()->memoryManager->runGC();
|
m->engine()->memoryManager->runGC();
|
||||||
|
@ -190,9 +197,9 @@ int main(int argc, char *argv[])
|
||||||
QV4::Scope scope(ctx);
|
QV4::Scope scope(ctx);
|
||||||
|
|
||||||
QV4::ScopedObject globalObject(scope, vm.globalObject);
|
QV4::ScopedObject globalObject(scope, vm.globalObject);
|
||||||
QV4::ScopedObject print(scope, new (scope.engine->memoryManager) builtins::Print(ctx));
|
QV4::ScopedObject print(scope, new (scope.engine) builtins::Print::Data(ctx));
|
||||||
globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))).getPointer(), print);
|
globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("print"))).getPointer(), print);
|
||||||
QV4::ScopedObject gc(scope, new (scope.engine->memoryManager) builtins::GC(ctx));
|
QV4::ScopedObject gc(scope, new (scope.engine) builtins::GC::Data(ctx));
|
||||||
globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc);
|
globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc);
|
||||||
|
|
||||||
foreach (const QString &fn, args) {
|
foreach (const QString &fn, args) {
|
||||||
|
|
Loading…
Reference in New Issue