diff options
Diffstat (limited to 'src/qml/jsruntime/qv4stackframe_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4stackframe_p.h | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h index 2777d79c31..f24b0b2433 100644 --- a/src/qml/jsruntime/qv4stackframe_p.h +++ b/src/qml/jsruntime/qv4stackframe_p.h @@ -14,6 +14,7 @@ // We mean it. // +#include <private/qv4scopedvalue_p.h> #include <private/qv4context_p.h> #include <private/qv4enginebase_p.h> #include <private/qv4calldata_p.h> @@ -26,7 +27,7 @@ QT_BEGIN_NAMESPACE namespace QV4 { struct CppStackFrame; -struct Q_QML_PRIVATE_EXPORT CppStackFrameBase +struct Q_QML_EXPORT CppStackFrameBase { enum class Kind : quint8 { JS, Meta }; @@ -35,6 +36,8 @@ struct Q_QML_PRIVATE_EXPORT CppStackFrameBase int originalArgumentsCount; int instructionPointer; + QT_WARNING_PUSH + QT_WARNING_DISABLE_MSVC(4201) // nonstandard extension used: nameless struct/union union { struct { Value *savedStackTop; @@ -57,11 +60,12 @@ struct Q_QML_PRIVATE_EXPORT CppStackFrameBase bool returnValueIsUndefined; }; }; + QT_WARNING_POP Kind kind; }; -struct Q_QML_PRIVATE_EXPORT CppStackFrame : protected CppStackFrameBase +struct Q_QML_EXPORT CppStackFrame : protected CppStackFrameBase { // We want to have those public but we can't declare them as public without making the struct // non-standard layout. So we have this other struct with "using" in between. @@ -83,6 +87,8 @@ struct Q_QML_PRIVATE_EXPORT CppStackFrame : protected CppStackFrameBase int lineNumber() const; int statementNumber() const; + int missingLineNumber() const; + CppStackFrame *parentFrame() const { return parent; } void setParentFrame(CppStackFrame *parentFrame) { parent = parentFrame; } @@ -116,7 +122,7 @@ protected: } }; -struct Q_QML_PRIVATE_EXPORT MetaTypesStackFrame : public CppStackFrame +struct Q_QML_EXPORT MetaTypesStackFrame : public CppStackFrame { using CppStackFrame::push; using CppStackFrame::pop; @@ -141,6 +147,9 @@ struct Q_QML_PRIVATE_EXPORT MetaTypesStackFrame : public CppStackFrame const QMetaType *argTypes() const { return metaTypes + 1; } void **argv() const { return returnAndArgs + 1; } + const QMetaType *returnAndArgTypes() const { return metaTypes; } + void **returnAndArgValues() const { return returnAndArgs; } + QObject *thisObject() const { return CppStackFrameBase::thisObject; } ExecutionContext *context() const { return CppStackFrameBase::context; } @@ -152,7 +161,7 @@ struct Q_QML_PRIVATE_EXPORT MetaTypesStackFrame : public CppStackFrame } }; -struct Q_QML_PRIVATE_EXPORT JSTypesStackFrame : public CppStackFrame +struct Q_QML_EXPORT JSTypesStackFrame : public CppStackFrame { using CppStackFrame::jsFrame; @@ -285,6 +294,30 @@ inline ExecutionContext *CppStackFrame::context() const return static_cast<const MetaTypesStackFrame *>(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<CppStackFrame>); |