Convert remaining FunctionObject's to new constructor scheme

Change-Id: I440d5b128d0ee28566ebfa82c2505a4bd97bba6b
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
This commit is contained in:
Lars Knoll 2014-05-09 12:15:23 +02:00 committed by Simon Hausmann
parent 00fa904911
commit dba56a752c
23 changed files with 147 additions and 151 deletions

View File

@ -51,6 +51,12 @@ namespace QV4 {
struct ArgumentsGetterFunction: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope, uint index)
: FunctionObject::Data(scope)
, index(index)
{
setVTable(staticVTable());
}
uint index;
};
struct {
@ -60,19 +66,18 @@ struct ArgumentsGetterFunction: FunctionObject
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);
};
struct ArgumentsSetterFunction: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope, uint index)
: FunctionObject::Data(scope)
, index(index)
{
setVTable(staticVTable());
}
uint index;
};
struct {
@ -82,13 +87,6 @@ struct ArgumentsSetterFunction: FunctionObject
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);
};

View File

@ -48,8 +48,8 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ArrayCtor);
ArrayCtor::ArrayCtor(ExecutionContext *scope)
: FunctionObject(scope, QStringLiteral("Array"))
ArrayCtor::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("Array"))
{
setVTable(staticVTable());
}

View File

@ -51,8 +51,11 @@ namespace QV4 {
struct ArrayCtor: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
ArrayCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *m, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);

View File

@ -46,8 +46,8 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(BooleanCtor);
DEFINE_OBJECT_VTABLE(BooleanObject);
BooleanCtor::BooleanCtor(ExecutionContext *scope)
: FunctionObject(scope, QStringLiteral("Boolean"))
BooleanCtor::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("Boolean"))
{
setVTable(staticVTable());
}

View File

@ -51,8 +51,11 @@ namespace QV4 {
struct BooleanCtor: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
BooleanCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);

View File

@ -657,8 +657,8 @@ QDateTime DateObject::toQDateTime() const
DEFINE_OBJECT_VTABLE(DateCtor);
DateCtor::DateCtor(ExecutionContext *scope)
: FunctionObject(scope, QStringLiteral("Date"))
DateCtor::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("Date"))
{
setVTable(staticVTable());
}

View File

@ -84,8 +84,10 @@ protected:
struct DateCtor: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
DateCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *);

View File

@ -295,7 +295,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
uint index;
functionProtoClass = functionProtoClass->addMember(id_prototype, Attr_NotEnumerable, &index);
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 = functionClass->addMember(id_prototype, Attr_NotEnumerable|Attr_NotConfigurable, &index);
Q_ASSERT(index == FunctionObject::Index_Prototype);
@ -331,21 +331,21 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
sequencePrototype = new (memoryManager) SequencePrototype(arrayClass);
objectCtor = new (memoryManager) ObjectCtor(rootContext);
stringCtor = new (memoryManager) StringCtor(rootContext);
numberCtor = new (memoryManager) NumberCtor(rootContext);
booleanCtor = new (memoryManager) BooleanCtor(rootContext);
arrayCtor = new (memoryManager) ArrayCtor(rootContext);
objectCtor = static_cast<HeapObject *>(new (this) ObjectCtor::Data(rootContext));
stringCtor = static_cast<HeapObject *>(new (this) StringCtor::Data(rootContext));
numberCtor = static_cast<HeapObject *>(new (this) NumberCtor::Data(rootContext));
booleanCtor = static_cast<HeapObject *>(new (this) BooleanCtor::Data(rootContext));
arrayCtor = static_cast<HeapObject *>(new (this) ArrayCtor::Data(rootContext));
functionCtor = static_cast<HeapObject *>(new (this) FunctionCtor::Data(rootContext));
dateCtor = new (memoryManager) DateCtor(rootContext);
regExpCtor = new (memoryManager) RegExpCtor(rootContext);
errorCtor = new (memoryManager) ErrorCtor(rootContext);
evalErrorCtor = new (memoryManager) EvalErrorCtor(rootContext);
rangeErrorCtor = new (memoryManager) RangeErrorCtor(rootContext);
referenceErrorCtor = new (memoryManager) ReferenceErrorCtor(rootContext);
syntaxErrorCtor = new (memoryManager) SyntaxErrorCtor(rootContext);
typeErrorCtor = new (memoryManager) TypeErrorCtor(rootContext);
uRIErrorCtor = new (memoryManager) URIErrorCtor(rootContext);
dateCtor = static_cast<HeapObject *>(new (this) DateCtor::Data(rootContext));
regExpCtor = static_cast<HeapObject *>(new (this) RegExpCtor::Data(rootContext));
errorCtor = static_cast<HeapObject *>(new (this) ErrorCtor::Data(rootContext));
evalErrorCtor = static_cast<HeapObject *>(new (this) EvalErrorCtor::Data(rootContext));
rangeErrorCtor = static_cast<HeapObject *>(new (this) RangeErrorCtor::Data(rootContext));
referenceErrorCtor = static_cast<HeapObject *>(new (this) ReferenceErrorCtor::Data(rootContext));
syntaxErrorCtor = static_cast<HeapObject *>(new (this) SyntaxErrorCtor::Data(rootContext));
typeErrorCtor = static_cast<HeapObject *>(new (this) TypeErrorCtor::Data(rootContext));
uRIErrorCtor = static_cast<HeapObject *>(new (this) URIErrorCtor::Data(rootContext));
objectPrototype->init(this, objectCtor.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("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("parseInt"), GlobalFunctions::method_parseInt, 2);
@ -807,8 +808,8 @@ void ExecutionEngine::requireArgumentsAccessors(int n)
delete [] oldAccessors;
}
for (int i = oldSize; i < nArgumentsAccessors; ++i) {
argumentsAccessors[i].value = Value::fromManaged(new (memoryManager) ArgumentsGetterFunction(rootContext, i));
argumentsAccessors[i].set = Value::fromManaged(new (memoryManager) ArgumentsSetterFunction(rootContext, i));
argumentsAccessors[i].value = ScopedValue(scope, new (scope.engine) ArgumentsGetterFunction::Data(rootContext, i));
argumentsAccessors[i].set = ScopedValue(scope, new (scope.engine) ArgumentsSetterFunction::Data(rootContext, i));
}
}
}

