blob: 7f5dfcdb5cecb6aa5987ebefc78c2a45c0125a10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/*
* Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWasm/AbstractMachine/Configuration.h>
namespace Wasm {
struct Interpreter {
void interpret(Configuration&);
bool did_trap() const { return m_do_trap; }
private:
void interpret(Configuration&, InstructionPointer&, const Instruction&);
void branch_to_label(Configuration&, LabelIndex);
ReadonlyBytes load_from_memory(Configuration&, const Instruction&, size_t);
void store_to_memory(Configuration&, const Instruction&, ReadonlyBytes data);
void call_address(Configuration&, FunctionAddress);
template<typename V, typename T>
MakeUnsigned<T> checked_unsigned_truncate(V);
template<typename V, typename T>
MakeSigned<T> checked_signed_truncate(V);
template<typename T>
T read_value(ReadonlyBytes data);
Vector<NonnullOwnPtr<Value>> pop_values(Configuration& configuration, size_t count);
bool trap_if_not(bool value)
{
if (!value)
m_do_trap = true;
return m_do_trap;
}
bool m_do_trap { false };
};
}
|