struct ArgumentsGetterFunction: FunctionObject
{
struct Data : FunctionObject::Data {
+ Data(ExecutionContext *scope, uint index)
+ : FunctionObject::Data(scope)
+ , index(index)
+ {
+ setVTable(staticVTable());
+ }
uint index;
};
struct {
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 {
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);
};
DEFINE_OBJECT_VTABLE(ArrayCtor);
-ArrayCtor::ArrayCtor(ExecutionContext *scope)
- : FunctionObject(scope, QStringLiteral("Array"))
+ArrayCtor::Data::Data(ExecutionContext *scope)
+ : FunctionObject::Data(scope, QStringLiteral("Array"))
{
setVTable(staticVTable());
}
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);
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());
}
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);
DEFINE_OBJECT_VTABLE(DateCtor);
-DateCtor::DateCtor(ExecutionContext *scope)
- : FunctionObject(scope, QStringLiteral("Date"))
+DateCtor::Data::Data(ExecutionContext *scope)
+ : FunctionObject::Data(scope, QStringLiteral("Date"))
{
setVTable(staticVTable());
}
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 *);
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);
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());
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);
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));
}
}
}
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());
}
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());
}
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());
}
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());
}
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());
}
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());
}
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());
}
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);
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);
};
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()
{
return construct(that, callData);
}
-FunctionPrototype::FunctionPrototype(InternalClass *ic)
- : FunctionObject(ic)
+DEFINE_OBJECT_VTABLE(FunctionPrototype);
+
+FunctionPrototype::Data::Data(InternalClass *ic)
+ : FunctionObject::Data(ic)
{
}
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();
bool strictMode() const { return d()->strictMode; }
bool bindingKeyFlag() const { return d()->bindingKeyFlag; }
-protected:
- FunctionObject(InternalClass *ic);
-
static void markObjects(Managed *that, ExecutionEngine *e);
};
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);
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)
struct Q_QML_EXPORT EvalFunction : FunctionObject
{
+ struct Data : FunctionObject::Data {
+ Data(ExecutionContext *scope);
+ };
+
V4_OBJECT
- EvalFunction(ExecutionContext *scope);
ReturnedValue evalCall(CallData *callData, bool directCall);
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());
}
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);
DEFINE_OBJECT_VTABLE(ObjectCtor);
-ObjectCtor::ObjectCtor(ExecutionContext *scope)
- : FunctionObject(scope, QStringLiteral("Object"))
+ObjectCtor::Data::Data(ExecutionContext *scope)
+ : FunctionObject::Data(scope, QStringLiteral("Object"))
{
setVTable(staticVTable());
}
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);
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)
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);
struct RegExpCtor: FunctionObject
{
struct Data : FunctionObject::Data {
+ Data(ExecutionContext *scope);
Value lastMatch;
StringValue lastInput;
int lastMatchStart;
int lastMatchEnd;
+ void clearLastMatch();
};
struct {
Value lastMatch;
} __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);
DEFINE_OBJECT_VTABLE(StringCtor);
-StringCtor::StringCtor(ExecutionContext *scope)
- : FunctionObject(scope, QStringLiteral("String"))
+StringCtor::Data::Data(ExecutionContext *scope)
+ : FunctionObject::Data(scope, QStringLiteral("String"))
{
setVTable(staticVTable());
}
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);
struct Print: FunctionObject
{
+ struct Data : FunctionObject::Data {
+ Data(ExecutionContext *scope)
+ : FunctionObject::Data(scope, QStringLiteral("print")) {
+ setVTable(staticVTable());
+ }
+ };
V4_OBJECT
- Print(ExecutionContext *scope): FunctionObject(scope, QStringLiteral("print")) {
- setVTable(staticVTable());
- }
static ReturnedValue call(Managed *, CallData *callData)
{
struct GC: public FunctionObject
{
+ struct Data : FunctionObject::Data {
+ Data(ExecutionContext *scope)
+ : FunctionObject::Data(scope, QStringLiteral("gc"))
+ {
+ setVTable(staticVTable());
+ }
+
+ };
V4_OBJECT
- GC(ExecutionContext* scope)
- : FunctionObject(scope, QStringLiteral("gc"))
- {
- setVTable(staticVTable());
- }
+
static ReturnedValue call(Managed *m, CallData *)
{
m->engine()->memoryManager->runGC();
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) {