Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4bytecodehandler_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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// Qt-Security score:significant
4
5#ifndef QV4BYTECODEHANDLER_P_H
6#define QV4BYTECODEHANDLER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <private/qtqmlcompilerglobal_p.h>
20#include <private/qv4instr_moth_p.h>
21
22QT_BEGIN_NAMESPACE
23
24namespace QV4 {
25namespace Moth {
26
27#define BYTECODE_HANDLER_DEFINE_ARGS(nargs, ...)
28 MOTH_EXPAND_FOR_MSVC(BYTECODE_HANDLER_DEFINE_ARGS##nargs(__VA_ARGS__))
29
30#define BYTECODE_HANDLER_DEFINE_ARGS0()
31#define BYTECODE_HANDLER_DEFINE_ARGS1(arg)
32 int arg
33#define BYTECODE_HANDLER_DEFINE_ARGS2(arg1, arg2)
34 int arg1,
35 int arg2
36#define BYTECODE_HANDLER_DEFINE_ARGS3(arg1, arg2, arg3)
37 int arg1,
38 int arg2,
39 int arg3
40#define BYTECODE_HANDLER_DEFINE_ARGS4(arg1, arg2, arg3, arg4)
41 int arg1,
42 int arg2,
43 int arg3,
44 int arg4
45#define BYTECODE_HANDLER_DEFINE_ARGS5(arg1, arg2, arg3, arg4, arg5)
46 int arg1,
47 int arg2,
48 int arg3,
49 int arg4,
50 int arg5
51
52#define BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER_INSTRUCTION(name, nargs, ...)
53 virtual void generate_##name(
54 BYTECODE_HANDLER_DEFINE_ARGS(nargs, __VA_ARGS__)
55 ) = 0;
56
57#define BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER(instr)
59
60class Q_QML_COMPILER_EXPORT ByteCodeHandler
61{
63public:
64 ByteCodeHandler() = default;
65 virtual ~ByteCodeHandler();
66
67 void decode(const char *code, uint len);
68 void reset() { _currentOffset = _nextOffset = 0; }
69
70 int currentInstructionOffset() const { return _currentOffset; }
71 int nextInstructionOffset() const { return _nextOffset; }
72 int absoluteOffset(int relativeOffset) const
73 { return nextInstructionOffset() + relativeOffset; }
74
75protected:
77
79 virtual Verdict startInstruction(Moth::Instr::Type instr) = 0;
80 virtual void endInstruction(Moth::Instr::Type instr) = 0;
81
82private:
83 int _currentOffset = 0;
84 int _nextOffset = 0;
85};
86
87} // Moth namespace
88} // QV4 namespace
89
90QT_END_NAMESPACE
91
92#endif // QV4BYTECODEHANDLER_P_H
virtual void endInstruction(Moth::Instr::Type instr)=0
int absoluteOffset(int relativeOffset) const
void decode(const char *code, uint len)
virtual Verdict startInstruction(Moth::Instr::Type instr)=0
Definition qjsvalue.h:24
#define BYTECODE_HANDLER_DEFINE_VIRTUAL_BYTECODE_HANDLER(instr)
#define BYTECODE_HANDLER_DEFINE_ARGS(nargs,...)