diff options
author | Lars Knoll <lars.knoll@qt.io> | 2018-09-18 11:05:38 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2018-09-23 17:27:39 +0000 |
commit | 3440b8f9c5b198be4124ee1defd69d807bb972c6 (patch) | |
tree | 6d7f726be8c0a73647afc63fe2c8778fa778249d /src/qml/jsruntime/qv4functionobject.cpp | |
parent | 3ff776b74e3d9c0af911e331cdb649fd3fa0dd09 (diff) |
Cleanup init method for ScriptFunction
Change-Id: I913f9429a9238860a5b4e9dc84d217ec824f25c1
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index b4d68717d3..8a674bc7fa 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -508,7 +508,7 @@ ReturnedValue ScriptFunction::virtualCall(const FunctionObject *fo, const Value return result; } -void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function, QV4::String *n, bool makeConstructor) +void Heap::ScriptFunction::initNoConstructor(QV4::ExecutionContext *scope, Function *function, QV4::String *n) { FunctionObject::init(); this->scope.set(scope->engine(), scope->d()); @@ -522,13 +522,22 @@ void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function ScopedString name(s, n ? n->d() : function->name()); if (name) f->setName(name); - if (makeConstructor && !function->isArrowFunction()) - f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_ProtoConstructor); Q_ASSERT(internalClass && internalClass->find(s.engine->id_length()->propertyKey()) == Index_Length); setProperty(s.engine, Index_Length, Value::fromInt32(int(function->compiledFunction->length))); } +void Heap::ScriptFunction::init(QV4::ExecutionContext *scope, Function *function) +{ + initNoConstructor(scope, function, nullptr); + if (function->isArrowFunction()) + return; + + Scope s(scope); + ScopedFunctionObject f(s, this); + f->createDefaultPrototypeProperty(Heap::FunctionObject::Index_ProtoConstructor); +} + Heap::InternalClass *ScriptFunction::classForConstructor() const { Scope scope(engine()); |