diff options
author | Liang Qi <liang.qi@qt.io> | 2016-12-14 19:01:23 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-12-14 19:01:23 +0100 |
commit | 0e80d28aa5892d6bbb4d0017b1bc9a33489f4176 (patch) | |
tree | 0db2e10c8776d172bccaeaa7ee1fab3934b93073 /src/qml/jsruntime/qv4script.cpp | |
parent | ed32558d6280cae40578f735fd326327d571d993 (diff) | |
parent | 16c81bb0d493af00bc376784bcb7e03a4a037b04 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp
src/plugins/qmltooling/qmldbg_inspector/globalinspector.cpp
src/plugins/qmltooling/qmldbg_nativedebugger/qqmlnativedebugservice.cpp
src/qml/qml/qqmlimport.cpp
src/quick/items/context2d/qquickcontext2dtexture_p.h
tools/qmleasing/splineeditor.h
Change-Id: I8f6630fcac243824350986c8e9f4bd6483bf20b5
Diffstat (limited to 'src/qml/jsruntime/qv4script.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 76 |
1 files changed, 4 insertions, 72 deletions
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 552171256f..b54177bee9 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -54,71 +54,12 @@ #include <private/qv4profiling_p.h> #include <qv4jsir_p.h> #include <qv4codegen_p.h> -#include <private/qqmlcontextwrapper_p.h> #include <QtCore/QDebug> #include <QtCore/QString> -QT_BEGIN_NAMESPACE - -namespace QV4 { -namespace Heap { - -struct QmlBindingWrapper : FunctionObject { - void init(QV4::QmlContext *scope, Function *f); -}; - -} - -struct QmlBindingWrapper : FunctionObject { - V4_OBJECT2(QmlBindingWrapper, FunctionObject) - - static void call(const Managed *that, Scope &scope, CallData *callData); -}; - -} - -QT_END_NAMESPACE - using namespace QV4; -DEFINE_OBJECT_VTABLE(QmlBindingWrapper); - -void Heap::QmlBindingWrapper::init(QV4::QmlContext *scope, Function *f) -{ - Heap::FunctionObject::init(scope, scope->d()->engine->id_eval(), /*createProto = */ false); - - Q_ASSERT(scope->inUse()); - - function = f; - if (function) - function->compilationUnit->addref(); -} - -void QmlBindingWrapper::call(const Managed *that, Scope &scope, CallData *callData) -{ - const QmlBindingWrapper *This = static_cast<const QmlBindingWrapper *>(that); - ExecutionEngine *v4 = static_cast<const Object *>(that)->engine(); - if (v4->hasException) { - scope.result = Encode::undefined(); - return; - } - CHECK_STACK_LIMITS(v4, scope); - - ExecutionContextSaver ctxSaver(scope); - - QV4::Function *f = This->function(); - if (!f) { - scope.result = QV4::Encode::undefined(); - return; - } - - Scoped<CallContext> ctx(scope, v4->currentContext->newCallContext(This, callData)); - v4->pushContext(ctx); - - scope.result = Q_V4_PROFILE(v4, f); -} - Script::Script(ExecutionEngine *v4, QmlContext *qml, CompiledData::CompilationUnit *compilationUnit) : line(0), column(0), scope(v4->rootContext()), strictMode(false), inheritContext(true), parsed(false) , compilationUnit(compilationUnit), vmFunction(0), parseAsBinding(true) @@ -230,10 +171,12 @@ ReturnedValue Script::run() return Q_V4_PROFILE(engine, vmFunction); } else { Scoped<QmlContext> qml(valueScope, qmlContext.value()); - ScopedFunctionObject f(valueScope, engine->memoryManager->allocObject<QmlBindingWrapper>(qml, vmFunction)); ScopedCallData callData(valueScope); callData->thisObject = Primitive::undefinedValue(); - f->call(valueScope, callData); + if (vmFunction->canUseSimpleFunction()) + qml->simpleCall(valueScope, callData, vmFunction); + else + qml->call(valueScope, callData, vmFunction); return valueScope.result.asReturnedValue(); } } @@ -303,17 +246,6 @@ QQmlRefPointer<QV4::CompiledData::CompilationUnit> Script::precompile(IR::Module return isel->compile(/*generate unit data*/false); } -ReturnedValue Script::qmlBinding() -{ - if (!parsed) - parse(); - ExecutionEngine *v4 = scope->engine(); - Scope valueScope(v4); - Scoped<QmlContext> qml(valueScope, qmlContext.value()); - ScopedObject v(valueScope, v4->memoryManager->allocObject<QmlBindingWrapper>(qml, vmFunction)); - return v.asReturnedValue(); -} - QV4::ReturnedValue Script::evaluate(ExecutionEngine *engine, const QString &script, QmlContext *qmlContext) { QV4::Scope scope(engine); |