View File

@ -253,14 +253,14 @@ DEFINE_OBJECT_VTABLE(SyntaxErrorCtor);
DEFINE_OBJECT_VTABLE(TypeErrorCtor);
DEFINE_OBJECT_VTABLE(URIErrorCtor);
ErrorCtor::ErrorCtor(ExecutionContext *scope)
: FunctionObject(scope, QStringLiteral("Error"))
ErrorCtor::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("Error"))
{
setVTable(staticVTable());
}
ErrorCtor::ErrorCtor(ExecutionContext *scope, const QString &name)
: FunctionObject(scope, name)
ErrorCtor::Data::Data(ExecutionContext *scope, const QString &name)
: FunctionObject::Data(scope, name)
{
setVTable(staticVTable());
}
@ -277,8 +277,8 @@ ReturnedValue ErrorCtor::call(Managed *that, CallData *callData)
return static_cast<Object *>(that)->construct(callData);
}
EvalErrorCtor::EvalErrorCtor(ExecutionContext *scope)
: ErrorCtor(scope, QStringLiteral("EvalError"))
EvalErrorCtor::Data::Data(ExecutionContext *scope)
: ErrorCtor::Data(scope, QStringLiteral("EvalError"))
{
setVTable(staticVTable());
}
@ -290,8 +290,8 @@ ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData)
return (new (m->engine()->memoryManager) EvalErrorObject(m->engine(), v))->asReturnedValue();
}
RangeErrorCtor::RangeErrorCtor(ExecutionContext *scope)
: ErrorCtor(scope, QStringLiteral("RangeError"))
RangeErrorCtor::Data::Data(ExecutionContext *scope)
: ErrorCtor::Data(scope, QStringLiteral("RangeError"))
{
setVTable(staticVTable());
}
@ -303,8 +303,8 @@ ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData)
return (new (m->engine()->memoryManager) RangeErrorObject(scope.engine, v))->asReturnedValue();
}
ReferenceErrorCtor::ReferenceErrorCtor(ExecutionContext *scope)
: ErrorCtor(scope, QStringLiteral("ReferenceError"))
ReferenceErrorCtor::Data::Data(ExecutionContext *scope)
: ErrorCtor::Data(scope, QStringLiteral("ReferenceError"))
{
setVTable(staticVTable());
}
@ -316,8 +316,8 @@ ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData)
return (new (m->engine()->memoryManager) ReferenceErrorObject(scope.engine, v))->asReturnedValue();
}
SyntaxErrorCtor::SyntaxErrorCtor(ExecutionContext *scope)
: ErrorCtor(scope, QStringLiteral("SyntaxError"))
SyntaxErrorCtor::Data::Data(ExecutionContext *scope)
: ErrorCtor::Data(scope, QStringLiteral("SyntaxError"))
{
setVTable(staticVTable());
}
@ -329,8 +329,8 @@ ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData)
return (new (m->engine()->memoryManager) SyntaxErrorObject(scope.engine, v))->asReturnedValue();
}
TypeErrorCtor::TypeErrorCtor(ExecutionContext *scope)
: ErrorCtor(scope, QStringLiteral("TypeError"))
TypeErrorCtor::Data::Data(ExecutionContext *scope)
: ErrorCtor::Data(scope, QStringLiteral("TypeError"))
{
setVTable(staticVTable());
}
@ -342,8 +342,8 @@ ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData)
return (new (m->engine()->memoryManager) TypeErrorObject(scope.engine, v))->asReturnedValue();
}
URIErrorCtor::URIErrorCtor(ExecutionContext *scope)
: ErrorCtor(scope, QStringLiteral("URIError"))
URIErrorCtor::Data::Data(ExecutionContext *scope)
: ErrorCtor::Data(scope, QStringLiteral("URIError"))
{
setVTable(staticVTable());
}

