Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
26
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
47
48 int registerString(const QString &str);
49 int getStringId(const QString &string) const;
50 QString stringForIndex(int index) const { return strings.at(index); }
51 uint stringCount() const { return strings.size() - backingUnitTableSize; }
52
53 uint sizeOfTableAndData() const { return stringDataSize + ((stringCount() * sizeof(uint) + 7) & ~7); }
54
55 void freeze() { frozen = true; }
56
57 void clear();
58
59 void initializeFromBackingUnit(const CompiledData::Unit *unit);
60
61 void serialize(CompiledData::Unit *unit);
62 QStringList allStrings() const { return strings.mid(backingUnitTableSize); }
63
64private:
65 QHash<QString, int> stringToId;
67 uint stringDataSize;
68 uint backingUnitTableSize = 0;
69 bool frozen = false;
70};
71
73 enum LookupMode { LookupForStorage, LookupForCall };
74
75 static void generateUnitChecksum(CompiledData::Unit *unit);
76
77 struct MemberInfo {
80 };
81
82 JSUnitGenerator(Module *module);
83
84 int registerString(const QString &str) { return stringTable.registerString(str); }
85 int getStringId(const QString &string) const { return stringTable.getStringId(string); }
86 QString stringForIndex(int index) const { return stringTable.stringForIndex(index); }
87
88 int registerGetterLookup(const QString &name, LookupMode mode);
89 int registerGetterLookup(int nameIndex, LookupMode mode);
90 int registerSetterLookup(const QString &name);
91 int registerSetterLookup(int nameIndex);
92 int registerGlobalGetterLookup(int nameIndex, LookupMode mode);
93 int registerQmlContextPropertyGetterLookup(int nameIndex, LookupMode mode);
94 int lookupNameIndex(int index) const { return lookups[index].nameIndex(); }
95 QString lookupName(int index) const { return stringForIndex(lookupNameIndex(index)); }
96
97 int registerRegExp(QQmlJS::AST::RegExpLiteral *regexp);
98
99 int registerConstant(ReturnedValue v);
100 ReturnedValue constant(int idx) const;
101
102 int registerJSClass(const QStringList &members);
103 int jsClassSize(int jsClassId) const;
104 QString jsClassMember(int jsClassId, int member) const;
105
106 int registerTranslation(const CompiledData::TranslationData &translation);
107
110 GenerateWithoutStringTable
111 };
112
113 QV4::CompiledData::Unit *generateUnit(GeneratorOption option = GenerateWithStringTable);
114 void writeFunction(char *f, Context *irFunction) const;
115 void writeClass(char *f, const Class &c);
116 void writeTemplateObject(char *f, const TemplateObject &o);
117 void writeBlock(char *f, Context *irBlock) const;
118
121
122private:
123 CompiledData::Unit generateHeader(GeneratorOption option, quint32_le *functionOffsets, uint *jsClassDataOffset);
124
125 Module *module;
126
127 QList<CompiledData::Lookup> lookups;
128 QVector<CompiledData::RegExp> regexps;
129 QVector<ReturnedValue> constants;
130 QByteArray jsClassData;
131 QVector<int> jsClassOffsets;
132 QVector<CompiledData::TranslationData> translations;
133};
134
135}
136
137}
138
140
141#endif
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
Definition qstring.h:1226
QString str
[2]
b clear()
Combined button and popup list for selecting options.
quint64 ReturnedValue
GLsizei const GLfloat * v
[13]
GLenum mode
GLuint index
[2]
GLsizei const GLchar ** strings
[1]
GLfloat GLfloat f
GLuint name
const GLubyte * c
GLuint GLenum option
Members members(const Members &candidates, QTypeRevision maxMajorVersion, Postprocess &&process)
#define Q_QML_COMPILER_EXPORT
unsigned int uint
Definition qtypes.h:34
static const QV4::Value & constant(Function *function, int index)
StringTableGenerator stringTable
QString lookupName(int index) const
int lookupNameIndex(int index) const
int getStringId(const QString &string) const
QString stringForIndex(int index) const
int registerString(const QString &str)
QString stringForIndex(int index) const