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 | |
4 | #ifndef QV4GLOBAL_H |
5 | #define QV4GLOBAL_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 | #include <QtCore/qglobal.h> |
19 | #include <private/qv4compilerglobal_p.h> |
20 | #include <QString> |
21 | |
22 | #include <qtqmlglobal.h> |
23 | #include <private/qtqmlglobal_p.h> |
24 | |
25 | // Do certain things depending on whether the JIT is enabled or disabled |
26 | |
27 | #if QT_CONFIG(qml_jit) |
28 | #define ENABLE_YARR_JIT 1 |
29 | #define ENABLE_JIT 1 |
30 | #define ENABLE_ASSEMBLER 1 |
31 | #else |
32 | #define ENABLE_YARR_JIT 0 |
33 | #define ENABLE_ASSEMBLER 0 |
34 | #define ENABLE_JIT 0 |
35 | #endif |
36 | |
37 | #if defined(Q_OS_QNX) && defined(_CPPLIB_VER) |
38 | #include <math.h> |
39 | #undef isnan |
40 | #undef isfinite |
41 | #undef isinf |
42 | #undef signbit |
43 | #endif |
44 | |
45 | QT_BEGIN_NAMESPACE |
46 | |
47 | namespace QV4 { |
48 | |
49 | namespace Compiler { |
50 | struct Module; |
51 | struct Context; |
52 | struct JSUnitGenerator; |
53 | class Codegen; |
54 | } |
55 | |
56 | namespace Moth { |
57 | class BytecodeGenerator; |
58 | } |
59 | |
60 | namespace Heap { |
61 | struct Base; |
62 | struct MemberData; |
63 | struct ArrayData; |
64 | |
65 | struct StringOrSymbol; |
66 | struct String; |
67 | struct Symbol; |
68 | struct Object; |
69 | struct ObjectPrototype; |
70 | |
71 | struct ExecutionContext; |
72 | struct CallContext; |
73 | struct QmlContext; |
74 | struct ScriptFunction; |
75 | struct InternalClass; |
76 | |
77 | struct BooleanObject; |
78 | struct NumberObject; |
79 | struct StringObject; |
80 | struct ArrayObject; |
81 | struct DateObject; |
82 | struct FunctionObject; |
83 | struct ErrorObject; |
84 | struct ArgumentsObject; |
85 | struct QObjectWrapper; |
86 | struct RegExpObject; |
87 | struct UrlObject; |
88 | struct UrlSearchParamsObject; |
89 | struct RegExp; |
90 | struct EvalFunction; |
91 | |
92 | struct SharedArrayBuffer; |
93 | struct ArrayBuffer; |
94 | struct DataView; |
95 | struct TypedArray; |
96 | |
97 | struct MapObject; |
98 | struct SetObject; |
99 | |
100 | struct PromiseObject; |
101 | struct PromiseCapability; |
102 | |
103 | template <typename T, size_t> struct Pointer; |
104 | } |
105 | |
106 | struct CppStackFrame; |
107 | struct JSTypesStackFrame; |
108 | struct MetaTypesStackFrame; |
109 | class MemoryManager; |
110 | class ExecutableAllocator; |
111 | struct PropertyKey; |
112 | struct StringOrSymbol; |
113 | struct String; |
114 | struct Symbol; |
115 | struct Object; |
116 | struct ObjectPrototype; |
117 | struct ObjectIterator; |
118 | struct ExecutionContext; |
119 | struct CallContext; |
120 | struct QmlContext; |
121 | struct ScriptFunction; |
122 | struct InternalClass; |
123 | struct Property; |
124 | struct Value; |
125 | template<size_t> struct HeapValue; |
126 | template<size_t> struct ValueArray; |
127 | struct Lookup; |
128 | struct ArrayData; |
129 | struct VTable; |
130 | struct Function; |
131 | |
132 | struct BooleanObject; |
133 | struct NumberObject; |
134 | struct StringObject; |
135 | struct ArrayObject; |
136 | struct DateObject; |
137 | struct FunctionObject; |
138 | struct ErrorObject; |
139 | struct ArgumentsObject; |
140 | struct Managed; |
141 | struct ExecutionEngine; |
142 | struct QObjectWrapper; |
143 | struct RegExpObject; |
144 | struct RegExp; |
145 | struct EvalFunction; |
146 | |
147 | struct SharedArrayBuffer; |
148 | struct ArrayBuffer; |
149 | struct DataView; |
150 | struct TypedArray; |
151 | |
152 | struct MapObject; |
153 | struct SetMapObject; |
154 | |
155 | struct PromiseObject; |
156 | struct PromiseCapability; |
157 | |
158 | struct CallData; |
159 | struct Scope; |
160 | struct ScopedValue; |
161 | template<typename T> struct Scoped; |
162 | typedef Scoped<String> ScopedString; |
163 | typedef Scoped<StringOrSymbol> ScopedStringOrSymbol; |
164 | typedef Scoped<Object> ScopedObject; |
165 | typedef Scoped<ArrayObject> ScopedArrayObject; |
166 | typedef Scoped<FunctionObject> ScopedFunctionObject; |
167 | typedef Scoped<ExecutionContext> ScopedContext; |
168 | |
169 | struct PersistentValueStorage; |
170 | class PersistentValue; |
171 | class WeakValue; |
172 | struct MarkStack; |
173 | |
174 | struct IdentifierTable; |
175 | class RegExpCache; |
176 | class MultiplyWrappedQObjectMap; |
177 | |
178 | enum PropertyFlag { |
179 | Attr_Data = 0, |
180 | Attr_Accessor = 0x1, |
181 | Attr_NotWritable = 0x2, |
182 | Attr_NotEnumerable = 0x4, |
183 | Attr_NotConfigurable = 0x8, |
184 | Attr_ReadOnly = Attr_NotWritable|Attr_NotEnumerable|Attr_NotConfigurable, |
185 | Attr_ReadOnly_ButConfigurable = Attr_NotWritable|Attr_NotEnumerable, |
186 | Attr_Invalid = 0xff |
187 | }; |
188 | |
189 | Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag) |
190 | Q_DECLARE_OPERATORS_FOR_FLAGS(PropertyFlags) |
191 | |
192 | struct PropertyAttributes |
193 | { |
194 | union { |
195 | uchar m_all; |
196 | struct { |
197 | uchar m_flags : 4; |
198 | uchar m_mask : 4; |
199 | }; |
200 | struct { |
201 | uchar m_type : 1; |
202 | uchar m_writable : 1; |
203 | uchar m_enumerable : 1; |
204 | uchar m_configurable : 1; |
205 | uchar type_set : 1; |
206 | uchar writable_set : 1; |
207 | uchar enumerable_set : 1; |
208 | uchar configurable_set : 1; |
209 | }; |
210 | }; |
211 | |
212 | enum Type { |
213 | Data = 0, |
214 | Accessor = 1, |
215 | Generic = 2 |
216 | }; |
217 | |
218 | PropertyAttributes() : m_all(0) {} |
219 | PropertyAttributes(PropertyFlag f) : m_all(0) { |
220 | if (f != Attr_Invalid) { |
221 | setType(f & Attr_Accessor ? Accessor : Data); |
222 | if (!(f & Attr_Accessor)) |
223 | setWritable(!(f & Attr_NotWritable)); |
224 | setEnumerable(!(f & Attr_NotEnumerable)); |
225 | setConfigurable(!(f & Attr_NotConfigurable)); |
226 | } |
227 | } |
228 | PropertyAttributes(PropertyFlags f) : m_all(0) { |
229 | if (f != Attr_Invalid) { |
230 | setType(f & Attr_Accessor ? Accessor : Data); |
231 | if (!(f & Attr_Accessor)) |
232 | setWritable(!(f & Attr_NotWritable)); |
233 | setEnumerable(!(f & Attr_NotEnumerable)); |
234 | setConfigurable(!(f & Attr_NotConfigurable)); |
235 | } |
236 | } |
237 | |
238 | void setType(Type t) { m_type = t; type_set = true; } |
239 | Type type() const { return type_set ? (Type)m_type : Generic; } |
240 | |
241 | bool isData() const { return type() == PropertyAttributes::Data || writable_set; } |
242 | bool isAccessor() const { return type() == PropertyAttributes::Accessor; } |
243 | bool isGeneric() const { return type() == PropertyAttributes::Generic && !writable_set; } |
244 | |
245 | bool hasType() const { return type_set; } |
246 | bool hasWritable() const { return writable_set; } |
247 | bool hasConfigurable() const { return configurable_set; } |
248 | bool hasEnumerable() const { return enumerable_set; } |
249 | |
250 | void setWritable(bool b) { m_writable = b; writable_set = true; } |
251 | void setConfigurable(bool b) { m_configurable = b; configurable_set = true; } |
252 | void setEnumerable(bool b) { m_enumerable = b; enumerable_set = true; } |
253 | |
254 | void resolve() { m_mask = 0xf; if (m_type == Accessor) { m_writable = false; writable_set = false; } } |
255 | |
256 | bool isWritable() const { return m_type != Data || m_writable; } |
257 | bool isEnumerable() const { return m_enumerable; } |
258 | bool isConfigurable() const { return m_configurable; } |
259 | |
260 | void clearType() { m_type = Data; type_set = false; } |
261 | void clearWritable() { m_writable = false; writable_set = false; } |
262 | void clearEnumerable() { m_enumerable = false; enumerable_set = false; } |
263 | void clearConfigurable() { m_configurable = false; configurable_set = false; } |
264 | |
265 | void clear() { m_all = 0; } |
266 | bool isEmpty() const { return !m_all; } |
267 | |
268 | uint all() const { return m_all; } |
269 | |
270 | bool operator==(PropertyAttributes other) { |
271 | return m_all == other.m_all; |
272 | } |
273 | bool operator!=(PropertyAttributes other) { |
274 | return m_all != other.m_all; |
275 | } |
276 | }; |
277 | |
278 | struct Q_QML_EXPORT StackFrame { |
279 | QString source; |
280 | QString function; |
281 | int line = -1; |
282 | int column = -1; |
283 | }; |
284 | typedef QVector<StackFrame> StackTrace; |
285 | |
286 | namespace JIT { |
287 | |
288 | enum class CallResultDestination { |
289 | Ignore, |
290 | InAccumulator, |
291 | }; |
292 | |
293 | } // JIT namespace |
294 | |
295 | } // QV4 namespace |
296 | |
297 | Q_DECLARE_TYPEINFO(QV4::PropertyAttributes, Q_PRIMITIVE_TYPE); |
298 | |
299 | QT_END_NAMESPACE |
300 | |
301 | #endif // QV4GLOBAL_H |
302 | |