7#include <private/qv4mm_p.h>
13static constexpr quint8 RegexpJitThreshold = 5;
18 JSC::RegExpFlags
jscFlags = JSC::NoFlags;
36 re->d()->cache =
nullptr;
45 return JSC::Yarr::offsetNoMatch;
51 JSC::Yarr::ErrorCode
error = JSC::Yarr::ErrorCode::NoError;
52 JSC::Yarr::YarrPattern yarrPattern(WTF::String(*regexp->pattern),
jscFlags(regexp->flags),
58 regexp->byteCode = JSC::Yarr::byteCompile(
60 regexp->internalClass->engine->bumperPointerAllocator).release();
64 delete regexp->jitCode;
65 regexp->jitCode =
nullptr;
66 regexp->jitFailed =
true;
70 delete regexp->byteCode;
71 regexp->byteCode =
nullptr;
74 if (!
priv->jitCode && !
priv->jitFailed &&
priv->internalClass->engine->canJIT()
75 && (
string.length() > 1024 ||
priv->matchCount++ == RegexpJitThreshold)) {
78 JSC::Yarr::ErrorCode
error = JSC::Yarr::ErrorCode::NoError;
79 JSC::Yarr::YarrPattern yarrPattern(
81 if (!yarrPattern.m_containsBackreferences) {
82 priv->jitCode =
new JSC::Yarr::YarrCodeBlock;
83 JSC::VM *vm =
static_cast<JSC::VM *
>(
priv->internalClass->engine);
84 JSC::Yarr::jitCompile(yarrPattern, JSC::Yarr::Char16, vm, *
priv->jitCode);
87 if (!
priv->hasValidJITCode()) {
89 regenerateByteCode(
priv);
94 WTF::String
s(
string);
97 if (
priv->hasValidJITCode()) {
98 static const uint offsetJITFail = std::numeric_limits<unsigned>::max() - 1;
99 uint ret = JSC::Yarr::offsetNoMatch;
100#if ENABLE(YARR_JIT_ALL_PARENS_EXPRESSIONS)
103 (
int*)matchOffsets,
buffer, 8192).start);
106 (
int*)matchOffsets).start);
108 if (
ret != offsetJITFail)
114 regenerateByteCode(
priv);
118 return JSC::Yarr::interpret(
byteCode(),
s.characters16(),
string.size(),
start, matchOffsets);
125 int matchedLength = matched.size();
127 int tailPos =
position + matchedLength;
129 for (
int i = 0;
i < replacement.
size(); ++
i) {
131 if (seenDollar >= 0) {
132 if (
ch.unicode() ==
'$') {
134 }
else if (
ch.unicode() ==
'&') {
136 }
else if (
ch.unicode() ==
'`') {
138 }
else if (
ch.unicode() ==
'\'') {
140 }
else if (
ch.unicode() >=
'0' &&
ch.unicode() <=
'9') {
141 int n =
ch.unicode() -
'0';
142 if (
i + 1 < replacement.
size()) {
143 ch = replacement.
at(
i + 1);
144 if (
ch.unicode() >=
'0' &&
ch.unicode() <=
'9') {
145 n =
n*10 + (
ch.unicode() -
'0');
149 if (
n > 0 &&
n <= nCaptures) {
154 for (
int j = seenDollar;
j <=
i; ++
j)
222 JSC::Yarr::ErrorCode
error = JSC::Yarr::ErrorCode::NoError;
224 if (
error != JSC::Yarr::ErrorCode::NoError)
226 subPatternCount = yarrPattern.m_numSubpatterns;
228 byteCode = JSC::Yarr::byteCompile(yarrPattern, internalClass->engine->bumperPointerAllocator).release();
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
iterator Iterator
Qt-style synonym for QHash::iterator.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
\macro QT_RESTRICTED_CAST_FROM_ASCII
QString left(qsizetype n) const &
QString mid(qsizetype position, qsizetype n=-1) const &
qsizetype size() const noexcept
Returns the number of characters in this string.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
void set(ExecutionEngine *engine, const Value &value)
QCache< int, Employee > cache
[0]
QSet< QString >::iterator it
DBusConnection const char DBusError * error
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
static JSC::RegExpFlags jscFlags(uint flags)
#define DEFINE_MANAGED_VTABLE(classname)
\inmodule QtCore \reentrant
QString flagsAsString() const
static QString getSubstitution(const QString &matched, const QString &str, int position, const Value *captures, int nCaptures, const QString &replacement)
static Heap::RegExp * create(ExecutionEngine *engine, const QString &pattern, uint flags=CompiledData::RegExp::RegExp_NoFlags)
JSC::Yarr::BytecodePattern * byteCode()
uint match(const QString &string, int start, uint *matchOffsets)
QString toQString() const
QML_NEARLY_ALWAYS_INLINE String * stringValue() const