1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtQml module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QV4DEBUGJOB_H |
41 | #define QV4DEBUGJOB_H |
42 | |
43 | #include "qv4datacollector.h" |
44 | #include <private/qv4engine_p.h> |
45 | |
46 | #include <QtCore/qjsonarray.h> |
47 | #include <QtCore/qjsonobject.h> |
48 | |
49 | QT_BEGIN_NAMESPACE |
50 | |
51 | class QV4DataCollector; |
52 | class QV4DebugJob |
53 | { |
54 | public: |
55 | virtual ~QV4DebugJob(); |
56 | virtual void run() = 0; |
57 | }; |
58 | |
59 | class JavaScriptJob : public QV4DebugJob |
60 | { |
61 | QV4::ExecutionEngine *engine; |
62 | int frameNr; |
63 | int context; |
64 | const QString &script; |
65 | bool resultIsException; |
66 | |
67 | public: |
68 | JavaScriptJob(QV4::ExecutionEngine *engine, int frameNr, int context, const QString &script); |
69 | void run() override; |
70 | bool hasExeption() const; |
71 | |
72 | protected: |
73 | virtual void handleResult(QV4::ScopedValue &result) = 0; |
74 | }; |
75 | |
76 | class CollectJob : public QV4DebugJob |
77 | { |
78 | protected: |
79 | QV4DataCollector *collector; |
80 | QJsonObject result; |
81 | |
82 | public: |
83 | CollectJob(QV4DataCollector *collector) : collector(collector) {} |
84 | const QJsonObject &returnValue() const { return result; } |
85 | }; |
86 | |
87 | class BacktraceJob: public CollectJob |
88 | { |
89 | int fromFrame; |
90 | int toFrame; |
91 | public: |
92 | BacktraceJob(QV4DataCollector *collector, int fromFrame, int toFrame); |
93 | void run() override; |
94 | }; |
95 | |
96 | class FrameJob: public CollectJob |
97 | { |
98 | int frameNr; |
99 | bool success; |
100 | |
101 | public: |
102 | FrameJob(QV4DataCollector *collector, int frameNr); |
103 | void run() override; |
104 | bool wasSuccessful() const; |
105 | }; |
106 | |
107 | class ScopeJob: public CollectJob |
108 | { |
109 | int frameNr; |
110 | int scopeNr; |
111 | bool success; |
112 | |
113 | public: |
114 | ScopeJob(QV4DataCollector *collector, int frameNr, int scopeNr); |
115 | void run() override; |
116 | bool wasSuccessful() const; |
117 | }; |
118 | |
119 | class ValueLookupJob: public CollectJob |
120 | { |
121 | const QJsonArray handles; |
122 | QString exception; |
123 | |
124 | public: |
125 | ValueLookupJob(const QJsonArray &handles, QV4DataCollector *collector); |
126 | void run() override; |
127 | const QString &exceptionMessage() const; |
128 | }; |
129 | |
130 | class ExpressionEvalJob: public JavaScriptJob |
131 | { |
132 | QV4DataCollector *collector; |
133 | QString exception; |
134 | QJsonObject result; |
135 | |
136 | public: |
137 | ExpressionEvalJob(QV4::ExecutionEngine *engine, int frameNr, int context, |
138 | const QString &expression, QV4DataCollector *collector); |
139 | void handleResult(QV4::ScopedValue &value) override; |
140 | const QString &exceptionMessage() const; |
141 | const QJsonObject &returnValue() const; |
142 | }; |
143 | |
144 | class GatherSourcesJob: public QV4DebugJob |
145 | { |
146 | QV4::ExecutionEngine *engine; |
147 | QStringList sources; |
148 | |
149 | public: |
150 | GatherSourcesJob(QV4::ExecutionEngine *engine); |
151 | void run() override; |
152 | const QStringList &result() const; |
153 | }; |
154 | |
155 | class EvalJob: public JavaScriptJob |
156 | { |
157 | bool result; |
158 | |
159 | public: |
160 | EvalJob(QV4::ExecutionEngine *engine, const QString &script); |
161 | |
162 | void handleResult(QV4::ScopedValue &result) override; |
163 | bool resultAsBoolean() const; |
164 | }; |
165 | |
166 | QT_END_NAMESPACE |
167 | |
168 | #endif // QV4DEBUGJOB_H |
169 | |
170 | |