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#ifndef QV4COMPILER_P_H
4#define QV4COMPILER_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <QtCore/qstring.h>
18#include <QtCore/qhash.h>
19#include <QtCore/qstringlist.h>
20#include <private/qv4compilerglobal_p.h>
21#include <private/qqmljsastfwd_p.h>
22#include <private/qv4compileddata_p.h>
23#include <private/qv4staticvalue_p.h>
24
25QT_BEGIN_NAMESPACE
26
27class QQmlPropertyData;
28
29namespace QV4 {
30
31namespace CompiledData {
32struct Unit;
33struct Lookup;
34struct RegExp;
35struct JSClassMember;
36}
37
38namespace Compiler {
39
40struct Context;
41struct Module;
42struct Class;
43struct TemplateObject;
44
45struct Q_QML_COMPILER_EXPORT StringTableGenerator {
47
48 int registerString(const QString &str);
49 int getStringId(const QString &string) const;
50 bool hasStringId(const QString &string) const { return stringToId.contains(string); }
51 QString stringForIndex(int index) const { return strings.at(index); }
52 uint stringCount() const { return strings.size() - backingUnitTableSize; }
53
54 uint sizeOfTableAndData() const { return stringDataSize + ((stringCount() * sizeof(uint) + 7) & ~7); }
55
56 void freeze() { frozen = true; }
57
58 void clear();
59
61
62 void serialize(CompiledData::Unit *unit);
63 QStringList allStrings() const { return strings.mid(backingUnitTableSize); }
64
65private:
67 QStringList strings;
68 uint stringDataSize;
69 uint backingUnitTableSize = 0;
70 bool frozen = false;
71};
72
73struct Q_QML_COMPILER_EXPORT JSUnitGenerator {
75
77
78 struct MemberInfo {
81 };
82
84
86 int getStringId(const QString &string) const { return stringTable.getStringId(string); }
87 bool hasStringId(const QString &string) const { return stringTable.hasStringId(string); }
89
96 int lookupNameIndex(int index) const { return lookups[index].nameIndex(); }
98
100
102 ReturnedValue constant(int idx) const;
103
105 int jsClassSize(int jsClassId) const;
106 QString jsClassMember(int jsClassId, int member) const;
107
109
114
116 void writeFunction(char *f, Context *irFunction) const;
117 void writeClass(char *f, const Class &c);
118 void writeTemplateObject(char *f, const TemplateObject &o);
119 void writeBlock(char *f, Context *irBlock) const;
120
123
124private:
126
127 Module *module;
128
135};
136
137}
138
139}
140
141QT_END_NAMESPACE
142
143#endif
Definition qjsvalue.h:23
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)