View File

@ -125,9 +125,12 @@ struct URIErrorObject: ErrorObject {
struct ErrorCtor: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
Data(ExecutionContext *scope, const QString &name);
};
V4_OBJECT
ErrorCtor(ExecutionContext *scope);
ErrorCtor(ExecutionContext *scope, const QString &name);
static ReturnedValue construct(Managed *, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);
@ -135,49 +138,60 @@ struct ErrorCtor: FunctionObject
struct EvalErrorCtor: ErrorCtor
{
struct Data : ErrorCtor::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
EvalErrorCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *m, CallData *callData);
};
struct RangeErrorCtor: ErrorCtor
{
struct Data : ErrorCtor::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
RangeErrorCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *m, CallData *callData);
};
struct ReferenceErrorCtor: ErrorCtor
{
struct Data : ErrorCtor::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
ReferenceErrorCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *m, CallData *callData);
};
struct SyntaxErrorCtor: ErrorCtor
{
struct Data : ErrorCtor::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
SyntaxErrorCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *m, CallData *callData);
};
struct TypeErrorCtor: ErrorCtor
{
struct Data : ErrorCtor::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
TypeErrorCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *m, CallData *callData);
};
struct URIErrorCtor: ErrorCtor
{
struct Data : ErrorCtor::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
URIErrorCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *m, CallData *callData);
};

View File

@ -112,48 +112,6 @@ FunctionObject::Data::Data(InternalClass *ic)
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()
{
@ -288,8 +246,10 @@ ReturnedValue FunctionCtor::call(Managed *that, CallData *callData)
return construct(that, callData);
}
FunctionPrototype::FunctionPrototype(InternalClass *ic)
: FunctionObject(ic)
DEFINE_OBJECT_VTABLE(FunctionPrototype);
FunctionPrototype::Data::Data(InternalClass *ic)
: FunctionObject::Data(ic)
{
}

View File

@ -134,10 +134,6 @@ struct Q_QML_EXPORT FunctionObject: Object {
unsigned int formalParameterCount() { return function() ? function()->compiledFunction->nFormals : 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);
ReturnedValue newInstance();
@ -162,9 +158,6 @@ struct Q_QML_EXPORT FunctionObject: Object {
bool strictMode() const { return d()->strictMode; }
bool bindingKeyFlag() const { return d()->bindingKeyFlag; }
protected:
FunctionObject(InternalClass *ic);
static void markObjects(Managed *that, ExecutionEngine *e);
};
@ -187,7 +180,11 @@ struct FunctionCtor: FunctionObject
struct FunctionPrototype: FunctionObject
{
FunctionPrototype(InternalClass *ic);
struct Data : FunctionObject::Data {
Data(InternalClass *ic);
};
V4_OBJECT
void init(ExecutionEngine *engine, Object *ctor);
static ReturnedValue method_toString(CallContext *ctx);

View File

@ -346,11 +346,13 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok)
DEFINE_OBJECT_VTABLE(EvalFunction);
EvalFunction::EvalFunction(ExecutionContext *scope)
: FunctionObject(scope, scope->d()->engine->id_eval)
EvalFunction::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, scope->d()->engine->id_eval)
{
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)

View File

