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#ifndef QV4RUNTIMEAPI_P_H
4#define QV4RUNTIMEAPI_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <private/qv4global_p.h>
18#include <private/qv4staticvalue_p.h>
19
20QT_BEGIN_NAMESPACE
21
22namespace QV4 {
23
24typedef uint Bool;
25
26struct Q_QML_EXPORT Runtime {
27 typedef ReturnedValue (*UnaryOperation)(const Value &value);
28 typedef ReturnedValue (*BinaryOperation)(const Value &left, const Value &right);
29 typedef ReturnedValue (*BinaryOperationContext)(ExecutionEngine *, const Value &left, const Value &right);
30
31 enum class Throws { No, Yes };
32 enum class ChangesContext { No, Yes };
33 enum class Pure { No, Yes };
34 enum class LastArgumentIsOutputValue { No, Yes };
35
36 template<Throws t, ChangesContext c = ChangesContext::No, Pure p = Pure::No,
37 LastArgumentIsOutputValue out = LastArgumentIsOutputValue::No>
38 struct Method
39 {
40 static constexpr bool throws = t == Throws::Yes;
41 static constexpr bool changesContext = c == ChangesContext::Yes;
42 static constexpr bool pure = p == Pure::Yes;
43 static constexpr bool lastArgumentIsOutputValue = out == LastArgumentIsOutputValue::Yes;
44 };
45 using PureMethod = Method<Throws::No, ChangesContext::No, Pure::Yes>;
46 using IteratorMethod = Method<Throws::No, ChangesContext::No, Pure::No,
47 LastArgumentIsOutputValue::Yes>;
48
49 /* call */
50 struct Q_QML_EXPORT CallGlobalLookup : Method<Throws::Yes>
51 {
52 static ReturnedValue call(ExecutionEngine *, uint, Value[], int);
53 };
54 struct Q_QML_EXPORT CallQmlContextPropertyLookup : Method<Throws::Yes>
55 {
56 static ReturnedValue call(ExecutionEngine *, uint, Value[], int);
57 };
58 struct Q_QML_EXPORT CallName : Method<Throws::Yes>
59 {
60 static ReturnedValue call(ExecutionEngine *, int, Value[], int);
61 };
62 struct Q_QML_EXPORT CallProperty : Method<Throws::Yes>
63 {
64 static ReturnedValue call(ExecutionEngine *, const Value &, int, Value[], int);
65 };
66 struct Q_QML_EXPORT CallPropertyLookup : Method<Throws::Yes>
67 {
68 static ReturnedValue call(ExecutionEngine *, const Value &, uint, Value[], int);
69 };
70 struct Q_QML_EXPORT CallValue : Method<Throws::Yes>
71 {
72 static ReturnedValue call(ExecutionEngine *, const Value &, Value[], int);
73 };
74 struct Q_QML_EXPORT CallWithReceiver : Method<Throws::Yes>
75 {
76 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value[], int);
77 };
78 struct Q_QML_EXPORT CallPossiblyDirectEval : Method<Throws::Yes>
79 {
80 static ReturnedValue call(ExecutionEngine *, Value[], int);
81 };
82 struct Q_QML_EXPORT CallWithSpread : Method<Throws::Yes>
83 {
84 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value[], int);
85 };
86 struct Q_QML_EXPORT TailCall : Method<Throws::Yes>
87 {
88 static ReturnedValue call(JSTypesStackFrame *, ExecutionEngine *engine);
89 };
90
91 /* construct */
92 struct Q_QML_EXPORT Construct : Method<Throws::Yes>
93 {
94 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value[], int);
95 };
96 struct Q_QML_EXPORT ConstructWithSpread : Method<Throws::Yes>
97 {
98 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value[], int);
99 };
100
101 /* load & store */
102 struct Q_QML_EXPORT StoreNameStrict : Method<Throws::Yes>
103 {
104 static void call(ExecutionEngine *, int, const Value &);
105 };
106 struct Q_QML_EXPORT StoreNameSloppy : Method<Throws::Yes>
107 {
108 static void call(ExecutionEngine *, int, const Value &);
109 };
110 struct Q_QML_EXPORT StoreProperty : Method<Throws::Yes>
111 {
112 static void call(ExecutionEngine *, const Value &, int, const Value &);
113 };
114 struct Q_QML_EXPORT StoreElement : Method<Throws::Yes>
115 {
116 static void call(ExecutionEngine *, const Value &, const Value &, const Value &);
117 };
118 struct Q_QML_EXPORT LoadProperty : Method<Throws::Yes>
119 {
120 static ReturnedValue call(ExecutionEngine *, const Value &, int);
121 };
122 struct Q_QML_EXPORT LoadName : Method<Throws::Yes>
123 {
124 static ReturnedValue call(ExecutionEngine *, int);
125 };
126 struct Q_QML_EXPORT LoadElement : Method<Throws::Yes>
127 {
128 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &);
129 };
130 struct Q_QML_EXPORT LoadSuperProperty : Method<Throws::Yes>
131 {
132 static ReturnedValue call(ExecutionEngine *, const Value &);
133 };
134 struct Q_QML_EXPORT StoreSuperProperty : Method<Throws::Yes>
135 {
136 static void call(ExecutionEngine *, const Value &, const Value &);
137 };
138 struct Q_QML_EXPORT LoadSuperConstructor : Method<Throws::Yes>
139 {
140 static ReturnedValue call(ExecutionEngine *, const Value &);
141 };
142 struct Q_QML_EXPORT LoadGlobalLookup : Method<Throws::Yes>
143 {
144 static ReturnedValue call(ExecutionEngine *, Function *, int);
145 };
146 struct Q_QML_EXPORT LoadQmlContextPropertyLookup : Method<Throws::Yes>
147 {
148 static ReturnedValue call(ExecutionEngine *, uint);
149 };
150 struct Q_QML_EXPORT GetLookup : Method<Throws::Yes>
151 {
152 static ReturnedValue call(ExecutionEngine *, Function *, const Value &, int);
153 };
154 struct Q_QML_EXPORT SetLookupStrict : Method<Throws::Yes>
155 {
156 static void call(Function *, const Value &, int, const Value &);
157 };
158 struct Q_QML_EXPORT SetLookupSloppy : Method<Throws::Yes>
159 {
160 static void call(Function *, const Value &, int, const Value &);
161 };
162
163 /* typeof */
164 struct Q_QML_EXPORT TypeofValue : PureMethod
165 {
166 static ReturnedValue call(ExecutionEngine *, const Value &);
167 };
168 struct Q_QML_EXPORT TypeofName : Method<Throws::No>
169 {
170 static ReturnedValue call(ExecutionEngine *, int);
171 };
172
173 /* delete */
174 struct Q_QML_EXPORT DeleteProperty_NoThrow : Method<Throws::No>
175 {
176 static Bool call(ExecutionEngine *, const Value &, const Value &);
177 };
178 struct Q_QML_EXPORT DeleteProperty : Method<Throws::Yes>
179 {
180 static ReturnedValue call(ExecutionEngine *, Function *, const Value &, const Value &);
181 };
182 struct Q_QML_EXPORT DeleteName_NoThrow : Method<Throws::No>
183 {
184 static Bool call(ExecutionEngine *, int);
185 };
186 struct Q_QML_EXPORT DeleteName : Method<Throws::Yes>
187 {
188 static ReturnedValue call(ExecutionEngine *, Function *, int);
189 };
190
191 /* exceptions & scopes */
192 struct Q_QML_EXPORT ThrowException : Method<Throws::Yes>
193 {
194 static void call(ExecutionEngine *, const Value &);
195 };
196 struct Q_QML_EXPORT PushCallContext : Method<Throws::No, ChangesContext::Yes>
197 {
198 static void call(JSTypesStackFrame *);
199 };
200 struct Q_QML_EXPORT PushWithContext : Method<Throws::Yes, ChangesContext::Yes>
201 {
202 static ReturnedValue call(ExecutionEngine *, const Value &);
203 };
204 struct Q_QML_EXPORT PushCatchContext : Method<Throws::No, ChangesContext::Yes>
205 {
206 static void call(ExecutionEngine *, int, int);
207 };
208 struct Q_QML_EXPORT PushBlockContext : Method<Throws::No, ChangesContext::Yes>
209 {
210 static void call(ExecutionEngine *, int);
211 };
212 struct Q_QML_EXPORT CloneBlockContext : Method<Throws::No, ChangesContext::Yes>
213 {
214 static void call(ExecutionEngine *);
215 };
216 struct Q_QML_EXPORT PushScriptContext : Method<Throws::No, ChangesContext::Yes>
217 {
218 static void call(ExecutionEngine *, int);
219 };
220 struct Q_QML_EXPORT PopScriptContext : Method<Throws::No, ChangesContext::Yes>
221 {
222 static void call(ExecutionEngine *);
223 };
224 struct Q_QML_EXPORT ThrowReferenceError : Method<Throws::Yes>
225 {
226 static void call(ExecutionEngine *, int);
227 };
228 struct Q_QML_EXPORT ThrowOnNullOrUndefined : Method<Throws::Yes>
229 {
230 static void call(ExecutionEngine *, const Value &);
231 };
232
233 /* garbage collection */
234 struct Q_QML_EXPORT MarkCustom : PureMethod
235 {
236 static void call(const Value &toBeMarked);
237 };
238
239 /* closures */
240 struct Q_QML_EXPORT Closure : Method<Throws::No>
241 {
242 static ReturnedValue call(ExecutionEngine *, int);
243 };
244
245 /* Function header */
246 struct Q_QML_EXPORT ConvertThisToObject : Method<Throws::Yes>
247 {
248 static ReturnedValue call(ExecutionEngine *, const Value &);
249 };
250 struct Q_QML_EXPORT DeclareVar : Method<Throws::Yes>
251 {
252 static void call(ExecutionEngine *, Bool, int);
253 };
254 struct Q_QML_EXPORT CreateMappedArgumentsObject : Method<Throws::No>
255 {
256 static ReturnedValue call(ExecutionEngine *);
257 };
258 struct Q_QML_EXPORT CreateUnmappedArgumentsObject : Method<Throws::No>
259 {
260 static ReturnedValue call(ExecutionEngine *);
261 };
262 struct Q_QML_EXPORT CreateRestParameter : PureMethod
263 {
264 static ReturnedValue call(ExecutionEngine *, int);
265 };
266
267 /* literals */
268 struct Q_QML_EXPORT ArrayLiteral : Method<Throws::Yes>
269 {
270 static ReturnedValue call(ExecutionEngine *, Value[], uint);
271 };
272 struct Q_QML_EXPORT ObjectLiteral : Method<Throws::Yes>
273 {
274 static ReturnedValue call(ExecutionEngine *, int, Value[], int);
275 };
276 struct Q_QML_EXPORT CreateClass : Method<Throws::Yes>
277 {
278 static ReturnedValue call(ExecutionEngine *, int, const Value &, Value[]);
279 };
280
281 /* for-in, for-of and array destructuring */
282 struct Q_QML_EXPORT GetIterator : Method<Throws::Yes>
283 {
284 static ReturnedValue call(ExecutionEngine *, const Value &, int);
285 };
286 struct Q_QML_EXPORT IteratorNext : IteratorMethod
287 {
288 static ReturnedValue call(ExecutionEngine *, const Value &, Value *);
289 };
290 struct Q_QML_EXPORT IteratorNextForYieldStar : IteratorMethod
291 {
292 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &, Value *);
293 };
294 struct Q_QML_EXPORT IteratorClose : Method<Throws::No>
295 {
296 static ReturnedValue call(ExecutionEngine *, const Value &);
297 };
298 struct Q_QML_EXPORT DestructureRestElement : Method<Throws::Yes>
299 {
300 static ReturnedValue call(ExecutionEngine *, const Value &);
301 };
302
303 /* conversions */
304 struct Q_QML_EXPORT ToObject : Method<Throws::Yes>
305 {
306 static ReturnedValue call(ExecutionEngine *, const Value &);
307 };
308 struct Q_QML_EXPORT ToBoolean : PureMethod
309 {
310 static Bool call(const Value &);
311 };
312 struct Q_QML_EXPORT ToNumber : Method<Throws::Yes>
313 {
314 static ReturnedValue call(ExecutionEngine *, const Value &);
315 };
316 /* unary operators */
317 struct Q_QML_EXPORT UMinus : Method<Throws::Yes>
318 {
319 static ReturnedValue call(const Value &);
320 };
321
322 /* binary operators */
323 struct Q_QML_EXPORT Instanceof : Method<Throws::Yes>
324 {
325 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &);
326 };
327 struct Q_QML_EXPORT As : Method<Throws::No>
328 {
329 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &);
330 };
331 struct Q_QML_EXPORT In : Method<Throws::Yes>
332 {
333 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &);
334 };
335 struct Q_QML_EXPORT Add : Method<Throws::Yes>
336 {
337 static ReturnedValue call(ExecutionEngine *, const Value &, const Value &);
338 };
339 struct Q_QML_EXPORT Sub : Method<Throws::Yes>
340 {
341 static ReturnedValue call(const Value &, const Value &);
342 };
343 struct Q_QML_EXPORT Mul : Method<Throws::Yes>
344 {
345 static ReturnedValue call(const Value &, const Value &);
346 };
347 struct Q_QML_EXPORT Div : Method<Throws::Yes>
348 {
349 static ReturnedValue call(const Value &, const Value &);
350 };
351 struct Q_QML_EXPORT Mod : Method<Throws::Yes>
352 {
353 static ReturnedValue call(const Value &, const Value &);
354 };
355 struct Q_QML_EXPORT Exp : Method<Throws::Yes>
356 {
357 static ReturnedValue call(const Value &, const Value &);
358 };
359 struct Q_QML_EXPORT BitAnd : Method<Throws::Yes>
360 {
361 static ReturnedValue call(const Value &, const Value &);
362 };
363 struct Q_QML_EXPORT BitOr : Method<Throws::Yes>
364 {
365 static ReturnedValue call(const Value &, const Value &);
366 };
367 struct Q_QML_EXPORT BitXor : Method<Throws::Yes>
368 {
369 static ReturnedValue call(const Value &, const Value &);
370 };
371 struct Q_QML_EXPORT Shl : Method<Throws::Yes>
372 {
373 static ReturnedValue call(const Value &, const Value &);
374 };
375 struct Q_QML_EXPORT Shr : Method<Throws::Yes>
376 {
377 static ReturnedValue call(const Value &, const Value &);
378 };
379 struct Q_QML_EXPORT UShr : Method<Throws::Yes>
380 {
381 static ReturnedValue call(const Value &, const Value &);
382 };
383 struct Q_QML_EXPORT GreaterThan : Method<Throws::Yes>
384 {
385 static ReturnedValue call(const Value &, const Value &);
386 };
387 struct Q_QML_EXPORT LessThan : Method<Throws::Yes>
388 {
389 static ReturnedValue call(const Value &, const Value &);
390 };
391 struct Q_QML_EXPORT GreaterEqual : Method<Throws::Yes>
392 {
393 static ReturnedValue call(const Value &, const Value &);
394 };
395 struct Q_QML_EXPORT LessEqual : Method<Throws::Yes>
396 {
397 static ReturnedValue call(const Value &, const Value &);
398 };
399 struct Q_QML_EXPORT Equal : Method<Throws::Yes>
400 {
401 static ReturnedValue call(const Value &, const Value &);
402 };
403 struct Q_QML_EXPORT NotEqual : Method<Throws::Yes>
404 {
405 static ReturnedValue call(const Value &, const Value &);
406 };
407 struct Q_QML_EXPORT StrictEqual : Method<Throws::Yes>
408 {
409 static ReturnedValue call(const Value &, const Value &);
410 };
411 struct Q_QML_EXPORT StrictNotEqual : Method<Throws::Yes>
412 {
413 static ReturnedValue call(const Value &, const Value &);
414 };
415
416 /* comparisons */
417 struct Q_QML_EXPORT CompareGreaterThan : Method<Throws::Yes>
418 {
419 static Bool call(const Value &, const Value &);
420 };
421 struct Q_QML_EXPORT CompareLessThan : Method<Throws::Yes>
422 {
423 static Bool call(const Value &, const Value &);
424 };
425 struct Q_QML_EXPORT CompareGreaterEqual : Method<Throws::Yes>
426 {
427 static Bool call(const Value &, const Value &);
428 };
429 struct Q_QML_EXPORT CompareLessEqual : Method<Throws::Yes>
430 {
431 static Bool call(const Value &, const Value &);
432 };
433 struct Q_QML_EXPORT CompareEqual : Method<Throws::Yes>
434 {
435 static Bool call(const Value &, const Value &);
436 };
437 struct Q_QML_EXPORT CompareNotEqual : Method<Throws::Yes>
438 {
439 static Bool call(const Value &, const Value &);
440 };
441 struct Q_QML_EXPORT CompareStrictEqual : Method<Throws::Yes>
442 {
443 static Bool call(const Value &, const Value &);
444 };
445 struct Q_QML_EXPORT CompareStrictNotEqual : Method<Throws::Yes>
446 {
447 static Bool call(const Value &, const Value &);
448 };
449
450 struct Q_QML_EXPORT CompareInstanceof : Method<Throws::Yes>
451 {
452 static Bool call(ExecutionEngine *, const Value &, const Value &);
453 };
454 struct Q_QML_EXPORT CompareIn : Method<Throws::Yes>
455 {
456 static Bool call(ExecutionEngine *, const Value &, const Value &);
457 };
458
459 struct Q_QML_EXPORT RegexpLiteral : PureMethod
460 {
461 static ReturnedValue call(ExecutionEngine *, int);
462 };
463 struct Q_QML_EXPORT GetTemplateObject : PureMethod
464 {
465 static ReturnedValue call(Function *, int);
466 };
467
468 struct StackOffsets {
469 static const int tailCall_function = -1;
470 static const int tailCall_thisObject = -2;
471 static const int tailCall_argv = -3;
472 static const int tailCall_argc = -4;
473 };
474
475 static QHash<const void *, const char *> symbolTable();
476};
477
478static_assert(std::is_standard_layout<Runtime>::value, "Runtime needs to be standard layout in order for us to be able to use offsetof");
479static_assert(sizeof(Runtime::BinaryOperation) == sizeof(void*), "JIT expects a function pointer to fit into a regular pointer, for cross-compilation offset translation");
480
481} // namespace QV4
482
483QT_END_NAMESPACE
484
485#endif // QV4RUNTIMEAPI_P_H
486

Provided by KDAB

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

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