diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-22 14:30:57 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-22 15:50:11 +0200 |
commit | a12cc118ddce1615425ddf12296584d34acf57cc (patch) | |
tree | 342e2a8a5cad4594bc177a2d93b9c06873bff45a | |
parent | 54d8facf66d668d8cea1184f7f24928e97497ae1 (diff) |
Replace usage of v8::Script and qmlModeCompile with QV4::Script
Change-Id: I114a0b7faed39be313cde5617a0ce4a06dece7e2
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 45 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmltypeloader_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlvme.cpp | 21 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4globalobject.cpp | 14 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4script.cpp | 86 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4script_p.h | 11 | ||||
-rw-r--r-- | src/qml/qml/v8/qjsengine.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8bindings.cpp | 24 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8contextwrapper.cpp | 16 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8contextwrapper_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8include.cpp | 13 | ||||
-rw-r--r-- | src/qml/types/qquickworkerscript.cpp | 29 |
13 files changed, 122 insertions, 150 deletions
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index bd74fd1471..b64035b66d 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -44,6 +44,7 @@ #include <private/qqmlexpression_p.h> #include <private/qv4value_p.h> #include <private/qv4functionobject_p.h> +#include <private/qv4script_p.h> QT_BEGIN_NAMESPACE @@ -312,33 +313,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope, const QString &filename, quint16 line, QV4::PersistentValue *qmlscope) { - QQmlEngine *engine = ctxt->engine; - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); - - QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); - QV4::ExecutionContext *ctx = v4->current; - - v8::Handle<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope); - v8::Handle<v8::Script> script = ep->v8engine()->qmlModeCompile(code, codeLength, filename, line); - v8::Handle<v8::Value> result; - try { - result = script->Run(scopeobject); - } catch (QV4::Exception &e) { - e.accept(ctx); - QQmlError error; - QQmlExpressionPrivate::exceptionToError(e, error); - if (error.description().isEmpty()) - error.setDescription(QLatin1String("Exception occurred during function evaluation")); - if (error.line() == -1) - error.setLine(line); - if (error.url().isEmpty()) - error.setUrl(QUrl::fromLocalFile(filename)); - ep->warning(error); - return QV4::PersistentValue(); - } - if (qmlscope) - *qmlscope = scopeobject->v4Value(); - return result->v4Value(); + return evalFunction(ctxt, scope, QString::fromUtf8(code, codeLength), filename, line, qmlscope); } // Callee owns the persistent handle @@ -353,13 +328,12 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope, QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); QV4::ExecutionContext *ctx = v4->current; - v8::Handle<v8::Object> scopeobject = ep->v8engine()->qmlScope(ctxt, scope); - v8::Handle<v8::Script> script = ep->v8engine()->qmlModeCompile(code, filename, line); + QV4::Value scopeObject = ep->v8engine()->qmlScope(ctxt, scope)->v4Value(); + QV4::Script script(v4, scopeObject.asObject(), code, filename, line); + QV4::Value result; try { - v8::Handle<v8::Value> result = script->Run(scopeobject); - if (qmlscope) - *qmlscope = scopeobject->v4Value(); - return result->v4Value(); + script.parse(); + result = script.run(); } catch (QV4::Exception &e) { e.accept(ctx); QQmlError error; @@ -371,8 +345,11 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope, if (error.url().isEmpty()) error.setUrl(QUrl::fromLocalFile(filename)); ep->warning(error); + return QV4::PersistentValue(); } - return QV4::PersistentValue(); + if (qmlscope) + *qmlscope = scopeObject; + return result; } void QQmlJavaScriptExpression::clearGuards() diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp index db893c1bf4..c91fc06c22 100644 --- a/src/qml/qml/qqmltypeloader.cpp +++ b/src/qml/qml/qqmltypeloader.cpp @@ -2251,12 +2251,13 @@ void QQmlTypeData::scriptImported(QQmlScriptBlob *blob, const QQmlScript::Locati } QQmlScriptData::QQmlScriptData() -: importCache(0), pragmas(QQmlScript::Object::ScriptBlock::None), m_loaded(false) +: importCache(0), pragmas(QQmlScript::Object::ScriptBlock::None), m_loaded(false), m_program(0) { } QQmlScriptData::~QQmlScriptData() { + delete m_program; } void QQmlScriptData::clear() diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h index d59cef61eb..b3998c6f6e 100644 --- a/src/qml/qml/qqmltypeloader_p.h +++ b/src/qml/qml/qqmltypeloader_p.h @@ -70,6 +70,7 @@ #include <private/qflagpointer_p.h> #include <private/qv4value_p.h> +#include <private/qv4script_p.h> QT_BEGIN_NAMESPACE @@ -510,7 +511,7 @@ private: bool m_loaded; QByteArray m_programSource; - QExplicitlySharedDataPointer<v8::Script> m_program; + QV4::Script *m_program; QV4::PersistentValue m_value; QQmlError m_error; }; diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 541176c3c7..d291452b49 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -1164,14 +1164,19 @@ void QQmlScriptData::initialize(QQmlEngine *engine) QQmlEnginePrivate *ep = QQmlEnginePrivate::get(engine); QV8Engine *v8engine = ep->v8engine(); + QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8engine); // If compilation throws an error, a surrounding catch will record it. - v8::Handle<v8::Script> program = v8engine->qmlModeCompile(m_programSource.constData(), - m_programSource.length(), urlString, 1); - if (program.IsEmpty()) - return; + // pass 0 as the QML object, we set it later before calling run() + QV4::Script *program = new QV4::Script(v4, 0, m_programSource, urlString, 1); + try { + program->parse(); + } catch (QV4::Exception &) { + delete program; + throw; + } - m_program = program.get(); + m_program = program; m_programSource.clear(); // We don't need this anymore addToEngine(engine); @@ -1238,12 +1243,16 @@ QV4::PersistentValue QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptData *s if (!script->isInitialized()) script->initialize(parentCtxt->engine); + if (!script->m_program) + return QV4::PersistentValue(); + v8::Handle<v8::Object> qmlglobal = v8engine->qmlScope(ctxt, 0); v8engine->contextWrapper()->takeContextOwnership(qmlglobal); QV4::ExecutionContext *ctx = QV8Engine::getV4(v8engine)->current; try { - script->m_program->Run(qmlglobal); + script->m_program->qml = qmlglobal->v4Value().asObject(); + script->m_program->run(); } catch (QV4::Exception &e) { e.accept(ctx); QQmlError error; diff --git a/src/qml/qml/v4/qv4globalobject.cpp b/src/qml/qml/v4/qv4globalobject.cpp index e56b396b6b..b0e259b30b 100644 --- a/src/qml/qml/v4/qv4globalobject.cpp +++ b/src/qml/qml/v4/qv4globalobject.cpp @@ -377,13 +377,11 @@ Value EvalFunction::evalCall(ExecutionContext *parentContext, Value /*thisObject script.inheritContext = inheritContext; script.parse(); - if (!script.function) - return Value::undefinedValue(); - - strictMode = script.function->isStrict || (ctx->strictMode); + Function *function = script.function(); + strictMode = function->isStrict || (ctx->strictMode); - usesArgumentsObject = script.function->usesArgumentsObject; - needsActivation = script.function->needsActivation(); + usesArgumentsObject = function->usesArgumentsObject; + needsActivation = function->needsActivation(); if (strictMode) { CallContext *k = ctx->engine->newCallContext(this, ctx->thisObject, 0, 0); @@ -391,7 +389,7 @@ Value EvalFunction::evalCall(ExecutionContext *parentContext, Value /*thisObject } ExecutionContext::EvalCode evalCode; - evalCode.function = script.function; + evalCode.function = function; evalCode.next = ctx->currentEvalCode; ctx->currentEvalCode = &evalCode; @@ -401,7 +399,7 @@ Value EvalFunction::evalCall(ExecutionContext *parentContext, Value /*thisObject Value result = Value::undefinedValue(); try { - result = script.function->code(ctx, script.function->codeData); + result = function->code(ctx, function->codeData); } catch (Exception &ex) { ctx->strictMode = cstrict; ctx->currentEvalCode = evalCode.next; diff --git a/src/qml/qml/v4/qv4script.cpp b/src/qml/qml/v4/qv4script.cpp index 3b4456055c..7eef5156b9 100644 --- a/src/qml/qml/v4/qv4script.cpp +++ b/src/qml/qml/v4/qv4script.cpp @@ -58,14 +58,27 @@ using namespace QV4; +struct FunctionWrapper : FunctionObject +{ + FunctionWrapper(ExecutionContext *scope, Function *f) + : FunctionObject(scope, scope->engine->id_eval) + { + function = f; + usesArgumentsObject = function->usesArgumentsObject; + needsActivation = function->needsActivation(); + defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1)); + } +}; + void Script::parse() { using namespace QQmlJS; - MemoryManager::GCBlocker gcBlocker(scope->engine->memoryManager); + ExecutionEngine *v4 = scope->engine; + + MemoryManager::GCBlocker gcBlocker(v4->memoryManager); - ExecutionEngine *vm = scope->engine; V4IR::Module module; Function *globalCode = 0; @@ -113,7 +126,7 @@ void Script::parse() Codegen cg(scope, strictMode); V4IR::Function *globalIRCode = cg(sourceFile, sourceCode, program, &module, QQmlJS::Codegen::EvalCode, inheritedLocals); - QScopedPointer<EvalInstructionSelection> isel(scope->engine->iselFactory->create(vm, &module)); + QScopedPointer<EvalInstructionSelection> isel(v4->iselFactory->create(v4, &module)); if (inheritContext) isel->setUseFastLookups(false); if (globalIRCode) @@ -124,64 +137,39 @@ void Script::parse() // ### should be a syntax error scope->throwTypeError(); } + if (!globalCode) + // ### FIX file/line number + __qmljs_throw(v4->current, QV4::Value::fromObject(v4->newSyntaxErrorObject(v4->current, 0)), -1); - function = globalCode; + functionWrapper = Value::fromObject(new (v4->memoryManager) FunctionWrapper(scope, globalCode)); } -struct QmlFunction : FunctionObject -{ - QmlFunction(ExecutionContext *scope) - : FunctionObject(scope, scope->engine->id_eval) - { - defineReadonlyProperty(scope->engine->id_length, Value::fromInt32(1)); - } -}; - Value Script::run() { - QV4::ExecutionEngine *engine = scope->engine; - - if (!function) - // ### FIX file/line number - __qmljs_throw(engine->current, QV4::Value::fromObject(engine->newSyntaxErrorObject(engine->current, 0)), -1); - - if (!qml) { - TemporaryAssignment<Function*> savedGlobalCode(engine->globalCode, function); + if (functionWrapper.isEmpty()) + parse(); - bool strict = scope->strictMode; - Lookup *lookups = scope->lookups; - - scope->strictMode = function->isStrict; - scope->lookups = function->lookups; + QV4::ExecutionEngine *engine = scope->engine; + QV4::FunctionObject *f = functionWrapper.value().asFunctionObject(); - if (engine->debugger) - engine->debugger->aboutToCall(0, scope); + if (engine->debugger) + engine->debugger->aboutToCall(0, scope); - QV4::Value result; - try { - result = function->code(scope, function->codeData); - } catch (Exception &e) { - scope->strictMode = strict; - scope->lookups = lookups; - throw; - } + quintptr stackSpace[stackContextSize/sizeof(quintptr)]; + ExecutionContext *ctx = qml ? engine->newQmlContext(f, qml) : engine->newCallContext(stackSpace, f, Value::undefinedValue(), 0, 0); - if (engine->debugger) - engine->debugger->justLeft(scope); - return result; - } else { - QmlFunction *f = new (engine->memoryManager) QmlFunction(scope); - f->function = function; - f->usesArgumentsObject = function->usesArgumentsObject; - f->needsActivation = function->needsActivation(); + Value result = f->function->code(ctx, f->function->codeData); - CallContext *ctx = engine->newQmlContext(f, qml); + engine->popContext(); - Value result = function->code(ctx, function->codeData); + if (engine->debugger) + engine->debugger->justLeft(scope); - engine->popContext(); + return result; +} - return result; - } +Function *Script::function() +{ + return functionWrapper.value().asFunctionObject()->function; } diff --git a/src/qml/qml/v4/qv4script_p.h b/src/qml/qml/v4/qv4script_p.h index 442b4fd071..ef67681d0e 100644 --- a/src/qml/qml/v4/qv4script_p.h +++ b/src/qml/qml/v4/qv4script_p.h @@ -51,12 +51,12 @@ namespace QV4 { struct ExecutionContext; struct Script { - Script(ExecutionContext *scope, const QString &sourceCode, const QString &source, int line = 0, int column = 0) + Script(ExecutionContext *scope, const QString &sourceCode, const QString &source = QString(), int line = 0, int column = 0) : sourceFile(source), line(line), column(column), sourceCode(sourceCode) - , scope(scope), strictMode(false), inheritContext(false), qml(0), function(0) {} - Script(ExecutionEngine *engine, Object *qml, const QString &sourceCode, const QString &source, int line = 0, int column = 0) + , scope(scope), strictMode(false), inheritContext(false), qml(0) {} + Script(ExecutionEngine *engine, Object *qml, const QString &sourceCode, const QString &source = QString(), int line = 0, int column = 0) : sourceFile(source), line(line), column(column), sourceCode(sourceCode) - , scope(engine->rootContext), strictMode(true), inheritContext(true), qml(qml), function(0) {} + , scope(engine->rootContext), strictMode(true), inheritContext(true), qml(qml) {} QString sourceFile; int line; int column; @@ -65,10 +65,11 @@ struct Script { bool strictMode; bool inheritContext; Object *qml; - Function *function; + PersistentValue functionWrapper; void parse(); Value run(); + Function *function(); }; } diff --git a/src/qml/qml/v8/qjsengine.cpp b/src/qml/qml/v8/qjsengine.cpp index 1e3713e5e0..50e826522b 100644 --- a/src/qml/qml/v8/qjsengine.cpp +++ b/src/qml/qml/v8/qjsengine.cpp @@ -261,9 +261,6 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in script.strictMode = ctx->strictMode; script.inheritContext = true; script.parse(); - if (!script.function) - return QJSValue(); - QV4::Value result = script.run(); return new QJSValuePrivate(d->m_v4Engine, result); } catch (QV4::Exception& ex) { diff --git a/src/qml/qml/v8/qv8bindings.cpp b/src/qml/qml/v8/qv8bindings.cpp index 4806762223..9bdc25e949 100644 --- a/src/qml/qml/v8/qv8bindings.cpp +++ b/src/qml/qml/v8/qv8bindings.cpp @@ -51,6 +51,7 @@ #include <private/qqmlprofilerservice_p.h> #include <private/qv4object_p.h> +#include <private/qv4script_p.h> QT_BEGIN_NAMESPACE @@ -246,20 +247,19 @@ QV8Bindings::QV8Bindings(QQmlCompiledData::V8Program *program, QV8Engine *engine = QQmlEnginePrivate::getV8Engine(context->engine); if (program->bindings.isEmpty()) { - v8::Handle<v8::Script> script; - bool compileFailed = false; - { - const QByteArray &source = program->program; - script = engine->qmlModeCompile(source.constData(), source.length(), - program->cdata->name, line); - } - - if (!compileFailed) { - v8::Handle<v8::Value> result = script->Run(engine->contextWrapper()->sharedContext()); - if (result->IsArray()) { - program->bindings = result->v4Value(); + QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); + QString sourceCode = program->program; + QV4::Script script(v4, engine->contextWrapper()->sharedContext().asObject(), sourceCode, program->cdata->name, line); + QV4::ExecutionContext *ctx = v4->current; + try { + script.parse(); + QV4::Value result = script.run(); + if (result.asArrayObject()) { + program->bindings = result; program->program.clear(); // We don't need the source anymore } + } catch (QV4::Exception &e) { + e.accept(ctx); } } diff --git a/src/qml/qml/v8/qv8contextwrapper.cpp b/src/qml/qml/v8/qv8contextwrapper.cpp index fe4bfb8463..b24b71ee29 100644 --- a/src/qml/qml/v8/qv8contextwrapper.cpp +++ b/src/qml/qml/v8/qv8contextwrapper.cpp @@ -200,14 +200,14 @@ void QV8ContextWrapper::setReadOnly(v8::Handle<v8::Object> qmlglobal, bool readO resource->readOnly = readOnly; } -void QV8ContextWrapper::addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script> script, - QQmlContextData *ctxt) -{ - QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(qmlglobal); - Q_ASSERT(resource); - resource->hasSubContexts = true; - script->SetData(v8::String::NewExternal(new QV8ContextResource::SubContext(ctxt))); -} +//void QV8ContextWrapper::addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script> script, +// QQmlContextData *ctxt) +//{ +// QV8ContextResource *resource = v8_resource_cast<QV8ContextResource>(qmlglobal); +// Q_ASSERT(resource); +// resource->hasSubContexts = true; +// script->SetData(v8::String::NewExternal(new QV8ContextResource::SubContext(ctxt))); +//} QQmlContextData *QV8ContextWrapper::callingContext() { diff --git a/src/qml/qml/v8/qv8contextwrapper_p.h b/src/qml/qml/v8/qv8contextwrapper_p.h index be62a0bb68..57eb46de44 100644 --- a/src/qml/qml/v8/qv8contextwrapper_p.h +++ b/src/qml/qml/v8/qv8contextwrapper_p.h @@ -79,8 +79,8 @@ public: void setReadOnly(v8::Handle<v8::Object>, bool); - void addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script>, - QQmlContextData *ctxt); +// void addSubContext(v8::Handle<v8::Object> qmlglobal, v8::Handle<v8::Script>, +// QQmlContextData *ctxt); QQmlContextData *callingContext(); QQmlContextData *context(v8::Handle<v8::Value>); diff --git a/src/qml/qml/v8/qv8include.cpp b/src/qml/qml/v8/qv8include.cpp index 018aaf5823..7a6b241535 100644 --- a/src/qml/qml/v8/qv8include.cpp +++ b/src/qml/qml/v8/qv8include.cpp @@ -50,6 +50,7 @@ #include <private/qqmlengine_p.h> #include <private/qv4engine_p.h> #include <private/qv4functionobject_p.h> +#include <private/qv4script_p.h> QT_BEGIN_NAMESPACE @@ -144,13 +145,14 @@ void QV8Include::finished() importContext->isPragmaLibraryContext = m_context->isPragmaLibraryContext; importContext->setParent(m_context, true); - v8::Handle<v8::Script> script = m_engine->qmlModeCompile(code, m_url.toString()); + QV4::Script script(QV8Engine::getV4(m_engine), m_qmlglobal.value().asObject(), code, m_url.toString()); QV4::ExecutionContext *ctx = QV8Engine::getV4(m_engine)->current; // ### Only used for debugging info //m_engine->contextWrapper()->addSubContext(m_qmlglobal.value(), script, importContext); try { - script->Run(m_qmlglobal.value()); + script.parse(); + script.run(); v8::Handle<v8::Object>(m_resultObject)->Set(v8::String::New("status"), QV4::Value::fromInt32(Ok)); } catch (QV4::Exception &e) { e.accept(ctx); @@ -213,14 +215,15 @@ QV4::Value QV8Include::include(const v8::Arguments &args) importContext->url = url; importContext->setParent(context, true); - v8::Handle<v8::Script> script = engine->qmlModeCompile(code, url.toString()); + QV4::Object *qmlglobal = args.GetIsolate()->GetEngine()->qmlContextObject(); + QV4::Script script(QV8Engine::getV4(engine), qmlglobal, code, url.toString()); - v8::Handle<v8::Object> qmlglobal = QV4::Value::fromObject(args.GetIsolate()->GetEngine()->qmlContextObject()); // ### Only used for debugging info // engine->contextWrapper()->addSubContext(qmlglobal, script, importContext); QV4::ExecutionContext *ctx = QV8Engine::getV4(engine)->current; try { - script->Run(qmlglobal); + script.parse(); + script.run(); result = resultValue(Ok); } catch (QV4::Exception &e) { e.accept(ctx); diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 9f31b711d0..1dce932dad 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -63,6 +63,7 @@ #include <private/qv4value_p.h> #include <private/qv4functionobject_p.h> +#include <private/qv4script_p.h> QT_BEGIN_NAMESPACE @@ -224,21 +225,14 @@ void QQuickWorkerScriptEnginePrivate::WorkerEngine::init() "}); "\ "})" - { - v8::Handle<v8::Script> onmessagescript = v8::Script::New(v8::String::New(CALL_ONMESSAGE_SCRIPT)); - onmessage = onmessagescript->Run()->v4Value(); - } - { - v8::Handle<v8::Script> createsendscript = v8::Script::New(v8::String::New(SEND_MESSAGE_CREATE_SCRIPT)); - v8::Handle<v8::Function> createsendconstructor = v8::Handle<v8::Function>::Cast(createsendscript->Run()); + onmessage = QV4::Script(m_v4Engine->rootContext, CALL_ONMESSAGE_SCRIPT).run(); + QV4::Script createsendscript(m_v4Engine->rootContext, SEND_MESSAGE_CREATE_SCRIPT); + QV4::FunctionObject *createsendconstructor = createsendscript.run().asFunctionObject(); - v8::Handle<v8::Value> args[] = { - V8FUNCTION(QQuickWorkerScriptEnginePrivate::sendMessage, this) + QV4::Value args[] = { + V8FUNCTION(QQuickWorkerScriptEnginePrivate::sendMessage, this)->v4Value() }; - v8::Handle<v8::Value> createsendvalue = createsendconstructor->Call(global(), 1, args); - - createsend = createsendvalue->v4Value(); - } + createsend = createsendconstructor->call(global(), args, 1); } // Requires handle and context scope @@ -384,11 +378,14 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url) // XXX ??? // workerEngine->baseUrl = url; - v8::Handle<v8::Script> program = workerEngine->qmlModeCompile(sourceCode, url.toString()); + QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine); + + QV4::Script program(v4, activation.asObject(), sourceCode, url.toString()); - QV4::ExecutionContext *ctx = QV8Engine::getV4(workerEngine)->current; + QV4::ExecutionContext *ctx = v4->current; try { - program->Run(activation); + program.parse(); + program.run(); } catch (QV4::Exception &e) { e.accept(ctx); QQmlError error; |