feat(library/vm/vm): add scope_vm_state
This commit is contained in:
parent
fd068344a6
commit
a30603405c
2 changed files with 17 additions and 0 deletions
|
|
@ -1004,6 +1004,15 @@ void vm_state::invoke_builtin(vm_decl const & d) {
|
|||
|
||||
LEAN_THREAD_VALUE(vm_state *, g_vm_state, nullptr);
|
||||
|
||||
scope_vm_state::scope_vm_state(vm_state & s):
|
||||
m_prev(g_vm_state) {
|
||||
g_vm_state = &s;
|
||||
}
|
||||
|
||||
scope_vm_state::~scope_vm_state() {
|
||||
g_vm_state = m_prev;
|
||||
}
|
||||
|
||||
void vm_state::invoke_cfun(vm_decl const & d) {
|
||||
flet<vm_state *> Set(g_vm_state, this);
|
||||
auto & S = m_stack;
|
||||
|
|
|
|||
|
|
@ -583,6 +583,14 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
/** \brief Helper class for setting thread local vm_state object */
|
||||
class scope_vm_state {
|
||||
vm_state * m_prev;
|
||||
public:
|
||||
scope_vm_state(vm_state & s);
|
||||
~scope_vm_state();
|
||||
};
|
||||
|
||||
/** \brief Return reference to thread local VM state object. */
|
||||
vm_state const & get_vm_state();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue