1// Copyright (C) 2019 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 QV4CALLDATA_P_H
5#define QV4CALLDATA_P_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 <private/qv4staticvalue_p.h>
19
20QT_BEGIN_NAMESPACE
21
22namespace QV4 {
23
24struct CallData
25{
26 enum Offsets {
27 Function = 0,
28 Context = 1,
29 Accumulator = 2,
30 This = 3,
31 NewTarget = 4,
32 Argc = 5,
33
34 LastOffset = Argc,
35 OffsetCount = LastOffset + 1
36 };
37
38 StaticValue function;
39 StaticValue context;
40 StaticValue accumulator;
41 StaticValue thisObject;
42 StaticValue newTarget;
43 StaticValue _argc;
44
45 int argc() const {
46 Q_ASSERT(_argc.isInteger());
47 return _argc.int_32();
48 }
49
50 void setArgc(int argc) {
51 Q_ASSERT(argc >= 0);
52 _argc.setInt_32(argc);
53 }
54
55 inline ReturnedValue argument(int i) const {
56 return i < argc() ? args[i].asReturnedValue()
57 : StaticValue::undefinedValue().asReturnedValue();
58 }
59
60 StaticValue args[1];
61
62 static constexpr int HeaderSize()
63 {
64 return offsetof(CallData, args) / sizeof(QV4::StaticValue);
65 }
66
67 template<typename Value>
68 Value *argValues();
69
70 template<typename Value>
71 const Value *argValues() const;
72};
73
74Q_STATIC_ASSERT(std::is_standard_layout<CallData>::value);
75Q_STATIC_ASSERT(offsetof(CallData, function ) == CallData::Function * sizeof(StaticValue));
76Q_STATIC_ASSERT(offsetof(CallData, context ) == CallData::Context * sizeof(StaticValue));
77Q_STATIC_ASSERT(offsetof(CallData, accumulator) == CallData::Accumulator * sizeof(StaticValue));
78Q_STATIC_ASSERT(offsetof(CallData, thisObject ) == CallData::This * sizeof(StaticValue));
79Q_STATIC_ASSERT(offsetof(CallData, newTarget ) == CallData::NewTarget * sizeof(StaticValue));
80Q_STATIC_ASSERT(offsetof(CallData, _argc ) == CallData::Argc * sizeof(StaticValue));
81Q_STATIC_ASSERT(offsetof(CallData, args ) == 6 * sizeof(StaticValue));
82
83} // namespace QV4
84
85QT_END_NAMESPACE
86
87#endif // QV4CALLDATA_P_H
88

source code of qtdeclarative/src/qml/common/qv4calldata_p.h