diff options
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index e160dd8a36..2cc58b74a6 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -68,18 +68,20 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(FunctionObject); -Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, QV4::String *name, bool createProto) - : function(Q_NULLPTR) +void Heap::FunctionObject::init(QV4::ExecutionContext *scope, QV4::String *name, bool createProto) { + Object::init(); + function = nullptr; this->scope = scope->d(); Scope s(scope->engine()); ScopedFunctionObject f(s, this); f->init(name, createProto); } -Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, Function *function, bool createProto) - : function(Q_NULLPTR) +void Heap::FunctionObject::init(QV4::ExecutionContext *scope, Function *function, bool createProto) { + Object::init(); + function = nullptr; this->scope = scope->d(); Scope s(scope->engine()); ScopedString name(s, function->name()); @@ -87,9 +89,10 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, Function *fun f->init(name, createProto); } -Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const QString &name, bool createProto) - : function(Q_NULLPTR) +void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const QString &name, bool createProto) { + Object::init(); + function = nullptr; this->scope = scope->d(); Scope s(scope->engine()); ScopedFunctionObject f(s, this); @@ -97,9 +100,10 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const QString f->init(n, createProto); } -Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto) - : function(Q_NULLPTR) +void Heap::FunctionObject::init(ExecutionContext *scope, const QString &name, bool createProto) { + Object::init(); + function = nullptr; this->scope = scope; Scope s(scope->engine); ScopedFunctionObject f(s, this); @@ -107,9 +111,10 @@ Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const QString &nam f->init(n, createProto); } -Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const ReturnedValue name) - : function(Q_NULLPTR) +void Heap::FunctionObject::init(QV4::ExecutionContext *scope, const ReturnedValue name) { + Object::init(); + function = nullptr; this->scope = scope->d(); Scope s(scope); ScopedFunctionObject f(s, this); @@ -117,9 +122,10 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const Returne f->init(n, false); } -Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name) - : function(Q_NULLPTR) +void Heap::FunctionObject::init(ExecutionContext *scope, const ReturnedValue name) { + Object::init(); + function = nullptr; this->scope = scope; Scope s(scope->engine); ScopedFunctionObject f(s, this); @@ -127,19 +133,21 @@ Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValu f->init(n, false); } -Heap::FunctionObject::FunctionObject() - : function(Q_NULLPTR) +void Heap::FunctionObject::init() { + Object::init(); + function = nullptr; this->scope = internalClass->engine->rootContext()->d(); Q_ASSERT(internalClass && internalClass->find(internalClass->engine->id_prototype()) == Index_Prototype); *propertyData(Index_Prototype) = Encode::undefined(); } -Heap::FunctionObject::~FunctionObject() +void Heap::FunctionObject::destroy() { if (function) function->compilationUnit->release(); + Object::destroy(); } void FunctionObject::init(String *n, bool createProto) @@ -227,7 +235,7 @@ QQmlSourceLocation FunctionObject::sourceLocation() const { if (isBinding()) { Q_ASSERT(as<const QV4::QQmlBindingFunction>()); - return static_cast<QV4::Heap::QQmlBindingFunction *>(d())->bindingLocation; + return *static_cast<QV4::Heap::QQmlBindingFunction *>(d())->bindingLocation; } QV4::Function *function = d()->function; Q_ASSERT(function); @@ -237,9 +245,9 @@ QQmlSourceLocation FunctionObject::sourceLocation() const DEFINE_OBJECT_VTABLE(FunctionCtor); -Heap::FunctionCtor::FunctionCtor(QV4::ExecutionContext *scope) - : Heap::FunctionObject(scope, QStringLiteral("Function")) +void Heap::FunctionCtor::init(QV4::ExecutionContext *scope) { + Heap::FunctionObject::init(scope, QStringLiteral("Function")); } // 15.3.2 @@ -305,8 +313,9 @@ void FunctionCtor::call(const Managed *that, Scope &scope, CallData *callData) DEFINE_OBJECT_VTABLE(FunctionPrototype); -Heap::FunctionPrototype::FunctionPrototype() +void Heap::FunctionPrototype::init() { + Heap::FunctionObject::init(); } void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor) @@ -417,9 +426,9 @@ ReturnedValue FunctionPrototype::method_bind(CallContext *ctx) DEFINE_OBJECT_VTABLE(ScriptFunction); -Heap::ScriptFunction::ScriptFunction(QV4::ExecutionContext *scope, Function *function) - : Heap::SimpleScriptFunction(scope, function, true) +void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function) { + Heap::SimpleScriptFunction::init(scope, function, true); } void ScriptFunction::construct(const Managed *that, Scope &scope, CallData *callData) @@ -478,8 +487,9 @@ void ScriptFunction::call(const Managed *that, Scope &scope, CallData *callData) DEFINE_OBJECT_VTABLE(SimpleScriptFunction); -Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, Function *function, bool createProto) +void Heap::SimpleScriptFunction::init(QV4::ExecutionContext *scope, Function *function, bool createProto) { + FunctionObject::init(); this->scope = scope->d(); this->function = function; @@ -599,10 +609,10 @@ Heap::Object *SimpleScriptFunction::protoForConstructor() DEFINE_OBJECT_VTABLE(BuiltinFunction); -Heap::BuiltinFunction::BuiltinFunction(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *)) - : Heap::FunctionObject(scope, name) - , code(code) +void Heap::BuiltinFunction::init(QV4::ExecutionContext *scope, QV4::String *name, ReturnedValue (*code)(QV4::CallContext *)) { + Heap::FunctionObject::init(scope, name); + this->code = code; } void BuiltinFunction::construct(const Managed *f, Scope &scope, CallData *) @@ -656,10 +666,10 @@ DEFINE_OBJECT_VTABLE(IndexedBuiltinFunction); DEFINE_OBJECT_VTABLE(BoundFunction); -Heap::BoundFunction::BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionObject *target, - const Value &boundThis, QV4::MemberData *boundArgs) - : Heap::FunctionObject(scope, QStringLiteral("__bound function__")) +void Heap::BoundFunction::init(QV4::ExecutionContext *scope, QV4::FunctionObject *target, + const Value &boundThis, QV4::MemberData *boundArgs) { + Heap::FunctionObject::init(scope, QStringLiteral("__bound function__")); this->target = target->d(); this->boundArgs = boundArgs ? boundArgs->d() : 0; this->boundThis = boundThis; |