diff options
author | Lars Knoll <lars.knoll@qt.io> | 2017-08-08 10:56:34 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-08-10 08:19:18 +0000 |
commit | 5bc4f4d958a3b76f3435d61206ca0109f07aa1a3 (patch) | |
tree | cb2ef4772f2d343e9957271161ac32809bc5d0a6 /src/qml/jsruntime/qv4globalobject.cpp | |
parent | 30e3664bf3668bda9a211fe7d1404f8f806dbf7b (diff) |
Refactor context handling
Fix the push/pop context instructions to not modify the JS
stack anymore, as that can cause conflicts with the VME
(and was an ugly hack in any case). Instead, these instructions
not return the old context, that is then stored in a temporary.
Get rid of Engine::current and Engine::currentContext. The
StackFrame structures do now contain the only and authoritive
data. This finally gives us a nice setup where we create and
destroy frames on the stack when entering/leaving functions.
Change-Id: If161e3e941f59865c47ecfe1e094faf62b52bfa0
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4globalobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4globalobject.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index f210ff2659..761a8282ae 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -343,16 +343,14 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const return Encode::undefined(); ExecutionEngine *v4 = engine(); - Scope scope(v4); - ExecutionContextSaver ctxSaver(scope.engine); + bool isStrict = v4->currentContext()->d()->v4Function->isStrict(); - ExecutionContext *currentContext = v4->currentContext; - ExecutionContext *ctx = currentContext; + Scope scope(v4); + ScopedContext ctx(scope, v4->currentContext()); if (!directCall) { - // the context for eval should be the global scope, so we fake a root - // context - ctx = v4->pushGlobalContext(); + // the context for eval should be the global scope + ctx = v4->rootContext(); } String *scode = callData->args[0].stringValue(); @@ -363,7 +361,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const bool inheritContext = !ctx->d()->v4Function->isStrict(); Script script(ctx, code, QStringLiteral("eval code")); - script.strictMode = (directCall && currentContext->d()->v4Function->isStrict()); + script.strictMode = (directCall && isStrict); script.inheritContext = inheritContext; script.parse(); if (v4->hasException) @@ -385,7 +383,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const // set the correct v4 function for the context ctx->d()->v4Function = function; - return Q_V4_PROFILE(ctx->engine(), function, 0); + return Q_V4_PROFILE(v4, ctx->d(), function, 0); } |