| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4regexpobject.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | __attribute__((visibility("default"))) QString qt_regexp_toCanonical(const QString &, QRegExp::PatternSyntax); | - | ||||||||||||
| 11 | - | |||||||||||||
| 12 | using namespace QV4; | - | ||||||||||||
| 13 | - | |||||||||||||
| 14 | const QV4::VTable RegExpObject::static_vtbl = { (std::is_same<RegExpObject::SuperClass, Object>::value) ? nullptr : &RegExpObject::SuperClass::static_vtbl, (sizeof(RegExpObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(RegExpObject::Data) + (RegExpObject::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(RegExpObject::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), RegExpObject::IsExecutionContext, RegExpObject::IsString, RegExpObject::IsObject, RegExpObject::IsFunctionObject, RegExpObject::IsErrorObject, RegExpObject::IsArrayData, RegExpObject::IsStringOrSymbol, RegExpObject::MyType, { 0, 0, 0, 0 }, "RegExpObject", RegExpObject::virtualDestroy, RegExpObject::Data::markObjects, RegExpObject::virtualIsEqualTo, RegExpObject::virtualGet, RegExpObject::virtualPut, RegExpObject::virtualDeleteProperty, RegExpObject::virtualHasProperty, RegExpObject::virtualGetOwnProperty, RegExpObject::virtualDefineOwnProperty, RegExpObject::virtualIsExtensible, RegExpObject::virtualPreventExtensions, RegExpObject::virtualGetPrototypeOf, RegExpObject::virtualSetPrototypeOf, RegExpObject::virtualGetLength, RegExpObject::virtualAdvanceIterator, RegExpObject::virtualInstanceOf, RegExpObject::virtualCall, RegExpObject::virtualCallAsConstructor, }; | - | ||||||||||||
| 15 | - | |||||||||||||
| 16 | void Heap::RegExpObject::init() | - | ||||||||||||
| 17 | { | - | ||||||||||||
| 18 | Object::init(); | - | ||||||||||||
| 19 | Scope scope(internalClass->engine); | - | ||||||||||||
| 20 | Scoped<QV4::RegExpObject> o(scope, this); | - | ||||||||||||
| 21 | value.set(scope.engine, QV4::RegExp::create(scope.engine, QString(), false, false)); | - | ||||||||||||
| 22 | o->initProperties(); | - | ||||||||||||
| 23 | } executed 99134 times by 153 tests: end of blockExecuted by:
| 99134 | ||||||||||||
| 24 | - | |||||||||||||
| 25 | void Heap::RegExpObject::init(QV4::RegExp *value) | - | ||||||||||||
| 26 | { | - | ||||||||||||
| 27 | Object::init(); | - | ||||||||||||
| 28 | Scope scope(internalClass->engine); | - | ||||||||||||
| 29 | this->value.set(scope.engine, value->d()); | - | ||||||||||||
| 30 | Scoped<QV4::RegExpObject> o(scope, this); | - | ||||||||||||
| 31 | o->initProperties(); | - | ||||||||||||
| 32 | } executed 1055167 times by 9 tests: end of blockExecuted by:
| 1055167 | ||||||||||||
| 33 | - | |||||||||||||
| 34 | - | |||||||||||||
| 35 | - | |||||||||||||
| 36 | - | |||||||||||||
| 37 | void Heap::RegExpObject::init(const QRegExp &re) | - | ||||||||||||
| 38 | { | - | ||||||||||||
| 39 | Object::init(); | - | ||||||||||||
| 40 | - | |||||||||||||
| 41 | - | |||||||||||||
| 42 | QString pattern = ::qt_regexp_toCanonical(re.pattern(), re.patternSyntax()); | - | ||||||||||||
| 43 | if (re.isMinimal()
| 16-46 | ||||||||||||
| 44 | QString ecmaPattern; | - | ||||||||||||
| 45 | int len = pattern.length(); | - | ||||||||||||
| 46 | ecmaPattern.reserve(len); | - | ||||||||||||
| 47 | int i = 0; | - | ||||||||||||
| 48 | const QChar *wc = pattern.unicode(); | - | ||||||||||||
| 49 | bool inBracket = false; | - | ||||||||||||
| 50 | while (i < len
| 16-80 | ||||||||||||
| 51 | QChar c = wc[i++]; | - | ||||||||||||
| 52 | ecmaPattern += c; | - | ||||||||||||
| 53 | switch (c.unicode()) { | - | ||||||||||||
| 54 | case executed 4 times by 1 test: '?':case '?':Executed by:
executed 4 times by 1 test: case '?':Executed by:
| 4 | ||||||||||||
| 55 | case executed 4 times by 1 test: '+':case '+':Executed by:
executed 4 times by 1 test: case '+':Executed by:
| 4 | ||||||||||||
| 56 | case executed 6 times by 1 test: '*':case '*':Executed by:
executed 6 times by 1 test: case '*':Executed by:
| 6 | ||||||||||||
| 57 | case executed 2 times by 1 test: '}':case '}':Executed by:
executed 2 times by 1 test: case '}':Executed by:
| 2 | ||||||||||||
| 58 | if (!inBracket
| 6-10 | ||||||||||||
| 59 | ecmaPattern += QLatin1Char('?'); executed 10 times by 1 test: ecmaPattern += QLatin1Char('?');Executed by:
| 10 | ||||||||||||
| 60 | break; executed 16 times by 1 test: break;Executed by:
| 16 | ||||||||||||
| 61 | case executed 2 times by 1 test: '\\':case '\\':Executed by:
executed 2 times by 1 test: case '\\':Executed by:
| 2 | ||||||||||||
| 62 | if (i < len
| 0-2 | ||||||||||||
| 63 | ecmaPattern += wc[i++]; executed 2 times by 1 test: ecmaPattern += wc[i++];Executed by:
| 2 | ||||||||||||
| 64 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||
| 65 | case executed 6 times by 1 test: '[':case '[':Executed by:
executed 6 times by 1 test: case '[':Executed by:
| 6 | ||||||||||||
| 66 | inBracket = true; | - | ||||||||||||
| 67 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||
| 68 | case executed 6 times by 1 test: ']':case ']':Executed by:
executed 6 times by 1 test: case ']':Executed by:
| 6 | ||||||||||||
| 69 | inBracket = false; | - | ||||||||||||
| 70 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||
| 71 | default executed 50 times by 1 test: :default:Executed by:
executed 50 times by 1 test: default:Executed by:
| 50 | ||||||||||||
| 72 | break; executed 50 times by 1 test: break;Executed by:
| 50 | ||||||||||||
| 73 | } | - | ||||||||||||
| 74 | } | - | ||||||||||||
| 75 | pattern = ecmaPattern; | - | ||||||||||||
| 76 | } executed 16 times by 1 test: end of blockExecuted by:
| 16 | ||||||||||||
| 77 | - | |||||||||||||
| 78 | Scope scope(internalClass->engine); | - | ||||||||||||
| 79 | Scoped<QV4::RegExpObject> o(scope, this); | - | ||||||||||||
| 80 | - | |||||||||||||
| 81 | o->d()->value.set(scope.engine, | - | ||||||||||||
| 82 | QV4::RegExp::create(scope.engine, pattern, re.caseSensitivity() == Qt::CaseInsensitive, false)); | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | o->initProperties(); | - | ||||||||||||
| 85 | } executed 62 times by 4 tests: end of blockExecuted by:
| 62 | ||||||||||||
| 86 | - | |||||||||||||
| 87 | void RegExpObject::initProperties() | - | ||||||||||||
| 88 | { | - | ||||||||||||
| 89 | setProperty(Index_LastIndex, Primitive::fromInt32(0)); | - | ||||||||||||
| 90 | - | |||||||||||||
| 91 | ((value()) ? static_cast<void>(0) : qt_assert("value()", __FILE__, 140)); | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | QString p = *value()->pattern; | - | ||||||||||||
| 94 | if (p.isEmpty()
| 99545-1054645 | ||||||||||||
| 95 | p = ([]() noexcept -> QString { enum { Size = sizeof(u"" "(?:)")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "(?:)" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()); | - | ||||||||||||
| 96 | } executed 99550 times by 153 tests: else {end of blockExecuted by:
| 99550 | ||||||||||||
| 97 | - | |||||||||||||
| 98 | p.replace('/', QLatin1String("\\/")); | - | ||||||||||||
| 99 | } executed 1054487 times by 9 tests: end of blockExecuted by:
| 1054487 | ||||||||||||
| 100 | - | |||||||||||||
| 101 | setProperty(Index_Source, engine()->newString(p)); | - | ||||||||||||
| 102 | setProperty(Index_Global, Primitive::fromBoolean(global())); | - | ||||||||||||
| 103 | setProperty(Index_IgnoreCase, Primitive::fromBoolean(value()->ignoreCase)); | - | ||||||||||||
| 104 | setProperty(Index_Multiline, Primitive::fromBoolean(value()->multiLine)); | - | ||||||||||||
| 105 | } executed 1154204 times by 153 tests: end of blockExecuted by:
| 1154204 | ||||||||||||
| 106 | - | |||||||||||||
| 107 | - | |||||||||||||
| 108 | - | |||||||||||||
| 109 | - | |||||||||||||
| 110 | QRegExp RegExpObject::toQRegExp() const | - | ||||||||||||
| 111 | { | - | ||||||||||||
| 112 | Qt::CaseSensitivity caseSensitivity = value()->ignoreCase
| 12-38 | ||||||||||||
| 113 | return executed 50 times by 7 tests: QRegExp(*value()->pattern, caseSensitivity, QRegExp::RegExp2);return QRegExp(*value()->pattern, caseSensitivity, QRegExp::RegExp2);Executed by:
executed 50 times by 7 tests: return QRegExp(*value()->pattern, caseSensitivity, QRegExp::RegExp2);Executed by:
| 50 | ||||||||||||
| 114 | } | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | QString RegExpObject::toString() const | - | ||||||||||||
| 117 | { | - | ||||||||||||
| 118 | QString result = QLatin1Char('/') + source() + QLatin1Char('/'); | - | ||||||||||||
| 119 | if (global()
| 12-50 | ||||||||||||
| 120 | result += QLatin1Char('g'); executed 12 times by 2 tests: result += QLatin1Char('g');Executed by:
| 12 | ||||||||||||
| 121 | if (value()->ignoreCase
| 6-56 | ||||||||||||
| 122 | result += QLatin1Char('i'); executed 6 times by 1 test: result += QLatin1Char('i');Executed by:
| 6 | ||||||||||||
| 123 | if (value()->multiLine
| 6-56 | ||||||||||||
| 124 | result += QLatin1Char('m'); executed 6 times by 1 test: result += QLatin1Char('m');Executed by:
| 6 | ||||||||||||
| 125 | return executed 62 times by 2 tests: result;return result;Executed by:
executed 62 times by 2 tests: return result;Executed by:
| 62 | ||||||||||||
| 126 | } | - | ||||||||||||
| 127 | - | |||||||||||||
| 128 | QString RegExpObject::source() const | - | ||||||||||||
| 129 | { | - | ||||||||||||
| 130 | Scope scope(engine()); | - | ||||||||||||
| 131 | ScopedString source(scope, scope.engine->newIdentifier(([]() noexcept -> QString { enum { Size = sizeof(u"" "source")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "source" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 66 times by 3 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 66 times by 3 tests: }())));return qstring_literal_temp;Executed by:
| 66 | ||||||||||||
| 132 | ScopedValue s(scope, const_cast<RegExpObject *>(this)->get(source)); | - | ||||||||||||
| 133 | return executed 66 times by 3 tests: s->toQString();return s->toQString();Executed by:
executed 66 times by 3 tests: return s->toQString();Executed by:
| 66 | ||||||||||||
| 134 | } | - | ||||||||||||
| 135 | - | |||||||||||||
| 136 | uint RegExpObject::flags() const | - | ||||||||||||
| 137 | { | - | ||||||||||||
| 138 | uint f = 0; | - | ||||||||||||
| 139 | if (global()
| 0-4 | ||||||||||||
| 140 | f |= QV4::RegExpObject::RegExp_Global; never executed: f |= QV4::RegExpObject::RegExp_Global; | 0 | ||||||||||||
| 141 | if (value()->ignoreCase
| 0-4 | ||||||||||||
| 142 | f |= QV4::RegExpObject::RegExp_IgnoreCase; executed 4 times by 1 test: f |= QV4::RegExpObject::RegExp_IgnoreCase;Executed by:
| 4 | ||||||||||||
| 143 | if (value()->multiLine
| 0-4 | ||||||||||||
| 144 | f |= QV4::RegExpObject::RegExp_Multiline; never executed: f |= QV4::RegExpObject::RegExp_Multiline; | 0 | ||||||||||||
| 145 | return executed 4 times by 1 test: f;return f;Executed by:
executed 4 times by 1 test: return f;Executed by:
| 4 | ||||||||||||
| 146 | } | - | ||||||||||||
| 147 | - | |||||||||||||
| 148 | const QV4::VTable RegExpCtor::static_vtbl = { (std::is_same<RegExpCtor::SuperClass, Object>::value) ? nullptr : &RegExpCtor::SuperClass::static_vtbl, (sizeof(RegExpCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), (sizeof(RegExpCtor::Data) + (RegExpCtor::NInlineProperties*sizeof(QV4::Value)) + QV4::Chunk::SlotSize - 1)/QV4::Chunk::SlotSize*QV4::Chunk::SlotSize/sizeof(QV4::Value) - (sizeof(RegExpCtor::Data) + sizeof(QV4::Value) - 1)/sizeof(QV4::Value), RegExpCtor::IsExecutionContext, RegExpCtor::IsString, RegExpCtor::IsObject, RegExpCtor::IsFunctionObject, RegExpCtor::IsErrorObject, RegExpCtor::IsArrayData, RegExpCtor::IsStringOrSymbol, RegExpCtor::MyType, { 0, 0, 0, 0 }, "RegExpCtor", RegExpCtor::virtualDestroy, RegExpCtor::Data::markObjects, RegExpCtor::virtualIsEqualTo, RegExpCtor::virtualGet, RegExpCtor::virtualPut, RegExpCtor::virtualDeleteProperty, RegExpCtor::virtualHasProperty, RegExpCtor::virtualGetOwnProperty, RegExpCtor::virtualDefineOwnProperty, RegExpCtor::virtualIsExtensible, RegExpCtor::virtualPreventExtensions, RegExpCtor::virtualGetPrototypeOf, RegExpCtor::virtualSetPrototypeOf, RegExpCtor::virtualGetLength, RegExpCtor::virtualAdvanceIterator, RegExpCtor::virtualInstanceOf, RegExpCtor::virtualCall, RegExpCtor::virtualCallAsConstructor, }; | - | ||||||||||||
| 149 | - | |||||||||||||
| 150 | void Heap::RegExpCtor::init(QV4::ExecutionContext *scope) | - | ||||||||||||
| 151 | { | - | ||||||||||||
| 152 | Heap::FunctionObject::init(scope, ([]() noexcept -> QString { enum { Size = sizeof(u"" "RegExp")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "RegExp" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98517 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98517 times by 153 tests: }()));return qstring_literal_temp;Executed by:
| 98517 | ||||||||||||
| 153 | clearLastMatch(); | - | ||||||||||||
| 154 | } executed 98920 times by 153 tests: end of blockExecuted by:
| 98920 | ||||||||||||
| 155 | - | |||||||||||||
| 156 | void Heap::RegExpCtor::clearLastMatch() | - | ||||||||||||
| 157 | { | - | ||||||||||||
| 158 | lastMatch.set(internalClass->engine, Primitive::nullValue()); | - | ||||||||||||
| 159 | lastInput.set(internalClass->engine, internalClass->engine->id_empty()->d()); | - | ||||||||||||
| 160 | lastMatchStart = 0; | - | ||||||||||||
| 161 | lastMatchEnd = 0; | - | ||||||||||||
| 162 | } executed 106845 times by 153 tests: end of blockExecuted by:
| 106845 | ||||||||||||
| 163 | - | |||||||||||||
| 164 | ReturnedValue RegExpCtor::virtualCallAsConstructor(const FunctionObject *fo, const Value *argv, int argc, const Value *) | - | ||||||||||||
| 165 | { | - | ||||||||||||
| 166 | Scope scope(fo->engine()); | - | ||||||||||||
| 167 | ScopedValue r(scope, argc ? argv[0] : Primitive::undefinedValue()); | - | ||||||||||||
| 168 | ScopedValue f(scope, argc > 1 ? argv[1] : Primitive::undefinedValue()); | - | ||||||||||||
| 169 | Scoped<RegExpObject> re(scope, r); | - | ||||||||||||
| 170 | if (re
| 46-4088 | ||||||||||||
| 171 | if (!f->isUndefined()
| 22-25 | ||||||||||||
| 172 | return executed 22 times by 2 tests: scope.engine->throwTypeError();return scope.engine->throwTypeError();Executed by:
executed 22 times by 2 tests: return scope.engine->throwTypeError();Executed by:
| 22 | ||||||||||||
| 173 | - | |||||||||||||
| 174 | Scoped<RegExp> regexp(scope, re->value()); | - | ||||||||||||
| 175 | return executed 26 times by 2 tests: Encode(scope.engine->newRegExpObject(regexp));return Encode(scope.engine->newRegExpObject(regexp));Executed by:
executed 26 times by 2 tests: return Encode(scope.engine->newRegExpObject(regexp));Executed by:
| 26 | ||||||||||||
| 176 | } | - | ||||||||||||
| 177 | - | |||||||||||||
| 178 | QString pattern; | - | ||||||||||||
| 179 | if (!r->isUndefined()
| 474-3615 | ||||||||||||
| 180 | pattern = r->toQString(); executed 3613 times by 3 tests: pattern = r->toQString();Executed by:
| 3613 | ||||||||||||
| 181 | if (scope.hasException()
| 27-4067 | ||||||||||||
| 182 | return executed 27 times by 1 test: Encode::undefined();return Encode::undefined();Executed by:
executed 27 times by 1 test: return Encode::undefined();Executed by:
| 27 | ||||||||||||
| 183 | - | |||||||||||||
| 184 | bool global = false; | - | ||||||||||||
| 185 | bool ignoreCase = false; | - | ||||||||||||
| 186 | bool multiLine = false; | - | ||||||||||||
| 187 | if (!f->isUndefined()
| 1977-2092 | ||||||||||||
| 188 | ScopedString s(scope, f->toString(scope.engine)); | - | ||||||||||||
| 189 | if (scope.hasException()
| 8-2083 | ||||||||||||
| 190 | return executed 8 times by 1 test: Encode::undefined();return Encode::undefined();Executed by:
executed 8 times by 1 test: return Encode::undefined();Executed by:
| 8 | ||||||||||||
| 191 | QString str = s->toQString(); | - | ||||||||||||
| 192 | for (int i = 0; i < str.length()
| 198-2144 | ||||||||||||
| 193 | if (str.at(i) == QLatin1Char('g')
| 0-1966 | ||||||||||||
| 194 | global = true; | - | ||||||||||||
| 195 | } executed 178 times by 2 tests: else if (str.at(i) == QLatin1Char('i')end of blockExecuted by:
| 4-1918 | ||||||||||||
| 196 | ignoreCase = true; | - | ||||||||||||
| 197 | } executed 44 times by 2 tests: else if (str.at(i) == QLatin1Char('m')end of blockExecuted by:
| 0-1886 | ||||||||||||
| 198 | multiLine = true; | - | ||||||||||||
| 199 | } executed 36 times by 2 tests: else {end of blockExecuted by:
| 36 | ||||||||||||
| 200 | return executed 1886 times by 2 tests: scope.engine->throwSyntaxError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Invalid flags supplied to RegExp constructor")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid flags supplied to RegExp constructor" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn scope.engine->throwSyntaxError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Invalid flags supplied to RegExp constructor")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid flags supplied to RegExp constructor" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));Executed by:
executed 1883 times by 2 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 1883 times by 2 tests: }()));return qstring_literal_temp;Executed by:
executed 1886 times by 2 tests: return scope.engine->throwSyntaxError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Invalid flags supplied to RegExp constructor")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid flags supplied to RegExp constructor" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));Executed by:
| 1883-1886 | ||||||||||||
| 201 | } | - | ||||||||||||
| 202 | } | - | ||||||||||||
| 203 | } executed 198 times by 2 tests: end of blockExecuted by:
| 198 | ||||||||||||
| 204 | - | |||||||||||||
| 205 | Scoped<RegExp> regexp(scope, RegExp::create(scope.engine, pattern, ignoreCase, multiLine, global)); | - | ||||||||||||
| 206 | if (!regexp->isValid()
| 251-1923 | ||||||||||||
| 207 | return executed 249 times by 1 test: scope.engine->throwSyntaxError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Invalid regular expression")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid regular expression" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); returnreturn scope.engine->throwSyntaxError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Invalid regular expression")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid regular expression" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));Executed by:
executed 251 times by 1 test: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 251 times by 1 test: }()));return qstring_literal_temp;Executed by:
executed 249 times by 1 test: return scope.engine->throwSyntaxError(([]() noexcept -> QString { enum { Size = sizeof(u"" "Invalid regular expression")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Invalid regular expression" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()));Executed by:
| 249-251 | ||||||||||||
| 208 | } | - | ||||||||||||
| 209 | - | |||||||||||||
| 210 | return executed 1925 times by 3 tests: Encode(scope.engine->newRegExpObject(regexp));return Encode(scope.engine->newRegExpObject(regexp));Executed by:
executed 1925 times by 3 tests: return Encode(scope.engine->newRegExpObject(regexp));Executed by:
| 1925 | ||||||||||||
| 211 | } | - | ||||||||||||
| 212 | - | |||||||||||||
| 213 | ReturnedValue RegExpCtor::virtualCall(const FunctionObject *f, const Value *, const Value *argv, int argc) | - | ||||||||||||
| 214 | { | - | ||||||||||||
| 215 | if (argc > 0
| 8-1958 | ||||||||||||
| 216 | if (argc == 1
| 10-26 | ||||||||||||
| 217 | return executed 30 times by 2 tests: Encode(argv[0]);return Encode(argv[0]);Executed by:
executed 30 times by 2 tests: return Encode(argv[0]);Executed by:
| 30 | ||||||||||||
| 218 | } executed 10 times by 2 tests: end of blockExecuted by:
| 10 | ||||||||||||
| 219 | - | |||||||||||||
| 220 | return executed 1936 times by 3 tests: virtualCallAsConstructor(f, argv, argc, f);return virtualCallAsConstructor(f, argv, argc, f);Executed by:
executed 1936 times by 3 tests: return virtualCallAsConstructor(f, argv, argc, f);Executed by:
| 1936 | ||||||||||||
| 221 | } | - | ||||||||||||
| 222 | - | |||||||||||||
| 223 | void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor) | - | ||||||||||||
| 224 | { | - | ||||||||||||
| 225 | Scope scope(engine); | - | ||||||||||||
| 226 | ScopedObject o(scope); | - | ||||||||||||
| 227 | ScopedObject ctor(scope, constructor); | - | ||||||||||||
| 228 | - | |||||||||||||
| 229 | ctor->defineReadonlyProperty(engine->id_prototype(), (o = this)); | - | ||||||||||||
| 230 | ctor->defineReadonlyConfigurableProperty(engine->id_length(), Primitive::fromInt32(2)); | - | ||||||||||||
| 231 | ctor->addSymbolSpecies(); | - | ||||||||||||
| 232 | - | |||||||||||||
| 233 | - | |||||||||||||
| 234 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "lastMatch")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "lastMatch" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98240 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98240 times by 153 tests: }()), method_get_lastMatch_n<0>, nullptr);return qstring_literal_temp;Executed by:
| 98240 | ||||||||||||
| 235 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$&")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$&" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98598 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98598 times by 153 tests: }()), method_get_lastMatch_n<0>, nullptr);return qstring_literal_temp;Executed by:
| 98598 | ||||||||||||
| 236 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$1")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$1" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98506 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98506 times by 153 tests: }()), method_get_lastMatch_n<1>, nullptr);return qstring_literal_temp;Executed by:
| 98506 | ||||||||||||
| 237 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$2")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$2" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98913 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98913 times by 153 tests: }()), method_get_lastMatch_n<2>, nullptr);return qstring_literal_temp;Executed by:
| 98913 | ||||||||||||
| 238 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$3")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$3" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99099 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99099 times by 153 tests: }()), method_get_lastMatch_n<3>, nullptr);return qstring_literal_temp;Executed by:
| 99099 | ||||||||||||
| 239 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$4")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$4" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99049 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99049 times by 153 tests: }()), method_get_lastMatch_n<4>, nullptr);return qstring_literal_temp;Executed by:
| 99049 | ||||||||||||
| 240 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$5")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$5" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99077 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99077 times by 153 tests: }()), method_get_lastMatch_n<5>, nullptr);return qstring_literal_temp;Executed by:
| 99077 | ||||||||||||
| 241 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$6")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$6" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99030 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99030 times by 153 tests: }()), method_get_lastMatch_n<6>, nullptr);return qstring_literal_temp;Executed by:
| 99030 | ||||||||||||
| 242 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$7")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$7" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99045 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99045 times by 153 tests: }()), method_get_lastMatch_n<7>, nullptr);return qstring_literal_temp;Executed by:
| 99045 | ||||||||||||
| 243 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$8")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$8" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98900 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98900 times by 153 tests: }()), method_get_lastMatch_n<8>, nullptr);return qstring_literal_temp;Executed by:
| 98900 | ||||||||||||
| 244 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$9")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$9" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98561 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98561 times by 153 tests: }()), method_get_lastMatch_n<9>, nullptr);return qstring_literal_temp;Executed by:
| 98561 | ||||||||||||
| 245 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "lastParen")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "lastParen" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99030 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99030 times by 153 tests: }()), method_get_lastParen, nullptr);return qstring_literal_temp;Executed by:
| 99030 | ||||||||||||
| 246 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$+")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$+" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98953 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98953 times by 153 tests: }()), method_get_lastParen, nullptr);return qstring_literal_temp;Executed by:
| 98953 | ||||||||||||
| 247 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "input")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "input" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98778 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98778 times by 153 tests: }()), method_get_input, nullptr);return qstring_literal_temp;Executed by:
| 98778 | ||||||||||||
| 248 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$_")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$_" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 99108 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 99108 times by 153 tests: }()), method_get_input, nullptr);return qstring_literal_temp;Executed by:
| 99108 | ||||||||||||
| 249 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "leftContext")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "leftContext" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98988 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98988 times by 153 tests: }()), method_get_leftContext, nullptr);return qstring_literal_temp;Executed by:
| 98988 | ||||||||||||
| 250 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$`")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$`" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98930 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98930 times by 153 tests: }()), method_get_leftContext, nullptr);return qstring_literal_temp;Executed by:
| 98930 | ||||||||||||
| 251 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "rightContext")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "rightContext" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98848 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98848 times by 153 tests: }()), method_get_rightContext, nullptr);return qstring_literal_temp;Executed by:
| 98848 | ||||||||||||
| 252 | ctor->defineAccessorProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "$'")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "$'" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98409 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98409 times by 153 tests: }()), method_get_rightContext, nullptr);return qstring_literal_temp;Executed by:
| 98409 | ||||||||||||
| 253 | - | |||||||||||||
| 254 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "constructor")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "constructor" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98728 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98728 times by 153 tests: }()), (o = ctor));return qstring_literal_temp;Executed by:
| 98728 | ||||||||||||
| 255 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "exec")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "exec" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98892 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98892 times by 153 tests: }()), method_exec, 1);return qstring_literal_temp;Executed by:
| 98892 | ||||||||||||
| 256 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "test")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "test" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98868 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98868 times by 153 tests: }()), method_test, 1);return qstring_literal_temp;Executed by:
| 98868 | ||||||||||||
| 257 | defineDefaultProperty(engine->id_toString(), method_toString, 0); | - | ||||||||||||
| 258 | defineDefaultProperty(([]() noexcept -> QString { enum { Size = sizeof(u"" "compile")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "compile" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return executed 98665 times by 153 tests: qstring_literal_temp;return qstring_literal_temp;Executed by:
executed 98665 times by 153 tests: }()), method_compile, 2);return qstring_literal_temp;Executed by:
| 98665 | ||||||||||||
| 259 | } executed 98937 times by 153 tests: end of blockExecuted by:
| 98937 | ||||||||||||
| 260 | - | |||||||||||||
| 261 | - | |||||||||||||
| 262 | ReturnedValue RegExpPrototype::execFirstMatch(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
| 263 | { | - | ||||||||||||
| 264 | Scope scope(b); | - | ||||||||||||
| 265 | Scoped<RegExpObject> r(scope, thisObject->as<RegExpObject>()); | - | ||||||||||||
| 266 | ((r && r->global()) ? static_cast<void>(0) : qt_assert("r && r->global()", __FILE__, 315)); | - | ||||||||||||
| 267 | - | |||||||||||||
| 268 | ScopedString str(scope, argc ? argv[0] : Primitive::undefinedValue()); | - | ||||||||||||
| 269 | ((str) ? static_cast<void>(0) : qt_assert("str", __FILE__, 318)); | - | ||||||||||||
| 270 | QString s = str->toQString(); | - | ||||||||||||
| 271 | - | |||||||||||||
| 272 | int offset = r->lastIndex(); | - | ||||||||||||
| 273 | if (offset < 0
| 0-820 | ||||||||||||
| 274 | r->setLastIndex(0); | - | ||||||||||||
| 275 | return never executed: QV4::Encode(Encode::null());return QV4::Encode(Encode::null());never executed: return QV4::Encode(Encode::null()); | 0 | ||||||||||||
| 276 | } | - | ||||||||||||
| 277 | - | |||||||||||||
| 278 | uint *matchOffsets = 0; matchOffsets = static_cast<uint*>( | - | ||||||||||||
| 279 | __builtin_alloca ( | - | ||||||||||||
| 280 | r->value()->captureCount() * 2 * sizeof(uint) | - | ||||||||||||
| 281 | ) | - | ||||||||||||
| 282 | ); | - | ||||||||||||
| 283 | const int result = Scoped<RegExp>(scope, r->value())->match(s, offset, matchOffsets); | - | ||||||||||||
| 284 | - | |||||||||||||
| 285 | RegExpCtor *regExpCtor = static_cast<RegExpCtor *>(scope.engine->regExpCtor()); | - | ||||||||||||
| 286 | regExpCtor->d()->clearLastMatch(); | - | ||||||||||||
| 287 | - | |||||||||||||
| 288 | if (result == -1
| 144-679 | ||||||||||||
| 289 | r->setLastIndex(0); | - | ||||||||||||
| 290 | return executed 144 times by 1 test: QV4::Encode(Encode::null());return QV4::Encode(Encode::null());Executed by:
executed 144 times by 1 test: return QV4::Encode(Encode::null());Executed by:
| 144 | ||||||||||||
| 291 | } | - | ||||||||||||
| 292 | - | |||||||||||||
| 293 | ReturnedValue retVal = Encode::undefined(); | - | ||||||||||||
| 294 | - | |||||||||||||
| 295 | if (r->value()->captureCount()
| 0-678 | ||||||||||||
| 296 | int start = matchOffsets[0]; | - | ||||||||||||
| 297 | int end = matchOffsets[1]; | - | ||||||||||||
| 298 | retVal = (
| 0-677 | ||||||||||||
| 299 | } executed 678 times by 1 test: end of blockExecuted by:
| 678 | ||||||||||||
| 300 | - | |||||||||||||
| 301 | RegExpCtor::Data *dd = regExpCtor->d(); | - | ||||||||||||
| 302 | dd->lastInput.set(scope.engine, str->d()); | - | ||||||||||||
| 303 | dd->lastMatchStart = matchOffsets[0]; | - | ||||||||||||
| 304 | dd->lastMatchEnd = matchOffsets[1]; | - | ||||||||||||
| 305 | - | |||||||||||||
| 306 | r->setLastIndex(matchOffsets[1]); | - | ||||||||||||
| 307 | - | |||||||||||||
| 308 | return executed 677 times by 1 test: retVal;return retVal;Executed by:
executed 677 times by 1 test: return retVal;Executed by:
| 677 | ||||||||||||
| 309 | } | - | ||||||||||||
| 310 | - | |||||||||||||
| 311 | ReturnedValue RegExpPrototype::method_exec(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
| 312 | { | - | ||||||||||||
| 313 | Scope scope(b); | - | ||||||||||||
| 314 | Scoped<RegExpObject> r(scope, thisObject->as<RegExpObject>()); | - | ||||||||||||
| 315 | if (!r
| 80-7397 | ||||||||||||
| 316 | return executed 80 times by 1 test: scope.engine->throwTypeError();return scope.engine->throwTypeError();Executed by:
executed 80 times by 1 test: return scope.engine->throwTypeError();Executed by:
| 80 | ||||||||||||
| 317 | - | |||||||||||||
| 318 | ScopedValue arg(scope, argc ? argv[0]: Primitive::undefinedValue()); | - | ||||||||||||
| 319 | ScopedString str(scope, arg->toString(scope.engine)); | - | ||||||||||||
| 320 | if (scope.hasException()
| 16-7389 | ||||||||||||
| 321 | return executed 15 times by 1 test: QV4::Encode::undefined();return QV4::Encode::undefined();Executed by:
executed 15 times by 1 test: return QV4::Encode::undefined();Executed by:
| 15 | ||||||||||||
| 322 | QString s = str->toQString(); | - | ||||||||||||
| 323 | - | |||||||||||||
| 324 | int offset = r->global()
| 1728-5661 | ||||||||||||
| 325 | if (offset < 0
| 12-7375 | ||||||||||||
| 326 | r->setLastIndex(0); | - | ||||||||||||
| 327 | return executed 24 times by 1 test: QV4::Encode(Encode::null());return QV4::Encode(Encode::null());Executed by:
executed 24 times by 1 test: return QV4::Encode(Encode::null());Executed by:
| 24 | ||||||||||||
| 328 | } | - | ||||||||||||
| 329 | - | |||||||||||||
| 330 | uint *matchOffsets = 0; matchOffsets = static_cast<uint*>( | - | ||||||||||||
| 331 | __builtin_alloca ( | - | ||||||||||||
| 332 | r->value()->captureCount() * 2 * sizeof(uint) | - | ||||||||||||
| 333 | ) | - | ||||||||||||
| 334 | ); | - | ||||||||||||
| 335 | const int result = Scoped<RegExp>(scope, r->value())->match(s, offset, matchOffsets); | - | ||||||||||||
| 336 | - | |||||||||||||
| 337 | RegExpCtor *regExpCtor = static_cast<RegExpCtor *>(scope.engine->regExpCtor()); | - | ||||||||||||
| 338 | regExpCtor->d()->clearLastMatch(); | - | ||||||||||||
| 339 | - | |||||||||||||
| 340 | if (result == -1
| 1848-5523 | ||||||||||||
| 341 | r->setLastIndex(0); | - | ||||||||||||
| 342 | return executed 1847 times by 1 test: QV4::Encode(Encode::null());return QV4::Encode(Encode::null());Executed by:
executed 1847 times by 1 test: return QV4::Encode(Encode::null());Executed by:
| 1847 | ||||||||||||
| 343 | } | - | ||||||||||||
| 344 | - | |||||||||||||
| 345 | - | |||||||||||||
| 346 | ScopedArrayObject array(scope, scope.engine->newArrayObject(scope.engine->internalClasses(EngineBase::Class_RegExpExecArray))); | - | ||||||||||||
| 347 | int len = r->value()->captureCount(); | - | ||||||||||||
| 348 | array->arrayReserve(len); | - | ||||||||||||
| 349 | ScopedValue v(scope); | - | ||||||||||||
| 350 | for (int i = 0; i < len
| 5522-8040 | ||||||||||||
| 351 | int start = matchOffsets[i * 2]; | - | ||||||||||||
| 352 | int end = matchOffsets[i * 2 + 1]; | - | ||||||||||||
| 353 | v = (
| 732-7303 | ||||||||||||
| 354 | array->arrayPut(i, v); | - | ||||||||||||
| 355 | } executed 8041 times by 2 tests: end of blockExecuted by:
| 8041 | ||||||||||||
| 356 | array->setArrayLengthUnchecked(len); | - | ||||||||||||
| 357 | array->setProperty(Index_ArrayIndex, Primitive::fromInt32(result)); | - | ||||||||||||
| 358 | array->setProperty(Index_ArrayInput, str); | - | ||||||||||||
| 359 | - | |||||||||||||
| 360 | RegExpCtor::Data *dd = regExpCtor->d(); | - | ||||||||||||
| 361 | dd->lastMatch.set(scope.engine, array); | - | ||||||||||||
| 362 | dd->lastInput.set(scope.engine, str->d()); | - | ||||||||||||
| 363 | dd->lastMatchStart = matchOffsets[0]; | - | ||||||||||||
| 364 | dd->lastMatchEnd = matchOffsets[1]; | - | ||||||||||||
| 365 | - | |||||||||||||
| 366 | if (r->global()
| 1655-3860 | ||||||||||||
| 367 | r->setLastIndex(matchOffsets[1]); executed 1655 times by 2 tests: r->setLastIndex(matchOffsets[1]);Executed by:
| 1655 | ||||||||||||
| 368 | - | |||||||||||||
| 369 | return executed 5515 times by 2 tests: array.asReturnedValue();return array.asReturnedValue();Executed by:
executed 5515 times by 2 tests: return array.asReturnedValue();Executed by:
| 5515 | ||||||||||||
| 370 | } | - | ||||||||||||
| 371 | - | |||||||||||||
| 372 | ReturnedValue RegExpPrototype::method_test(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
| 373 | { | - | ||||||||||||
| 374 | Value res = Value::fromReturnedValue(method_exec(b, thisObject, argv, argc)); | - | ||||||||||||
| 375 | return executed 694 times by 1 test: Encode(!res.isNull());return Encode(!res.isNull());Executed by:
executed 694 times by 1 test: return Encode(!res.isNull());Executed by:
| 694 | ||||||||||||
| 376 | } | - | ||||||||||||
| 377 | - | |||||||||||||
| 378 | ReturnedValue RegExpPrototype::method_toString(const FunctionObject *b, const Value *thisObject, const Value *, int) | - | ||||||||||||
| 379 | { | - | ||||||||||||
| 380 | ExecutionEngine *v4 = b->engine(); | - | ||||||||||||
| 381 | const RegExpObject *r = thisObject->as<RegExpObject>(); | - | ||||||||||||
| 382 | if (!r
| 0-62 | ||||||||||||
| 383 | return never executed: v4->throwTypeError();return v4->throwTypeError();never executed: return v4->throwTypeError(); | 0 | ||||||||||||
| 384 | - | |||||||||||||
| 385 | return executed 62 times by 2 tests: Encode(v4->newString(r->toString()));return Encode(v4->newString(r->toString()));Executed by:
executed 62 times by 2 tests: return Encode(v4->newString(r->toString()));Executed by:
| 62 | ||||||||||||
| 386 | } | - | ||||||||||||
| 387 | - | |||||||||||||
| 388 | ReturnedValue RegExpPrototype::method_compile(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc) | - | ||||||||||||
| 389 | { | - | ||||||||||||
| 390 | Scope scope(b); | - | ||||||||||||
| 391 | Scoped<RegExpObject> r(scope, thisObject->as<RegExpObject>()); | - | ||||||||||||
| 392 | if (!r
| 0 | ||||||||||||
| 393 | return never executed: scope.engine->throwTypeError();return scope.engine->throwTypeError();never executed: return scope.engine->throwTypeError(); | 0 | ||||||||||||
| 394 | - | |||||||||||||
| 395 | Scoped<RegExpObject> re(scope, scope.engine->regExpCtor()->callAsConstructor(argv, argc)); | - | ||||||||||||
| 396 | - | |||||||||||||
| 397 | r->d()->value.set(scope.engine, re->value()); | - | ||||||||||||
| 398 | return never executed: Encode::undefined();return Encode::undefined();never executed: return Encode::undefined(); | 0 | ||||||||||||
| 399 | } | - | ||||||||||||
| 400 | - | |||||||||||||
| 401 | template <uint index> | - | ||||||||||||
| 402 | ReturnedValue RegExpPrototype::method_get_lastMatch_n(const FunctionObject *b, const Value *, const Value *, int) | - | ||||||||||||
| 403 | { | - | ||||||||||||
| 404 | Scope scope(b); | - | ||||||||||||
| 405 | ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(scope.engine->regExpCtor())->lastMatch()); | - | ||||||||||||
| 406 | ScopedValue res(scope, lastMatch ? lastMatch->get(index) : Encode::undefined()); | - | ||||||||||||
| 407 | if (res->isUndefined()
| 8-30 | ||||||||||||
| 408 | res = scope.engine->newString(); executed 30 times by 1 test: res = scope.engine->newString();Executed by:
| 30 | ||||||||||||
| 409 | return executed 38 times by 1 test: res->asReturnedValue();return res->asReturnedValue();Executed by:
executed 38 times by 1 test: return res->asReturnedValue();Executed by:
| 38 | ||||||||||||
| 410 | } | - | ||||||||||||
| 411 | - | |||||||||||||
| 412 | ReturnedValue RegExpPrototype::method_get_lastParen(const FunctionObject *b, const Value *, const Value *, int) | - | ||||||||||||
| 413 | { | - | ||||||||||||
| 414 | Scope scope(b); | - | ||||||||||||
| 415 | ScopedArrayObject lastMatch(scope, static_cast<RegExpCtor*>(scope.engine->regExpCtor())->lastMatch()); | - | ||||||||||||
| 416 | ScopedValue res(scope, lastMatch ? lastMatch->get(lastMatch->getLength() - 1) : Encode::undefined()); | - | ||||||||||||
| 417 | if (res->isUndefined()
| 0-2 | ||||||||||||
| 418 | res = scope.engine->newString(); never executed: res = scope.engine->newString(); | 0 | ||||||||||||
| 419 | return executed 2 times by 1 test: res->asReturnedValue();return res->asReturnedValue();Executed by:
executed 2 times by 1 test: return res->asReturnedValue();Executed by:
| 2 | ||||||||||||
| 420 | } | - | ||||||||||||
| 421 | - | |||||||||||||
| 422 | ReturnedValue RegExpPrototype::method_get_input(const FunctionObject *b, const Value *, const Value *, int) | - | ||||||||||||
| 423 | { | - | ||||||||||||
| 424 | return executed 4 times by 1 test: static_cast<RegExpCtor*>(b->engine()->regExpCtor())->lastInput()->asReturnedValue();return static_cast<RegExpCtor*>(b->engine()->regExpCtor())->lastInput()->asReturnedValue();Executed by:
executed 4 times by 1 test: return static_cast<RegExpCtor*>(b->engine()->regExpCtor())->lastInput()->asReturnedValue();Executed by:
| 4 | ||||||||||||
| 425 | } | - | ||||||||||||
| 426 | - | |||||||||||||
| 427 | ReturnedValue RegExpPrototype::method_get_leftContext(const FunctionObject *b, const Value *, const Value *, int) | - | ||||||||||||
| 428 | { | - | ||||||||||||
| 429 | Scope scope(b); | - | ||||||||||||
| 430 | Scoped<RegExpCtor> regExpCtor(scope, scope.engine->regExpCtor()); | - | ||||||||||||
| 431 | QString lastInput = regExpCtor->lastInput()->toQString(); | - | ||||||||||||
| 432 | return executed 2 times by 1 test: Encode(scope.engine->newString(lastInput.left(regExpCtor->lastMatchStart())));return Encode(scope.engine->newString(lastInput.left(regExpCtor->lastMatchStart())));Executed by:
executed 2 times by 1 test: return Encode(scope.engine->newString(lastInput.left(regExpCtor->lastMatchStart())));Executed by:
| 2 | ||||||||||||
| 433 | } | - | ||||||||||||
| 434 | - | |||||||||||||
| 435 | ReturnedValue RegExpPrototype::method_get_rightContext(const FunctionObject *b, const Value *, const Value *, int) | - | ||||||||||||
| 436 | { | - | ||||||||||||
| 437 | Scope scope(b); | - | ||||||||||||
| 438 | Scoped<RegExpCtor> regExpCtor(scope, scope.engine->regExpCtor()); | - | ||||||||||||
| 439 | QString lastInput = regExpCtor->lastInput()->toQString(); | - | ||||||||||||
| 440 | return executed 2 times by 1 test: Encode(scope.engine->newString(lastInput.mid(regExpCtor->lastMatchEnd())));return Encode(scope.engine->newString(lastInput.mid(regExpCtor->lastMatchEnd())));Executed by:
executed 2 times by 1 test: return Encode(scope.engine->newString(lastInput.mid(regExpCtor->lastMatchEnd())));Executed by:
| 2 | ||||||||||||
| 441 | } | - | ||||||||||||
| 442 | - | |||||||||||||
| 443 | - | |||||||||||||
| Switch to Source code | Preprocessed file |