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 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
106struct CppStackFrame;
107struct JSTypesStackFrame;
108struct MetaTypesStackFrame;
109class MemoryManager;
110class ExecutableAllocator;
111struct PropertyKey;
112struct StringOrSymbol;
113struct String;
114struct Symbol;
115struct Object;
116struct ObjectPrototype;
117struct ObjectIterator;
118struct ExecutionContext;
119struct CallContext;
120struct QmlContext;
121struct ScriptFunction;
122struct InternalClass;
123struct Property;
124struct Value;
125template<size_t> struct HeapValue;
126template<size_t> struct ValueArray;
127struct Lookup;
128struct ArrayData;
129struct VTable;
130struct Function;
131
132struct BooleanObject;
133struct NumberObject;
134struct StringObject;
135struct ArrayObject;
136struct DateObject;
137struct FunctionObject;
138struct ErrorObject;
139struct ArgumentsObject;
140struct Managed;
141struct ExecutionEngine;
142struct QObjectWrapper;
143struct RegExpObject;
144struct RegExp;
145struct EvalFunction;
146
147struct SharedArrayBuffer;
148struct ArrayBuffer;
149struct DataView;
150struct TypedArray;
151
152struct MapObject;
153struct SetMapObject;
154
155struct PromiseObject;
156struct PromiseCapability;
157
158struct CallData;
159struct Scope;
160struct ScopedValue;
161template<typename T> struct Scoped;
162typedef Scoped<String> ScopedString;
163typedef Scoped<StringOrSymbol> ScopedStringOrSymbol;
164typedef Scoped<Object> ScopedObject;
165typedef Scoped<ArrayObject> ScopedArrayObject;
166typedef Scoped<FunctionObject> ScopedFunctionObject;
167typedef Scoped<ExecutionContext> ScopedContext;
168
169struct PersistentValueStorage;
170class PersistentValue;
171class WeakValue;
172struct MarkStack;
173
174struct IdentifierTable;
175class RegExpCache;
176class MultiplyWrappedQObjectMap;
177
178enum 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
189Q_DECLARE_FLAGS(PropertyFlags, PropertyFlag)
190Q_DECLARE_OPERATORS_FOR_FLAGS(PropertyFlags)
191
192struct 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
278struct Q_QML_EXPORT StackFrame {
279 QString source;
280 QString function;
281 int line = -1;
282 int column = -1;
283};
284typedef QVector<StackFrame> StackTrace;
285
286namespace JIT {
287
288enum class CallResultDestination {
289 Ignore,
290 InAccumulator,
291};
292
293} // JIT namespace
294
295} // QV4 namespace
296
297Q_DECLARE_TYPEINFO(QV4::PropertyAttributes, Q_PRIMITIVE_TYPE);
298
299QT_END_NAMESPACE
300
301#endif // QV4GLOBAL_H
302

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