Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/qml/jsruntime/qv4regexpobject_p.h |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | /**************************************************************************** | - | ||||||
2 | ** | - | ||||||
3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
5 | ** | - | ||||||
6 | ** This file is part of the QtQml module of the Qt Toolkit. | - | ||||||
7 | ** | - | ||||||
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||
9 | ** Commercial License Usage | - | ||||||
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||
11 | ** accordance with the commercial license agreement provided with the | - | ||||||
12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||
13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||
14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||
15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||
16 | ** | - | ||||||
17 | ** GNU Lesser General Public License Usage | - | ||||||
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||
19 | ** General Public License version 3 as published by the Free Software | - | ||||||
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||
21 | ** packaging of this file. Please review the following information to | - | ||||||
22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||
24 | ** | - | ||||||
25 | ** GNU General Public License Usage | - | ||||||
26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||
27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||
28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||
29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||
31 | ** included in the packaging of this file. Please review the following | - | ||||||
32 | ** information to ensure the GNU General Public License requirements will | - | ||||||
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||
35 | ** | - | ||||||
36 | ** $QT_END_LICENSE$ | - | ||||||
37 | ** | - | ||||||
38 | ****************************************************************************/ | - | ||||||
39 | #ifndef QV4REGEXPOBJECT_H | - | ||||||
40 | #define QV4REGEXPOBJECT_H | - | ||||||
41 | - | |||||||
42 | // | - | ||||||
43 | // W A R N I N G | - | ||||||
44 | // ------------- | - | ||||||
45 | // | - | ||||||
46 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
47 | // implementation detail. This header file may change from version to | - | ||||||
48 | // version without notice, or even be removed. | - | ||||||
49 | // | - | ||||||
50 | // We mean it. | - | ||||||
51 | // | - | ||||||
52 | - | |||||||
53 | #include "qv4runtime_p.h" | - | ||||||
54 | #include "qv4engine_p.h" | - | ||||||
55 | #include "qv4context_p.h" | - | ||||||
56 | #include "qv4functionobject_p.h" | - | ||||||
57 | #include "qv4string_p.h" | - | ||||||
58 | #include "qv4managed_p.h" | - | ||||||
59 | #include "qv4property_p.h" | - | ||||||
60 | #include "qv4objectiterator_p.h" | - | ||||||
61 | #include "qv4regexp_p.h" | - | ||||||
62 | - | |||||||
63 | #include <QtCore/QString> | - | ||||||
64 | #include <QtCore/QHash> | - | ||||||
65 | #include <QtCore/QScopedPointer> | - | ||||||
66 | #include <cstdio> | - | ||||||
67 | #include <cassert> | - | ||||||
68 | - | |||||||
69 | QT_BEGIN_NAMESPACE | - | ||||||
70 | - | |||||||
71 | namespace QV4 { | - | ||||||
72 | - | |||||||
73 | namespace Heap { | - | ||||||
74 | - | |||||||
75 | #define RegExpObjectMembers(class, Member) \ | - | ||||||
76 | Member(class, Pointer, RegExp *, value) | - | ||||||
77 | - | |||||||
78 | DECLARE_HEAP_OBJECT(RegExpObject, Object) { | - | ||||||
79 | DECLARE_MARKOBJECTS(RegExpObject); executed 9862 times by 26 tests: end of block Executed by:
executed 9862 times by 26 tests: o->value.heapObject()->mark(stack); Executed by:
| 0-9862 | ||||||
80 | - | |||||||
81 | void init(); | - | ||||||
82 | void init(QV4::RegExp *value); | - | ||||||
83 | void init(const QRegExp &re); | - | ||||||
84 | }; | - | ||||||
85 | - | |||||||
86 | #define RegExpCtorMembers(class, Member) \ | - | ||||||
87 | Member(class, HeapValue, HeapValue, lastMatch) \ | - | ||||||
88 | Member(class, Pointer, String *, lastInput) \ | - | ||||||
89 | Member(class, NoMark, int, lastMatchStart) \ | - | ||||||
90 | Member(class, NoMark, int, lastMatchEnd) | - | ||||||
91 | - | |||||||
92 | DECLARE_HEAP_OBJECT(RegExpCtor, FunctionObject) { | - | ||||||
93 | DECLARE_MARKOBJECTS(RegExpCtor); executed 8854 times by 26 tests: end of block Executed by:
executed 8854 times by 26 tests: o->lastInput.heapObject()->mark(stack); Executed by:
| 0-8854 | ||||||
94 | - | |||||||
95 | void init(QV4::ExecutionContext *scope); | - | ||||||
96 | void clearLastMatch(); | - | ||||||
97 | }; | - | ||||||
98 | - | |||||||
99 | } | - | ||||||
100 | - | |||||||
101 | struct RegExpObject: Object { | - | ||||||
102 | V4_OBJECT2(RegExpObject, Object) executed 41791 times by 42 tests: end of block Executed by:
never executed: end of block executed 3505589 times by 153 tests: return &static_vtbl; Executed by:
executed 7929167 times by 153 tests: return static_cast<QV4::Heap::RegExpObject *>(m()); Executed by:
executed 6874176 times by 153 tests: return dptr; Executed by:
| 0-7929167 | ||||||
103 | Q_MANAGED_TYPE(RegExpObject) | - | ||||||
104 | V4_INTERNALCLASS(RegExpObject) executed 1054956 times by 9 tests: return e->internalClasses(QV4::EngineBase::Class_RegExpObject); Executed by:
| 1054956 | ||||||
105 | V4_PROTOTYPE(regExpPrototype) executed 1055133 times by 9 tests: return e->regExpPrototype(); Executed by:
| 1055133 | ||||||
106 | - | |||||||
107 | // needs to be compatible with the flags in qv4compileddata_p.h | - | ||||||
108 | enum Flags { | - | ||||||
109 | RegExp_Global = 0x01, | - | ||||||
110 | RegExp_IgnoreCase = 0x02, | - | ||||||
111 | RegExp_Multiline = 0x04 | - | ||||||
112 | }; | - | ||||||
113 | - | |||||||
114 | enum { | - | ||||||
115 | Index_LastIndex = 0, | - | ||||||
116 | Index_Source = 1, | - | ||||||
117 | Index_Global = 2, | - | ||||||
118 | Index_IgnoreCase = 3, | - | ||||||
119 | Index_Multiline = 4, | - | ||||||
120 | Index_ArrayIndex = Heap::ArrayObject::LengthPropertyIndex + 1, | - | ||||||
121 | Index_ArrayInput = Index_ArrayIndex + 1 | - | ||||||
122 | }; | - | ||||||
123 | - | |||||||
124 | enum { NInlineProperties = 5 }; | - | ||||||
125 | - | |||||||
126 | Heap::RegExp *value() const { return d()->value; } executed 4647372 times by 153 tests: return d()->value; Executed by:
| 4647372 | ||||||
127 | bool global() const { return d()->value->global; } executed 1171453 times by 153 tests: return d()->value->global; Executed by:
| 1171453 | ||||||
128 | - | |||||||
129 | void initProperties(); | - | ||||||
130 | - | |||||||
131 | int lastIndex() const { | - | ||||||
132 | Q_ASSERT(Index_LastIndex == internalClass()->find(engine()->id_lastIndex()->propertyKey())); | - | ||||||
133 | return propertyData(Index_LastIndex)->toInt32(); executed 3226 times by 2 tests: return propertyData(Index_LastIndex)->toInt32(); Executed by:
| 3226 | ||||||
134 | } | - | ||||||
135 | void setLastIndex(int index) { | - | ||||||
136 | Q_ASSERT(Index_LastIndex == internalClass()->find(engine()->id_lastIndex()->propertyKey())); | - | ||||||
137 | return setProperty(Index_LastIndex, Primitive::fromInt32(index)); executed 6632 times by 3 tests: return setProperty(Index_LastIndex, Primitive::fromInt32(index)); Executed by:
| 6632 | ||||||
138 | } | - | ||||||
139 | - | |||||||
140 | QRegExp toQRegExp() const; | - | ||||||
141 | QString toString() const; | - | ||||||
142 | QString source() const; | - | ||||||
143 | uint flags() const; | - | ||||||
144 | }; | - | ||||||
145 | - | |||||||
146 | struct RegExpCtor: FunctionObject | - | ||||||
147 | { | - | ||||||
148 | V4_OBJECT2(RegExpCtor, FunctionObject) executed 4 times by 1 test: end of block Executed by:
never executed: end of block executed 296997 times by 153 tests: return &static_vtbl; Executed by:
executed 212323 times by 153 tests: return static_cast<QV4::Heap::RegExpCtor *>(m()); Executed by:
executed 113361 times by 153 tests: return dptr; Executed by:
| 0-296997 | ||||||
149 | - | |||||||
150 | Value lastMatch() { return d()->lastMatch; } executed 40 times by 1 test: return d()->lastMatch; Executed by:
| 40 | ||||||
151 | Heap::String *lastInput() { return d()->lastInput; } executed 8 times by 1 test: return d()->lastInput; Executed by:
| 8 | ||||||
152 | int lastMatchStart() { return d()->lastMatchStart; } executed 2 times by 1 test: return d()->lastMatchStart; Executed by:
| 2 | ||||||
153 | int lastMatchEnd() { return d()->lastMatchEnd; } executed 2 times by 1 test: return d()->lastMatchEnd; Executed by:
| 2 | ||||||
154 | - | |||||||
155 | static ReturnedValue virtualCallAsConstructor(const FunctionObject *f, const Value *argv, int argc, const Value *); | - | ||||||
156 | static ReturnedValue virtualCall(const FunctionObject *f, const Value *thisObject, const Value *argv, int argc); | - | ||||||
157 | }; | - | ||||||
158 | - | |||||||
159 | struct RegExpPrototype: RegExpObject | - | ||||||
160 | { | - | ||||||
161 | void init(ExecutionEngine *engine, Object *ctor); | - | ||||||
162 | - | |||||||
163 | static ReturnedValue method_exec(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
164 | static ReturnedValue method_test(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
165 | static ReturnedValue method_toString(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
166 | static ReturnedValue method_compile(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
167 | - | |||||||
168 | template <uint index> | - | ||||||
169 | static ReturnedValue method_get_lastMatch_n(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
170 | static ReturnedValue method_get_lastParen(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
171 | static ReturnedValue method_get_input(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
172 | static ReturnedValue method_get_leftContext(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
173 | static ReturnedValue method_get_rightContext(const FunctionObject *, const Value *thisObject, const Value *argv, int argc); | - | ||||||
174 | - | |||||||
175 | static ReturnedValue execFirstMatch(const FunctionObject *b, const Value *thisObject, const Value *argv, int argc); | - | ||||||
176 | }; | - | ||||||
177 | - | |||||||
178 | } | - | ||||||
179 | - | |||||||
180 | QT_END_NAMESPACE | - | ||||||
181 | - | |||||||
182 | #endif // QMLJS_OBJECTS_H | - | ||||||
Source code | Switch to Preprocessed file |