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 QV4DATACOLLECTOR_H |
5 | #define QV4DATACOLLECTOR_H |
6 | |
7 | #include <private/qv4engine_p.h> |
8 | #include <private/qv4persistent_p.h> |
9 | |
10 | #include <QtCore/QJsonObject> |
11 | #include <QtCore/QJsonArray> |
12 | |
13 | #include <QtCore/QJsonObject> |
14 | #include <QtCore/QJsonArray> |
15 | |
16 | QT_BEGIN_NAMESPACE |
17 | |
18 | class QV4Debugger; |
19 | class QV4DataCollector |
20 | { |
21 | public: |
22 | typedef uint Ref; |
23 | typedef QVector<uint> Refs; |
24 | |
25 | static QV4::Heap::ExecutionContext *findScope(QV4::Heap::ExecutionContext *ctxt, int scope); |
26 | static int encodeScopeType(QV4::Heap::ExecutionContext::ContextType scopeType); |
27 | |
28 | QVector<QV4::Heap::ExecutionContext::ContextType> getScopeTypes(int frame); |
29 | QV4::Heap::ExecutionContext *findContext(int frame); |
30 | QV4::CppStackFrame *findFrame(int frame); |
31 | |
32 | QV4DataCollector(QV4::ExecutionEngine *engine); |
33 | |
34 | Ref addValueRef(const QV4::ScopedValue &value); |
35 | |
36 | bool isValidRef(Ref ref) const; |
37 | QJsonObject lookupRef(Ref ref); |
38 | |
39 | bool collectScope(QJsonObject *dict, int frameNr, int scopeNr); |
40 | QJsonObject buildFrame(const QV4::StackFrame &stackFrame, int frameNr); |
41 | |
42 | QV4::ExecutionEngine *engine() const { return m_engine; } |
43 | void clear(); |
44 | |
45 | private: |
46 | Ref addRef(QV4::Value value, bool deduplicate = true); |
47 | QV4::ReturnedValue getValue(Ref ref); |
48 | |
49 | QJsonArray collectProperties(const QV4::Object *object); |
50 | QJsonObject collectAsJson(const QString &name, const QV4::ScopedValue &value); |
51 | |
52 | QV4::ExecutionEngine *m_engine; |
53 | QV4::PersistentValue m_values; |
54 | }; |
55 | |
56 | QT_END_NAMESPACE |
57 | |
58 | #endif // QV4DATACOLLECTOR_H |
59 |