From d83c35a2e6216d2568f005c2260a06991134d8cf Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 15 May 2023 09:23:03 +0200 Subject: Move ScopedStackFrame into qv4stackframe_p.h This is where it belongs. We need to apply some tricks to avoid cyclic includes, but that's better than what we have so far. Also, sort and clean up the includes in the affected files. Change-Id: Ia7a957d06c0ca284045d831417740c3f9920bc92 Reviewed-by: Fabian Kosmale Reviewed-by: Qt CI Bot --- src/qml/jsruntime/qv4stackframe_p.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/qml/jsruntime/qv4stackframe_p.h') diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h index 9c3e3700ce..3effd3c236 100644 --- a/src/qml/jsruntime/qv4stackframe_p.h +++ b/src/qml/jsruntime/qv4stackframe_p.h @@ -14,6 +14,7 @@ // We mean it. // +#include #include #include #include @@ -287,6 +288,30 @@ inline ExecutionContext *CppStackFrame::context() const return static_cast(this)->context(); } +struct ScopedStackFrame +{ + ScopedStackFrame(const Scope &scope, ExecutionContext *context) + : engine(scope.engine) + { + if (auto currentFrame = engine->currentStackFrame) { + frame.init(currentFrame->v4Function, nullptr, context, nullptr, nullptr, 0); + frame.instructionPointer = currentFrame->instructionPointer; + } else { + frame.init(nullptr, nullptr, context, nullptr, nullptr, 0); + } + frame.push(engine); + } + + ~ScopedStackFrame() + { + frame.pop(engine); + } + +private: + ExecutionEngine *engine = nullptr; + MetaTypesStackFrame frame; +}; + Q_STATIC_ASSERT(sizeof(CppStackFrame) == sizeof(JSTypesStackFrame)); Q_STATIC_ASSERT(sizeof(CppStackFrame) == sizeof(MetaTypesStackFrame)); Q_STATIC_ASSERT(std::is_standard_layout_v); -- cgit v1.2.3