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.cpp
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#include <private/qv4bytecodehandler_p.h>
6
7QT_USE_NAMESPACE
8using namespace QV4;
9using namespace Moth;
10
11ByteCodeHandler::~ByteCodeHandler()
12{
13}
14
15#define DISPATCH_INSTRUCTION(name, nargs, ...)
16 generate_##name(
17 __VA_ARGS__
18 );
19
20#define DECODE_AND_DISPATCH(instr)
21 {
22 INSTR_##instr(MOTH_DECODE_WITH_BASE)
23 Q_UNUSED(base_ptr);
24 _currentOffset = _nextOffset;
25 _nextOffset = code - start;
26 if (startInstruction(Instr::Type::instr) == ProcessInstruction) {
27 INSTR_##instr(DISPATCH)
28 endInstruction(Instr::Type::instr);
29 }
30 continue;
31 }
32
33void ByteCodeHandler::decode(const char *code, uint len)
34{
35 MOTH_JUMP_TABLE;
36
37 const char *start = code;
38 const char *end = code + len;
39 while (code < end) {
40 MOTH_DISPATCH()
41
42 FOR_EACH_MOTH_INSTR(DECODE_AND_DISPATCH)
43 }
44}
45
46#undef DECODE_AND_DISPATCH
47#undef DISPATCH_INSTRUCTION