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

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtdeclarative/src/qml/jsruntime/qv4global_p.h