Skip to content

Commit 62cfb87

Browse files
committed
Move ThreadContext to execute.hpp
1 parent e0a6dfd commit 62cfb87

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

lib/fizzy/execute.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ constexpr ExecutionResult Void{true};
4141
/// Shortcut for execution that resulted in a trap.
4242
constexpr ExecutionResult Trap{false};
4343

44+
45+
class ThreadContext
46+
{
47+
class [[nodiscard]] Guard
48+
{
49+
ThreadContext& m_thread_context;
50+
51+
public:
52+
explicit Guard(ThreadContext& ctx) noexcept : m_thread_context{ctx} {}
53+
~Guard() noexcept { --m_thread_context.depth; }
54+
};
55+
56+
public:
57+
int depth = 0;
58+
59+
Guard bump_call_depth() noexcept
60+
{
61+
++depth;
62+
return Guard{*this};
63+
}
64+
};
65+
4466
/// Execute a function from an instance.
4567
///
4668
/// @param instance The instance.

lib/fizzy/instantiate.hpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,7 @@ namespace fizzy
2020
{
2121
struct ExecutionResult;
2222
struct Instance;
23-
24-
class ThreadContext
25-
{
26-
class [[nodiscard]] Guard
27-
{
28-
ThreadContext& m_thread_context;
29-
30-
public:
31-
explicit Guard(ThreadContext& ctx) noexcept : m_thread_context{ctx} {}
32-
~Guard() noexcept { --m_thread_context.depth; }
33-
};
34-
35-
public:
36-
int depth = 0;
37-
38-
Guard bump_call_depth() noexcept
39-
{
40-
++depth;
41-
return Guard{*this};
42-
}
43-
};
23+
class ThreadContext;
4424

4525
/// Function representing WebAssembly or host function execution.
4626
using execute_function = std::function<ExecutionResult(Instance&, const Value*, ThreadContext&)>;

0 commit comments

Comments
 (0)