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
qv4regexp_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
#
ifndef
QV4REGEXP_H
5
#
define
QV4REGEXP_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
// Yarr.h is not self-contained. Make sure it sees uint8_t
19
#
include
<
cstdint
>
20
21
#
include
<
yarr
/
Yarr
.
h
>
22
#
include
<
yarr
/
YarrInterpreter
.
h
>
23
#
include
<
yarr
/
YarrJIT
.
h
>
24
25
#
include
<
private
/
qv4compileddata_p
.
h
>
26
#
include
<
private
/
qv4managed_p
.
h
>
27
28
#
include
<
QtCore
/
qstring
.
h
>
29
#
include
<
QtCore
/
qvector
.
h
>
30
31
QT_BEGIN_NAMESPACE
32
33
namespace
QV4
{
34
35
struct
ExecutionEngine;
36
struct
RegExpCacheKey
;
37
38
namespace
Heap
{
39
40
struct
RegExp
:
Base
{
41
void
init
(ExecutionEngine *engine,
const
QString& pattern, uint flags);
42
void
destroy
();
43
44
QString
*
pattern
;
45
JSC
::
Yarr
::
BytecodePattern
*
byteCode
;
46
#
if
ENABLE
(
YARR_JIT
)
47
JSC
::
Yarr
::
YarrCodeBlock
*
jitCode
;
48
#
endif
49
bool
hasValidJITCode
()
const
{
50
#
if
ENABLE
(
YARR_JIT
)
51
return
jitCode && !jitCode->failureReason().has_value() && jitCode->has16BitCode();
52
#
else
53
return
false
;
54
#
endif
55
}
56
57
bool
ignoreCase
()
const
{
return
flags & CompiledData::RegExp::RegExp_IgnoreCase; }
58
bool
multiLine
()
const
{
return
flags & CompiledData::RegExp::RegExp_Multiline; }
59
bool
global
()
const
{
return
flags & CompiledData::RegExp::RegExp_Global; }
60
bool
unicode
()
const
{
return
flags & CompiledData::RegExp::RegExp_Unicode; }
61
bool
sticky
()
const
{
return
flags & CompiledData::RegExp::RegExp_Sticky; }
62
63
RegExpCache
*
cache
;
64
int
subPatternCount
;
65
66
#
if
ENABLE
(
YARR_JIT
)
67
bool
isJittable
()
const
{
return
!
jitFailed
; }
68
int
interpreterCallCount
;
69
bool
jitFailed
;
70
#
endif
71
72
quint8
flags
;
73
bool
valid
;
74
75
int
captureCount
()
const
{
return
subPatternCount
+ 1; }
76
};
77
static_assert
(
std
::
is_trivially_copyable_v
<
RegExp
>);
78
static_assert
(
std
::
is_trivially_default_constructible_v
<
RegExp
>);
79
80
}
81
82
struct
RegExp
:
public
Managed
83
{
84
V4_MANAGED(
RegExp
, Managed)
85
Q_MANAGED_TYPE
(
RegExp
)
86
V4_NEEDS_DESTROY
87
V4_INTERNALCLASS
(
RegExp
)
88
89
QString
pattern
()
const
{
return
*
d
()->
pattern
; }
90
JSC
::
Yarr
::
BytecodePattern
*
byteCode
() {
return
d
()->
byteCode
; }
91
#
if
ENABLE
(
YARR_JIT
)
92
JSC
::
Yarr
::
YarrCodeBlock
*
jitCode
()
const
{
return
d
()->
jitCode
; }
93
#
endif
94
RegExpCache
*
cache
()
const
{
return
d
()->
cache
; }
95
int
subPatternCount
()
const
{
return
d
()->
subPatternCount
; }
96
bool
ignoreCase
()
const
{
return
d
()->
ignoreCase
(); }
97
bool
multiLine
()
const
{
return
d
()->
multiLine
(); }
98
bool
global
()
const
{
return
d
()->
global
(); }
99
bool
unicode
()
const
{
return
d
()->
unicode
(); }
100
bool
sticky
()
const
{
return
d
()->
sticky
(); }
101
102
static
Heap
::
RegExp
*
create
(
103
ExecutionEngine
*
engine
,
const
QString
&
pattern
,
104
CompiledData
::
RegExp
::
Flags
flags
=
CompiledData
::
RegExp
::
RegExp_NoFlags
);
105
106
bool
isValid
()
const
{
return
d()->valid; }
107
108
uint
match
(
const
QString& string,
int
start, uint *matchOffsets);
109
110
int
captureCount
()
const
{
return
subPatternCount() + 1; }
111
112
static
QString
getSubstitution
(
const
QString &matched,
const
QString &str,
int
position,
const
Value *captures,
int
nCaptures,
const
QString &replacement);
113
114
friend
class
RegExpCache
;
115
};
116
117
struct
RegExpCacheKey
118
{
119
RegExpCacheKey
(
const
QString &pattern, uint flags)
120
:
pattern
(
pattern
),
flags
(
flags
)
121
{ }
122
explicit
inline
RegExpCacheKey
(
const
RegExp::Data *re);
123
124
bool
operator
==(
const
RegExpCacheKey
&other)
const
125
{
return
pattern == other.pattern && flags == other.flags;; }
126
bool
operator
!=(
const
RegExpCacheKey
&other)
const
127
{
return
!
operator
==
(
other
)
; }
128
129
QString
pattern
;
130
quint8
flags
;
131
};
132
133
inline
RegExpCacheKey
::
RegExpCacheKey
(
const
RegExp::Data *re)
134
:
pattern
(*
re
->
pattern
)
135
,
flags
(
re
->
flags
)
136
{}
137
138
inline
size_t
qHash
(
const
RegExpCacheKey
& key, size_t seed = 0)
noexcept
139
{
return
qHashMulti(seed, key.pattern, key.flags); }
140
141
class
RegExpCache
:
public
QHash
<
RegExpCacheKey
,
WeakValue
>
142
{
143
public
:
144
~
RegExpCache
();
145
};
146
147
148
149
}
150
151
QT_END_NAMESPACE
152
153
#
endif
// QV4REGEXP_H
QV4::RegExpCache
Definition
qv4regexp_p.h:142
QV4::RegExpCache::~RegExpCache
~RegExpCache()
Definition
qv4regexp.cpp:35
QV4::Heap
Definition
qv4compileddata_p.h:76
QV4
Definition
qjsvalue.h:24
QV4::qHash
size_t qHash(const RegExpCacheKey &key, size_t seed=0) noexcept
Definition
qv4regexp_p.h:138
DEFINE_MANAGED_VTABLE
DEFINE_MANAGED_VTABLE(RegExp)
jscFlags
static JSC::RegExpFlags jscFlags(quint8 flags)
Definition
qv4regexp.cpp:19
QV4::Heap::RegExp
Definition
qv4regexp_p.h:40
QV4::Heap::RegExp::global
bool global() const
Definition
qv4regexp_p.h:59
QV4::Heap::RegExp::sticky
bool sticky() const
Definition
qv4regexp_p.h:61
QV4::Heap::RegExp::valid
bool valid
Definition
qv4regexp_p.h:73
QV4::Heap::RegExp::ignoreCase
bool ignoreCase() const
Definition
qv4regexp_p.h:57
QV4::Heap::RegExp::multiLine
bool multiLine() const
Definition
qv4regexp_p.h:58
QV4::Heap::RegExp::subPatternCount
int subPatternCount
Definition
qv4regexp_p.h:64
QV4::Heap::RegExp::unicode
bool unicode() const
Definition
qv4regexp_p.h:60
QV4::Heap::RegExp::hasValidJITCode
bool hasValidJITCode() const
Definition
qv4regexp_p.h:49
QV4::Heap::RegExp::destroy
void destroy()
Definition
qv4regexp.cpp:238
QV4::Heap::RegExp::cache
RegExpCache * cache
Definition
qv4regexp_p.h:63
QV4::Heap::RegExp::init
void init(ExecutionEngine *engine, const QString &pattern, uint flags)
Definition
qv4regexp.cpp:217
QV4::Heap::RegExp::flags
quint8 flags
Definition
qv4regexp_p.h:72
QV4::Heap::RegExp::byteCode
JSC::Yarr::BytecodePattern * byteCode
Definition
qv4regexp_p.h:45
QV4::Heap::RegExp::pattern
QString * pattern
Definition
qv4regexp_p.h:44
QV4::Heap::RegExp::captureCount
int captureCount() const
Definition
qv4regexp_p.h:75
QV4::RegExpCacheKey
Definition
qv4regexp_p.h:118
QV4::RegExpCacheKey::flags
quint8 flags
Definition
qv4regexp_p.h:130
QV4::RegExpCacheKey::RegExpCacheKey
RegExpCacheKey(const QString &pattern, uint flags)
Definition
qv4regexp_p.h:119
QV4::RegExpCacheKey::pattern
QString pattern
Definition
qv4regexp_p.h:129
QV4::RegExpCacheKey::operator!=
bool operator!=(const RegExpCacheKey &other) const
Definition
qv4regexp_p.h:126
QV4::RegExpCacheKey::operator==
bool operator==(const RegExpCacheKey &other) const
Definition
qv4regexp_p.h:124
QV4::RegExpCacheKey::RegExpCacheKey
RegExpCacheKey(const RegExp::Data *re)
Definition
qv4regexp_p.h:133
QV4::RegExp
Definition
qv4regexp_p.h:83
QV4::RegExp::getSubstitution
static QString getSubstitution(const QString &matched, const QString &str, int position, const Value *captures, int nCaptures, const QString &replacement)
Definition
qv4regexp.cpp:141
QV4::RegExp::isValid
bool isValid() const
Definition
qv4regexp_p.h:106
QV4::RegExp::captureCount
int captureCount() const
Definition
qv4regexp_p.h:110
QV4::RegExp::match
uint match(const QString &string, int start, uint *matchOffsets)
Definition
qv4regexp.cpp:45
qtdeclarative
src
qml
jsruntime
qv4regexp_p.h
Generated on
for Qt by
1.18.0