Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
27
QT_BEGIN_NAMESPACE
28
29
class
QQmlPropertyData;
30
31
namespace
QV4
{
32
33
namespace
CompiledData
{
34
struct
Unit
;
35
struct
Lookup
;
36
struct
RegExp
;
37
struct
JSClassMember
;
38
}
39
40
namespace
Compiler
{
41
42
struct
Context
;
43
struct
Module
;
44
struct
Class
;
45
struct
TemplateObject
;
46
47
struct
Q_QML_COMPILER_EXPORT
StringTableGenerator
{
48
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
62
void
initializeFromBackingUnit
(
const
CompiledData
::
Unit
*unit);
63
64
void
serialize
(
CompiledData
::
Unit
*unit);
65
QStringList
allStrings
()
const
{
return
strings.mid(backingUnitTableSize); }
66
67
private
:
68
QHash
<
QString
,
int
>
stringToId
;
69
QStringList strings;
70
uint stringDataSize;
71
uint backingUnitTableSize = 0;
72
bool
frozen =
false
;
73
};
74
75
struct
Q_QML_COMPILER_EXPORT
JSUnitGenerator
{
76
enum
LookupMode
{
LookupForStorage
,
LookupForCall
};
77
78
static
void
generateUnitChecksum
(
CompiledData
::
Unit
*
unit
);
79
80
struct
MemberInfo
{
81
QString
name
;
82
bool
isAccessor
;
83
};
84
85
JSUnitGenerator
(
Module
*
module
);
86
87
int
registerString
(
const
QString
&
str
) {
return
stringTable
.
registerString
(
str
); }
88
int
getStringId
(
const
QString
&
string
)
const
{
return
stringTable
.
getStringId
(
string
); }
89
bool
hasStringId
(
const
QString
&
string
)
const
{
return
stringTable
.
hasStringId
(
string
); }
90
QString
stringForIndex
(
int
index
)
const
{
return
stringTable
.
stringForIndex
(
index
); }
91
92
int
registerGetterLookup
(
const
QString
&
name
,
LookupMode
mode
);
93
int
registerGetterLookup
(
int
nameIndex
,
LookupMode
mode
);
94
int
registerSetterLookup
(
const
QString
&
name
);
95
int
registerSetterLookup
(
int
nameIndex
);
96
int
registerGlobalGetterLookup
(
int
nameIndex
,
LookupMode
mode
);
97
int
registerQmlContextPropertyGetterLookup
(
int
nameIndex
,
LookupMode
mode
);
98
int
lookupNameIndex
(
int
index
)
const
{
return
lookups
[
index
].
nameIndex
(); }
99
QString
lookupName
(
int
index
)
const
{
return
stringForIndex
(
lookupNameIndex
(
index
)); }
100
101
int
registerRegExp
(
QQmlJS
::
AST
::
RegExpLiteral
*
regexp
);
102
103
int
registerConstant
(
ReturnedValue
v
);
104
ReturnedValue
constant
(
int
idx
)
const
;
105
106
int
registerJSClass
(
const
QStringList
&
members
);
107
int
jsClassSize
(
int
jsClassId
)
const
;
108
QString
jsClassMember
(
int
jsClassId
,
int
member
)
const
;
109
110
int
registerTranslation
(
const
CompiledData
::
TranslationData
&
translation
);
111
112
enum
GeneratorOption
{
113
GenerateWithStringTable
,
114
GenerateWithoutStringTable
115
};
116
117
QV4
::
CompiledData
::
Unit
*
generateUnit
(
GeneratorOption
option
=
GenerateWithStringTable
);
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
123
StringTableGenerator
stringTable
;
124
QString
codeGeneratorName
;
125
126
private
:
127
CompiledData
::
Unit
generateHeader
(
GeneratorOption
option
,
quint32_le
*
functionOffsets
,
uint
*
jsClassDataOffset
);
128
129
Module
*
module
;
130
131
QList
<
CompiledData
::
Lookup
>
lookups
;
132
QList
<
CompiledData
::
RegExp
>
regexps
;
133
QList
<
ReturnedValue
>
constants
;
134
QByteArray
jsClassData
;
135
QList
<
int
>
jsClassOffsets
;
136
QList
<
CompiledData
::
TranslationData
>
translations
;
137
};
138
139
}
140
141
}
142
143
QT_END_NAMESPACE
144
145
#
endif
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QV4::CompiledData
Definition
qv4compileddata.cpp:22
QV4::Compiler
Definition
qv4compiler_p.h:40
QV4
Definition
qjsvalue.h:24
QtPrivate
Definition
qalloc.h:29
QtPrivate::roundUpToMultipleOf
static size_t roundUpToMultipleOf(size_t divisor, size_t x)
Definition
qv4compiler.cpp:21
jsClassMembersOffset
static constexpr qsizetype jsClassMembersOffset
Definition
qv4compiler.cpp:202
lookupMode
static QV4::CompiledData::Lookup::Mode lookupMode(QV4::Compiler::JSUnitGenerator::LookupMode mode)
Definition
qv4compiler.cpp:125
QV4::CompiledData::JSClassMember
Definition
qv4compileddata_p.h:245
QV4::CompiledData::Lookup
Definition
qv4compileddata_p.h:210
QV4::CompiledData::RegExp
Definition
qv4compileddata_p.h:180
QV4::CompiledData::Unit
Definition
qv4compileddata_p.h:1127
QV4::Compiler::Class
Definition
qv4compilercontext_p.h:59
QV4::Compiler::Context
Definition
qv4compilercontext_p.h:136
QV4::Compiler::JSUnitGenerator
Definition
qv4compiler_p.h:75
QV4::Compiler::Module
Definition
qv4compilercontext_p.h:105
QV4::Compiler::StringTableGenerator
Definition
qv4compiler_p.h:47
QV4::Compiler::StringTableGenerator::freeze
void freeze()
Definition
qv4compiler_p.h:58
QV4::Compiler::StringTableGenerator::sizeOfTableAndData
uint sizeOfTableAndData() const
Definition
qv4compiler_p.h:56
QV4::Compiler::StringTableGenerator::hasStringId
bool hasStringId(const QString &string) const
Definition
qv4compiler_p.h:52
QV4::Compiler::StringTableGenerator::allStrings
QStringList allStrings() const
Definition
qv4compiler_p.h:65
QV4::Compiler::StringTableGenerator::stringForIndex
QString stringForIndex(int index) const
Definition
qv4compiler_p.h:53
QV4::Compiler::StringTableGenerator::getStringId
int getStringId(const QString &string) const
Definition
qv4compiler.cpp:47
QV4::Compiler::StringTableGenerator::registerString
int registerString(const QString &str)
Definition
qv4compiler.cpp:35
QV4::Compiler::StringTableGenerator::stringCount
uint stringCount() const
Definition
qv4compiler_p.h:54
QV4::Compiler::StringTableGenerator::serialize
void serialize(CompiledData::Unit *unit)
Definition
qv4compiler.cpp:70
QV4::Compiler::StringTableGenerator::initializeFromBackingUnit
void initializeFromBackingUnit(const CompiledData::Unit *unit)
Definition
qv4compiler.cpp:61
QV4::Compiler::StringTableGenerator::clear
void clear()
Definition
qv4compiler.cpp:53
QV4::Compiler::TemplateObject
Definition
qv4compilercontext_p.h:77
qtdeclarative
src
qml
compiler
qv4compiler_p.h
Generated on
for Qt by
1.18.0