@ -50,8 +50,11 @@ namespace QV4 {
struct Q_QML_EXPORT EvalFunction : FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
EvalFunction(ExecutionContext *scope);
ReturnedValue evalCall(CallData *callData, bool directCall);

View File

@ -51,8 +51,8 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(NumberCtor);
DEFINE_OBJECT_VTABLE(NumberObject);
NumberCtor::NumberCtor(ExecutionContext *scope)
: FunctionObject(scope, QStringLiteral("Number"))
NumberCtor::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("Number"))
{
setVTable(staticVTable());
}

View File

@ -51,8 +51,10 @@ namespace QV4 {
struct NumberCtor: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
NumberCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *that, CallData *callData);
static ReturnedValue call(Managed *, CallData *callData);

View File

@ -74,8 +74,8 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ObjectCtor);
ObjectCtor::ObjectCtor(ExecutionContext *scope)
: FunctionObject(scope, QStringLiteral("Object"))
ObjectCtor::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("Object"))
{
setVTable(staticVTable());
}

View File

@ -51,8 +51,10 @@ namespace QV4 {
struct ObjectCtor: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
ObjectCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *that, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);

View File

@ -237,19 +237,19 @@ uint RegExpObject::flags() const
DEFINE_OBJECT_VTABLE(RegExpCtor);
RegExpCtor::RegExpCtor(ExecutionContext *scope)
: FunctionObject(scope, QStringLiteral("RegExp"))
RegExpCtor::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("RegExp"))
{
setVTable(staticVTable());
clearLastMatch();
}
void RegExpCtor::clearLastMatch()
void RegExpCtor::Data::clearLastMatch()
{
d()->lastMatch = Primitive::nullValue();
d()->lastInput = engine()->id_empty;
d()->lastMatchStart = 0;
d()->lastMatchEnd = 0;
lastMatch = Primitive::nullValue();
lastInput = internalClass->engine->id_empty;
lastMatchStart = 0;
lastMatchEnd = 0;
}
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);
Scoped<RegExpCtor> regExpCtor(scope, ctx->d()->engine->regExpCtor);
regExpCtor->clearLastMatch();
regExpCtor->d()->clearLastMatch();
if (result == -1) {
r->lastIndexProperty(ctx)->value = Primitive::fromInt32(0);

View File

@ -110,10 +110,12 @@ protected:
struct RegExpCtor: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
Value lastMatch;
StringValue lastInput;
int lastMatchStart;
int lastMatchEnd;
void clearLastMatch();
};
struct {
Value lastMatch;
@ -123,13 +125,11 @@ struct RegExpCtor: FunctionObject
} __data;
V4_OBJECT
RegExpCtor(ExecutionContext *scope);
Value lastMatch() { return d()->lastMatch; }
StringValue lastInput() { return d()->lastInput; }
int lastMatchStart() { return d()->lastMatchStart; }
int lastMatchEnd() { return d()->lastMatchEnd; }
void clearLastMatch();
static ReturnedValue construct(Managed *m, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);

View File

@ -173,8 +173,8 @@ void StringObject::markObjects(Managed *that, ExecutionEngine *e)
DEFINE_OBJECT_VTABLE(StringCtor);
StringCtor::StringCtor(ExecutionContext *scope)
: FunctionObject(scope, QStringLiteral("String"))
StringCtor::Data::Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("String"))
{
setVTable(staticVTable());
}

View File

@ -76,8 +76,10 @@ protected:
struct StringCtor: FunctionObject
{
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope);
};
V4_OBJECT
StringCtor(ExecutionContext *scope);
static ReturnedValue construct(Managed *m, CallData *callData);
static ReturnedValue call(Managed *that, CallData *callData);

View File

@ -72,10 +72,13 @@ using namespace QV4;
struct Print: FunctionObject
{
V4_OBJECT
Print(ExecutionContext *scope): FunctionObject(scope, QStringLiteral("print")) {
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("print")) {
setVTable(staticVTable());
}
};
V4_OBJECT
static ReturnedValue call(Managed *, CallData *callData)
{
@ -94,12 +97,16 @@ DEFINE_OBJECT_VTABLE(Print);
struct GC: public FunctionObject
{
V4_OBJECT
GC(ExecutionContext* scope)
: FunctionObject(scope, QStringLiteral("gc"))
struct Data : FunctionObject::Data {
Data(ExecutionContext *scope)
: FunctionObject::Data(scope, QStringLiteral("gc"))
{
setVTable(staticVTable());
}
};
V4_OBJECT
static ReturnedValue call(Managed *m, CallData *)
{
m->engine()->memoryManager->runGC();
@ -190,9 +197,9 @@ int main(int argc, char *argv[])
QV4::Scope scope(ctx);
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);
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);
foreach (const QString &fn, args) {