2021-03-24 22:37:53 +01:00
|
|
|
#include "cs_thread.hh"
|
|
|
|
|
|
|
|
namespace cubescript {
|
|
|
|
|
|
|
|
thread_state::thread_state(internal_state *cs):
|
2021-04-02 19:12:46 +02:00
|
|
|
vmstack{cs}, idstack{cs}, astacks{cs}, errbuf{cs}
|
2021-03-24 22:37:53 +01:00
|
|
|
{
|
2021-03-28 01:33:31 +01:00
|
|
|
vmstack.reserve(32);
|
2021-03-30 00:28:06 +02:00
|
|
|
idstack.reserve(MAX_ARGUMENTS);
|
2021-03-24 22:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hook_func thread_state::set_hook(hook_func f) {
|
|
|
|
auto hk = std::move(call_hook);
|
|
|
|
call_hook = std::move(f);
|
|
|
|
return hk;
|
|
|
|
}
|
|
|
|
|
2021-05-02 22:44:38 +02:00
|
|
|
alias_stack &thread_state::get_astack(alias const *a) {
|
2021-05-05 03:16:32 +02:00
|
|
|
auto it = astacks.try_emplace(a->index());
|
2021-04-02 19:12:46 +02:00
|
|
|
if (it.second) {
|
2021-05-02 22:44:38 +02:00
|
|
|
auto *imp = const_cast<alias_impl *>(
|
|
|
|
static_cast<alias_impl const *>(a)
|
|
|
|
);
|
|
|
|
it.first->second.node = &imp->p_initial;
|
|
|
|
it.first->second.flags = imp->p_flags;
|
2021-04-02 19:12:46 +02:00
|
|
|
}
|
|
|
|
return it.first->second;
|
2021-04-02 05:47:49 +02:00
|
|
|
}
|
|
|
|
|
2021-03-28 01:33:31 +01:00
|
|
|
} /* namespace cubescript */
|