mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
47 lines
1.4 KiB
C++
47 lines
1.4 KiB
C++
/*
|
|
* 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; }
|
|
void clear_trap() { m_do_trap = false; }
|
|
|
|
Function<bool(Configuration&, InstructionPointer&, const Instruction&)>* pre_interpret_hook { nullptr };
|
|
Function<bool(Configuration&, InstructionPointer&, const Instruction&, const Interpreter&)>* post_interpret_hook { nullptr };
|
|
|
|
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 };
|
|
};
|
|
|
|
}
|