diff options
author | Lars Knoll <lars.knoll@qt.io> | 2016-11-30 15:35:16 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2016-12-09 08:30:51 +0000 |
commit | 55101d6937880f4dfd8d8eb79fbb15a8e7bb508a (patch) | |
tree | c43905119590ac7b99da1471086fca86a6032acd /src | |
parent | 9f4cfec74517f7ff3f65037ad04abac33e2104ba (diff) |
Move the check whether a function is simple to QV4::Function
This allows re-using the check in the QQmlJavascriptExpression code.
Change-Id: I647a6edb4844911f540f08c4a067d055676dd0ed
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4function_p.h | 9 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index beba5a1fd6..802af43cdc 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -91,6 +91,15 @@ struct Q_QML_EXPORT Function { inline bool needsActivation() const { return activationRequired; } + inline bool canUseSimpleFunction() const { + if (needsActivation() || + compiledFunction->flags & CompiledData::Function::HasCatchOrWith || + compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || + isNamedExpression()) + return false; + return true; + } + QQmlSourceLocation sourceLocation() const { return QQmlSourceLocation(sourceFile(), compiledFunction->location.line, compiledFunction->location.column); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 66549ffd3e..21edf1d8d3 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -195,12 +195,9 @@ void FunctionObject::markObjects(Heap::Base *that, ExecutionEngine *e) Heap::FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Function *function, bool createProto) { - if (function->needsActivation() || - function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith || - function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || - function->isNamedExpression()) - return scope->d()->engine->memoryManager->allocObject<ScriptFunction>(scope, function); - return scope->d()->engine->memoryManager->allocObject<SimpleScriptFunction>(scope, function, createProto); + if (function->canUseSimpleFunction()) + return scope->d()->engine->memoryManager->allocObject<SimpleScriptFunction>(scope, function, createProto); + return scope->d()->engine->memoryManager->allocObject<ScriptFunction>(scope, function); } Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlContext, QObject *scopeObject, Function *runtimeFunction, const QList<QByteArray> &signalParameters, QString *error) |