Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4compiler_p.h
Go to the documentation of this file.
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// Qt-Security score:significant
4
5#ifndef QV4COMPILER_P_H
6#define QV4COMPILER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qstring.h>
20#include <QtCore/qhash.h>
21#include <QtCore/qstringlist.h>
22#include <private/qv4compilerglobal_p.h>
23#include <private/qqmljsastfwd_p.h>
24#include <private/qv4compileddata_p.h>
25#include <private/qv4staticvalue_p.h>
26
27QT_BEGIN_NAMESPACE
28
29class QQmlPropertyData;
30
31namespace QV4 {
32
33namespace CompiledData {
34struct Unit;
35struct Lookup;
36struct RegExp;
37struct JSClassMember;
38}
39
40namespace Compiler {
41
42struct Context;
43struct Module;
44struct Class;
45struct TemplateObject;
46
47struct Q_QML_COMPILER_EXPORT StringTableGenerator {
49
50 int registerString(const QString &str);
51 int getStringId(const QString &string) const;
52 bool hasStringId(const QString &string) const { return stringToId.contains(string); }
53 QString stringForIndex(int index) const { return strings.at(index); }
54 uint stringCount() const { return strings.size() - backingUnitTableSize; }
55
56 uint sizeOfTableAndData() const { return stringDataSize + ((stringCount() * sizeof(uint) + 7) & ~7); }
57
58 void freeze() { frozen = true; }
59
60 void clear();
61
63
64 void serialize(CompiledData::Unit *unit);
65 QStringList allStrings() const { return strings.mid(backingUnitTableSize); }
66
67private:
69 QStringList strings;
70 uint stringDataSize;
71 uint backingUnitTableSize = 0;
72 bool frozen = false;
73};
74
75struct Q_QML_COMPILER_EXPORT JSUnitGenerator {
77
79
80 struct MemberInfo {
83 };
84
86
88 int getStringId(const QString &string) const { return stringTable.getStringId(string); }
89 bool hasStringId(const QString &string) const { return stringTable.hasStringId(string); }
91
98 int lookupNameIndex(int index) const { return lookups[index].nameIndex(); }
100
102
104 ReturnedValue constant(int idx) const;
105
107 int jsClassSize(int jsClassId) const;
108 QString jsClassMember(int jsClassId, int member) const;
109
111
116
118 void writeFunction(char *f, Context *irFunction) const;
119 void writeClass(char *f, const Class &c);
120 void writeTemplateObject(char *f, const TemplateObject &o);
121 void writeBlock(char *f, Context *irBlock) const;
122
125
126private:
128
129 Module *module;
130
137};
138
139}
140
141}
142
143QT_END_NAMESPACE
144
145#endif
Combined button and popup list for selecting options.
Definition qjsvalue.h:24
static size_t roundUpToMultipleOf(size_t divisor, size_t x)
static constexpr qsizetype jsClassMembersOffset
static QV4::CompiledData::Lookup::Mode lookupMode(QV4::Compiler::JSUnitGenerator::LookupMode mode)
bool hasStringId(const QString &string) const
QString stringForIndex(int index) const
int getStringId(const QString &string) const
int registerString(const QString &str)
void serialize(CompiledData::Unit *unit)
void initializeFromBackingUnit(const CompiledData::Unit *unit)