1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QV4DEBUGJOB_H
5#define QV4DEBUGJOB_H
6
7#include "qv4datacollector.h"
8#include <private/qv4engine_p.h>
9
10#include <QtCore/qjsonarray.h>
11#include <QtCore/qjsonobject.h>
12
13QT_BEGIN_NAMESPACE
14
15class QV4DataCollector;
16class QV4DebugJob
17{
18public:
19 virtual ~QV4DebugJob();
20 virtual void run() = 0;
21};
22
23class JavaScriptJob : public QV4DebugJob
24{
25 QV4::ExecutionEngine *engine;
26 int frameNr;
27 int context;
28 const QString &script;
29 bool resultIsException;
30
31public:
32 JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, int context, const QString &script);
33 void run() override;
34 bool hasExeption() const;
35
36protected:
37 virtual void handleResult(QV4::ScopedValue &result) = 0;
38};
39
40class CollectJob : public QV4DebugJob
41{
42protected:
43 QV4DataCollector *collector;
44 QJsonObject result;
45
46public:
47 CollectJob(QV4DataCollector *collector) : collector(collector) {}
48 const QJsonObject &returnValue() const { return result; }
49};
50
51class BacktraceJob: public CollectJob
52{
53 int fromFrame;
54 int toFrame;
55public:
56 BacktraceJob(QV4DataCollector *collector, int fromFrame, int toFrame);
57 void run() override;
58};
59
60class FrameJob: public CollectJob
61{
62 int frameNr;
63 bool success;
64
65public:
66 FrameJob(QV4DataCollector *collector, int frameNr);
67 void run() override;
68 bool wasSuccessful() const;
69};
70
71class ScopeJob: public CollectJob
72{
73 int frameNr;
74 int scopeNr;
75 bool success;
76
77public:
78 ScopeJob(QV4DataCollector *collector, int frameNr, int scopeNr);
79 void run() override;
80 bool wasSuccessful() const;
81};
82
83class ValueLookupJob: public CollectJob
84{
85 const QJsonArray handles;
86 QString exception;
87
88public:
89 ValueLookupJob(const QJsonArray &handles, QV4DataCollector *collector);
90 void run() override;
91 const QString &exceptionMessage() const;
92};
93
94class ExpressionEvalJob: public JavaScriptJob
95{
96 QV4DataCollector *collector;
97 QString exception;
98 QJsonObject result;
99
100public:
101 ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, int context,
102 const QString &expression, QV4DataCollector *collector);
103 void handleResult(QV4::ScopedValue &value) override;
104 const QString &exceptionMessage() const;
105 const QJsonObject &returnValue() const;
106};
107
108class GatherSourcesJob: public QV4DebugJob
109{
110 QV4::ExecutionEngine *engine;
111 QStringList sources;
112
113public:
114 GatherSourcesJob(QV4::ExecutionEngine *engine);
115 void run() override;
116 const QStringList &result() const;
117};
118
119class EvalJob: public JavaScriptJob
120{
121 bool result;
122
123public:
124 EvalJob(QV4::ExecutionEngine *engine, const QString &script);
125
126 void handleResult(QV4::ScopedValue &result) override;
127 bool resultAsBoolean() const;
128};
129
130QT_END_NAMESPACE
131
132#endif // QV4DEBUGJOB_H
133
134

source code of qtdeclarative/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.h